Ansible
Ansible is a software tool from Redhat to make automation task between ansible master host and client.
Step by step configuration and simple playbook to run ansible
1. installation on master system
in redhat/centos: yum install ansible -y
2. configure the /etc/ansible/hosts file to input group and add the clients hosts inside the grup
[ansible_client] <--- group name
192.168.2.11 ansible_ssh_user= root ansible_ssh_pass= password <---- IP of client, username of client and client password
3. make a playbook that use a yml language
sample.yml <-- sample playbook file
----
- name: sample book
hosts: ansible_client <--- group name that we input in the ansible host file
remote_user: root
become: true
tasks:
- name: install httpd
yum:
name: httpd
state: latest
- name: run httpd
service:
name: httpd
state: started
- name: create content
copy:
content: "Congrats on installing ansible"
dest: /home/jacobs/helloansible.txt
4. check playbook syntax consistency
# ansible-playbook sample.yml --syntax-check
output: playbook: sample.yml
#
If everything is correct, syntax will be shown output of filename of the playbook.
5. execute the ansible playbook
# ansible-playbook sample.yml
At the end of the execution will have valuable information on how the tasks are executed for each client nodes.
information such as what tasks is executed or tasks change, what client node unreachable if any, and if any failed tasks.
Source: https://www.youtube.com/watch?v=EcnqJbxBcM0
Comments
Post a Comment