role prepare node
This commit is contained in:
parent
7d3db6acd9
commit
2349b59eca
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
configure_swap: true
|
||||
ip_tables_config: true
|
||||
|
|
@ -1,34 +1,4 @@
|
|||
---
|
||||
- name: Update all packages
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: dist
|
||||
|
||||
- name: Install essential packages
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- net-tools
|
||||
- curl
|
||||
- wget
|
||||
- htop
|
||||
- vim
|
||||
state: present
|
||||
|
||||
- name: Add 1GB swap file
|
||||
ansible.builtin.shell: |
|
||||
fallocate -l 1G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
args:
|
||||
creates: /swapfile
|
||||
|
||||
- name: Make swap persistent
|
||||
ansible.builtin.lineinfile:
|
||||
dest: /etc/fstab
|
||||
line: '/swapfile none swap sw 0 0'
|
||||
state: present
|
||||
|
||||
- name: Configure iptables firewall rules
|
||||
ansible.builtin.iptables:
|
||||
chain: INPUT
|
||||
|
|
@ -42,9 +12,10 @@
|
|||
- { protocol: tcp, port: '443', description: 'HTTPS for secure web traffic' }
|
||||
- { protocol: udp, port: '51820', description: 'WireGuard VPN traffic' }
|
||||
become: true
|
||||
become_exe: "{{ become_exe_value }}"
|
||||
register: iptables_result
|
||||
|
||||
- name: Display iptables configuration status
|
||||
ansible.builtin.debug:
|
||||
msg: "Configured firewall rules for ports: 80 (HTTP), 443 (HTTPS), 51820 (WireGuard UDP)"
|
||||
when: iptables_result is changed
|
||||
when: iptables_result is changed
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- include_role: updates.yaml
|
||||
- include_role: swap.yaml
|
||||
when: configure_swap is defined
|
||||
- include_role: iptables.yaml
|
||||
when: ip_tables_coonfig is defined
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: Add 1GB swap file
|
||||
ansible.builtin.shell: |
|
||||
fallocate -l 1G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
swapon /swapfile
|
||||
args:
|
||||
creates: /swapfile
|
||||
|
||||
- name: Make swap persistent
|
||||
ansible.builtin.lineinfile:
|
||||
dest: /etc/fstab
|
||||
line: '/swapfile none swap sw 0 0'
|
||||
state: present
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- name: Update all packages
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: dist
|
||||
|
||||
- name: Install essential packages
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- net-tools
|
||||
- curl
|
||||
- wget
|
||||
- htop
|
||||
- vim
|
||||
state: present
|
||||
Loading…
Reference in New Issue