Automation is everywhere. I decided to take a quick look into Ansible
Ansible is the simplest way to automate apps and IT infrastructure using SSH, with no agents to install on remote systems.
Here is Intro to Ansible.
Ansible – Open Source IT Automation Platform
- using SSH and does not require an agent
- written in Python
- push-based architecture
- Ansible Core – free open source, no support, help is in the community
- Ansible Engine – the same code as Core, but supported by Red Hat (better for enterprise)
- Ansible Tower – GUI front end for Ansible Core – licensed
- Ansible AWX – Open-source version of Ansible Tower
How to install Ansible (CentOS)
$ sudo yum install epel-release
$ sudo yum install ansible
$ ansible –version
- Control node – Ansible and Python installed
- Management nodes – the network devices or servers to manage with Ansible
- Inventory – the file defines the hosts and groups of hosts, commands, modules, and tasks in a playbook
- static or dynamic file
- INI or YAML file
- default hosts file: /etc/ansible/hosts
- Modules – the code that Ansible executes (python files)
- Tasks – specific actions to perform within a Playbook
- Variables – something different about a specific host
- Playbooks – collection tasks written in YAML
- ansible.cfg – config file defines all custom options
- starts with “- – -” and ends with “…”
- task start with “- name: “
- use spaces
Playbook 1 to backup all config.
to run the playbook:
- -u username
- -k password
- –limit – limit playbook to run on one device name
- -i – specify the host file
Ansible makes changes only if there is a difference with existing output.
To change the default setting to display line numbers in vi/vim:
# then add the following line to the file:
Facts – information that we derive from speaking with the remote system. Ansible uses the setup module to discover this information automatically.
It could be very time-consuming.
Run playbook with conditions
– – –
– name: first playbook with when
– name: backup
when: ansible_network_os == ‘aci’