After completing this activities you will be able to automate linux automation tasks with ansible. Install ansible on a control node.
Automation avoid manual system administration and configuration. this allow administrator automate repetitive task A good automation process is to write a programm, ideally in comprehensive language, to focus on critical things.
Ansible is an open source automation platform. it's an automation engine that run ansible playbook. Ansible is a poerful management automation platform to many workflow and envirenments. Ansible playbook provide humain readable automation. it is easy for human to read, comprehend and change. playbook execute task in order. Ansible can be used to orchestrate the entire application productive quickly. there are two machine in the ansible architecture: control node and manage node. control node is an administration laptop in which ansible will be install and run. list of the manage node are list on the inventory file. the inventory file can be defined in a static or dynamic text file. A file that containt the task is call playbook. Each playbook life have an .yml extension
linux, Unix, Network device, cloud environment, virtualization, cointener environment Antomation language: amsible playbook
Ansible is simply to install on a control node(workstation) in which ansible will be run. Noted: the control node should only be Linux or Unix system. Microsoft Windows is not supported as a control node, Although windows system can be managed hosts.
Python 3 (3.6 or later) need to be installed on the control node Ensure you already subscrib to red hat subscription manager or setup local repolist
yum update
yum install epel-release -y
yum search python36
yum install python36 -y
alternatives --set python /usr/bin/python3
Different mode are available to install ansible In this case you will install ansible with the help od python module pip
yum install python3-pip
Use pip3 to install ansible
pip3 install ansible
command use to verified ansible installation
ansible --version
inventory is specified on ansible.cfg configuration file if configuration is not setup you can create ansible.cfg on /etc/ansible/ repository
touch /etc/ansible/ansible.cfg
setting in ansible.cfg are organize in two section
- fist section
[defaults]
inventory=/etc/myhost.txt
remote_user= root
host_key_checking=false
- defaults : set default setting
- inventory: specifies the path to the inventory file
- remote_user: is the name of the user that logs in on the remote hosts
- host_key_checking: specified whether or not to prompt for a password
- second section
[privilege_escalation]
become = True
become_method = sudo
become_user = root
become_ask_pass = False
- become : indicates if you want to automaticaly switch to the become_user
- become_method: set how to become the other user
- become_user: specified the remote user
- become_ask_pass: set if a password should be asked for when escalating
- Alternative inventory file can be specified through the ansible.cfg configuration file
- It is commaon pratice to put the inventory file in the current project directory
- the inventory file can also be specified on other location, but mention the path on ansible,cfg file
[inventory]
127.0.0.1
192.168.3.45
[Web]
192.168.3.40
[FileServer]
192.168.3.42
ansible -i inventory --list-hosts