-> Set hostname
# hostnamectl set-hostname ansible_host
-> Add remote hosts into /etc/hosts file
# vi /etc/hosts
10.10.10.2 remote_host_2
10.10.10.3 remote_host_3
-> Generate ssh key without passphase
# ssh-keygen
-> Install ssh key into remote servers
# ssh-copy-id remote_host_2
# ssh-copy-id remote_host_3
-> Install ansible rpm packages
# yum install ansible
-> Add remote hosts as nodes into /etc/ansible/hosts file
# vi /etc/ansible/hosts
[remote_hosts]
remote_host_2
remote_host_3
-> Prepare an ansible playbook in /etc/ansible/
# vi my_very_first_playbook.yml
# example playbook
- name: Run the role for me
hosts: remote_hosts
roles:
- example-role
-> Prepare a role for the playbook in /etc/ansible/roles/example-role/
# vi main.yml
- name: checking Command Scheduler service
service:
name=crond.service
state=started
-> Run the playbook in /etc/ansible/
# ansible-playbook my_very_first_playbook.yml
or
# ansible-playbook -i hosts my_very_first_playbook.yml
(i -> inventory, its default location is /etc/ansible/hosts)
-> To check the ansible logs
# tail -f /var/log/ansible.log