Ansible is a Command Line Interface management tool that runs on Linux, MacOS, Windows (Operating System) locally or using SSH. It is built in Python.
Definitions
- Collections: a way to distribute and bundle together playbooks, roles, module and plugins
- Control node: a machine where Ansible is installed on and runs from
- Inventory: a list of nodes managed by Ansible
- Module: a unit of code executed by Ansible to do specific things
- Playbook: is a blueprint/ ordered list of automation tasks—which are complex IT actions executed with limited or no human involvement.
- Role: Groups of tasks with associated variables, templates, files etc
- Task: A unit of action in ansible
Example task of installing web server on Linux
# roles/example/tasks/main.yml
- name: Install the correct web server for RHEL
import_tasks: redhat.yml
when: ansible_facts[‘os_family’]|lower == ‘redhat’
- name: Install the correct web server for Debian
import_tasks: debian.yml
when: ansible_facts[‘os_family’]|lower == ‘debian’
# roles/example/tasks/redhat.yml
- name: Install web server
ansible.builtin.yum:
name: “httpd”
state: present
# roles/example/tasks/debian.yml
- name: Install web server
ansible.builtin.apt:
name: “apache2”
state: present