System Hardening is the process of securing a system's configuration and settings to reduce IT vulnerability and the possibility of being compromised. This can be done by reducing the attack surface and attack vectors which attackers continuously try to exploit for purpose of malicious activity.
ansible
Ansible is a tool for automation of configurations and deployments. Scripts are written in yaml files as playbooks. As a Security tool we can use ansible to apply OS updates, service packs, and patches automatically; remove unnecessary drivers, file sharing, libraries, software, services, and functionality. These tasks are part of system hardening.
ansible -i inventory.ini machinename -m copy -a "src=notes.txt dest=notes.txt"
---
- name: Get the version of nginx
hosts: all
remote_user: root
gather_facts: no
tasks:
- name: Check if nginx is installed
command: which nginx
register: nginx_version
- name: Print nginx version
command: nginx -v | echo
when: nginx_version != -1
- debug:
msg: "Nginx is not installed"
when: nginx_version == -1
---
- name: Simple playbook
hosts: all
remote_user: root
gather_facts: no # what does it mean?
tasks:
- name: Show the content of /etc/os-release
command: cat /etc/os-release
register: os_release
- debug:
msg: "This system uses Ubuntu-based distro"
when: os_release.stdout.find('Ubuntu') != -1