Загрузка...

Run Your First Ansible Playbook in Simple Steps : Fully tested and Tried

#devopsengineer
#devopsmadeeasy
#ansible

How to Run Successfully your Ansible Playbook : Fully Tested
1) We need 3 servers created in same region under same vpc - 3 Linux server of any instance type
2) One will be master node - where we will install python and ansible
3) On master node first install python

sudo yum install -y python3
python3 --version

4) Then after successfully installing python install ansible

sudo yum install -y ansible
ansible --version

5) After successfully installing ansible:

vi /etc/ansible/hosts
If hosts file is not present then
sudo touch hosts
sudo chmod 777 hosts
vi /etc/ansible/hosts
Click i for insert
give private ip address of other Linux server and user and key to connect to servers

Syntax:
privateip ansible_user=ec2-user ansible_ssh_private_key_file=~/DevOps.pem
privateip2 ansible_user=ec2-user ansible_ssh_private_key_file=~/DevOps.pem
Escape , then :wq

6) Check if your directory is user home directory else click cd ~

7) Create ansibleDemo.yaml file using : touch ansibleDemo.yaml

vi ansibleDemo.yaml , Press i for insert


- name: Install Git on Linux server
hosts: all
become: true

tasks:
- name: Ensure Git is installed
package:
name: git
state: present
Press Esc , :wq

8) Also we have to keep DevOps.pem file in user home directory using which ansible to connect two other 2 servers and this pem file is other two servers file which we got while creating these servers, so we have to create this DevOps.pem file using : touch DevOps.pem

then vi DevOps.pem , Press i , Paste key from local machine to this file, Press escape , :wq

9) After that run : ansible all -m ping (This command is to check that whether our master node is able to connect to connect to other 2 Linux servers, if error is there then try : chmod 400 DevOps.pem)

10) Once ansible all -m ping ran successfully , run : ansible-playbook ansibleDemo.yaml
Congratulations you ran your first ansible playbook File

Видео Run Your First Ansible Playbook in Simple Steps : Fully tested and Tried канала Sakshi Gautam
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки