Advertisement
D0cEvil

Ansible - Firewall config

Dec 27th, 2022
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.46 KB | Cybersecurity | 0 0
  1. ### Firewall Configurations ###
  2. - hosts: testservers
  3.   tasks:
  4.     # CentOS #
  5.  
  6.    - name: Allow HTTP CentOS
  7.      command: firewall-cmd --add-service=http --permanent
  8.      when: ansible_distribution == "CentOS"
  9.  
  10.    - name: Allow HTTPs CentOS
  11.      command: firewall-cmd --add-service=https --permanent
  12.      when: ansible_distribution == "CentOS"
  13.  
  14.    - name: Allow SQL CentOS
  15.      command: firewall-cmd --add-port=3306/tcp --permanent
  16.      when: ansible_distribution == "CentOS"
  17.  
  18.     # SUSE #
  19.  
  20.    - name: Allow HTTP SUSE
  21.      lineinfile: dest=/etc/sysconfig/SuSEfirewall2 line='FW_CONFIGURATIONS_EXT="apache2"' create="yes"
  22.      when: ansible_os_family == "Suse"
  23.  
  24.    - name: Allow SSH SUSE
  25.      lineinfile: dest=/etc/sysconfig/SuSEfirewall2 line='FW_SERVICES_EXT_TCP="ssh"' create="yes"
  26.      when: ansible_os_family == "Suse"
  27.  
  28.    - name: Allow PING SUSE
  29.      lineinfile: dest=/etc/sysconfig/SuSEfirewall2 line='FW_ALLOW_PING_FW="yes"' create="yes"
  30.      when: ansible_os_family == "Suse"
  31.  
  32. ### Firewall reboot ###
  33.  
  34.     # CentOS #
  35.  
  36.    - name: Reload Firewall settings CentOS
  37.      command: firewall-cmd --reload
  38.      when: ansible_distribution == "CentOS"
  39.  
  40.     # SUSE #
  41.  
  42.    - name: Reload init Firewall settings SUSE
  43.      command: /etc/init.d/SuSEfirewall2_init restart
  44.      when: ansible_os_family == "Suse"
  45.  
  46.    - name: Reload setup Firewall settings SUSE
  47.      command: /etc/init.d/SuSEfirewall2_setup restart
  48.      when: ansible_os_family == "Suse"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement