Security is paramount in many industries today. Ansible can help make sure your environment is set up as your security office requires by pushing out changes and ensuring that current settings are live. In this lab, we’ll practice firewall and SELinux configuration.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Ensure Ports 80 and 22 Are Open on Webservers
Your playbook should look similar to the following:
``` --- - name: webserver firewall rules hosts: webservers become: yes tasks: - name: ssh firewall rules firewalld: permanent: yes state: enabled immediate: yes service: ssh - name: http firewall rules firewalld: permanent: yes state: enabled immediate: yes service: http ```
- Ensure Ports 5432 and 22 Are Open on dbservers
Your playbook should contain something similar to the following:
``` - name: Set up firewalls on dbservers hosts: dbservers become: yes tasks: - name: ssh firewall rules firewalld: permanent: yes state: enabled immediate: yes service: ssh - name: postgres rules firewalld: permanent: yes state: enabled immediate: yes service: postgresql ```
- Enable SELinux on All Servers
Your playbook should look similar to the following:
``` - name: SELinux hosts: all become: yes tasks: - name: Enable SELinux selinux: state: enforcing policy: targeted ```