Ansile Office Document
Ansile Office Document
configuration management.
So we are talking about IT orchestration where tasks are run in sequence in several different machines or
servers.
Ansible does this by connecting to multiple machines through SSH and runs the tasks which have been
configured into playbooks and uses a simple language called YAML (Yet Another Markup Language).
Copy the ssh key to the target machine and vice versa.
Control Machine ssh-copy-id <IP-Address-Host-Machine>
Target Machine ssh-copy-id <IP-Address-Control-Machine>
We are now able to log in without entering the password. After the check out of the ssh connectivity on both
the machines and be logged in as ansible user.
Control Machine: ssh ansible@<IP-Address-Host-Machine
Target Machine: ssh ansible@<IP-Address-Control-Machine>
Install and Set your default Python on RHEL 8 using the guide below.
Once you have Pip installed, use it to get Ansible installed in your RHEL 8 machine.
$ ansible --version
To test Ansible, you should have OpenSSH service running on the remote server.
Create Ansible inventory file, go to the location and create a file hosts by this path /etc/ansible/
$ vim hosts
Copy the IP address of your remote server(s) to manage and add to Ansible inventory file.
[web]
192.168.122.197
[db]
192.168.122.198
[staging]
192.168.122.199
192.168.122.200
192.168.122.201
Check is there any file called ansible.cfg : If that file is not there create a file in the /etc/ansible/
Get the content from the specified location and paste those details in the ansible.cfg file .
https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg
$ ssh-keygen
$ ssh-copy-id [email protected]
The -i option is used to provide path to inventory file. You should get the same output for hosts group name.
- hosts: all
tasks:
- name: Ansible copy file to remote server
copy:
src: ~/sample.txt
dest: /tmp
ansible-playbook /etc/ansible/copyplaybook.yml