tags: ansible, ansible tutorial, ansible tutorial in hindi, ansible class, automation, automation tools, devops tools, #ansible, Ansible installation, in centos 7, automated tasks, ansible inventory, ansible roles, ansible playbook, ansible modules, ansible ping hosts, linuxtopic, linux topic, ansible video turorial, ansible tower, ansible documentation, ansible family, ansble open source,
Ansible is a free, powerful, open source automation tool for configuring, managing and deploying software applications on the nodes by using SSH.
Ansible run without agent in remote host it just required ssh connection and python ( 2.4 or higher )on all nodes.
Ansible Host
OS - CentOS 7
Kernel - 3.10.0-693.17.1.el7.x86_64
IP - 172.17.20.100
Hostname - linuxtopic.com
Prerequisite
Install Require Packages
yum install PyYAML sshpass python-httplib2 python-jinja2 epel*
Install Ansible using following command.
yum install ansible -y
To verify the ansible version
ansible --version
Ansible default structure
- ansible.cfg
- hosts
- roles
ls /etc/ansible
ansible.cfg : Main Configuration File
vi /etc/ansible/ansible.cfg
Check following points and uncomment if you want to change default settings
#inventory = /etc/ansible/hosts
#library = /usr/share/my_modules/
#module_utils = /usr/share/my_module_utils/
#remote_tmp = ~/.ansible/tmp
#local_tmp = ~/.ansible/tmp
#plugin_filters_cfg = /etc/ansible/plugin_filters.yml
#forks = 5
#poll_interval = 15
#sudo_user = root
#ask_sudo_pass = True
#ask_pass = True
#transport = smart
#remote_port = 22
#module_lang = C
#module_set_locale = False
# uncomment this to disable SSH key host checking
host_key_checking = False
# additional paths to search for roles in, colon separated
#roles_path = /etc/ansible/roles
# SSH timeout
#timeout = 10
# default user to use for playbooks if user is not specified
# (/usr/bin/ansible will use current user as default)
#remote_user = root
# logging is off by default unless this path is defined
# if so defined, consider logrotate
#log_path = /var/log/ansible.log
# if set, always use this private key file for authentication, same as
# if passing --private-key to ansible or ansible-playbook
#private_key_file = /path/to/file
# If set, configures the path to the Vault password file as an alternative to
# specifying --vault-password-file on the command line.
#vault_password_file = /path/to/vault_password_file
#system_warnings = True
#deprecation_warnings = True
Roles
ansible roles are the collections of variables, tasks, files, templates, and modules. each role has a directory tree in itself and locate in /roles directory.
ansible-galaxy -h
ansible-galaxy [delete|import|info|init|install|list|login|remove|search|setup] [--help] [options]
To Create a roles directory
cd /etc/ansible/rolesansible-galaxy init linuxtopic
ls linuxtopic
Hosts
This is Inventory file where we add entry of hosts matching.
vi /etc/hosts
# localhost
[localhost]
127.0.0.1
Note: here "[localhost]" hosts group name and "127.0.0.1” is hosts of group
To verify localhost connectivity using ping module
ansible localhost -m ping
Here “ansible” is command “localhost” is groupname ( we can also use separate ip of host like 127.0.0.1 ) “-m ping” -m module option and “ping” is module name
Video Tutorial
Thanks
End of this ansble installation part in CentOS 7, we need your support so i request you to please comment, share and like this post
www.linuxtopic.com