• LOGIN
  • No products in the cart.

Devops on AWS – Ansible Installation and Commands

Ansible Installation:=================


Controller Server:
———————
— yum install epel-release
— yum update
— yum install git python python-devel python-pip openssl ansible
— ansible –version

— Add ansible user  (Repeat the same step for remaining systems)
— useradd ansible
— passwd ansible

— visudo (Add the following line in root section)
— ansible ALL=(ALL)       NOPASSWD:  ALL

— Password less login:
— login with ansible user
— run the ‘ssh-keygen’
— run ssh-copy-id user@ip

— Configure Ansible:
— vi /etc/ansible/ansible.conf
— enable 
sudo user
inventory location

— No restarts Required

— Customizing Hosts file (/etc/ansible/hosts)
[local]
192.168.1.10

[centos]
192.168.1.10
192.168.1.11

[webservers]
192.168.1.11
—————————————————————————————–

Ansible Comands:============


1 – ansible all -m ping

list all the hosts configured in your environment
   — ansible all –list-hosts

2 – ansible all -a “ls -al /home/ansible”

3 – ansible all -s -a “cat /var/log/messages”

4 – ansible centos -m copy -a “src=test.txt dest=/tmp/test.txt “

5 – ansible centos -s -m yum -a “name=elinks state=latest”

6 – ansible centos -s -m user -a “user=test”

7 – ansible webservers -s -m yum -a “name=httpd state=latest”

8 – Managing Services:
   
   – ansible webservers -s -m service -a “name=httpd state=started”
   – ansible webservers -s -m service -a “name=httpd state=restarted”
   – ansible webservers -s -m service -a “name=httpd state=stopped”

9 – Gathering Facts:
   – ansible all -m setup | more

   To gather the Fact with format:
– ansible centos -m setup -a ‘filter=*ipv4*’

   Save the fact info in a dir(facts):
– ansible centos -m setup –tree /tmp/facts

   Important Facts:

— ansible centos -m setup -a ‘filter=ansible_architecture’
— ansible centos -m setup -a ‘filter=ansible_distribution’
— ansible centos -m setup -a ‘filter=ansible_distribution_version’
— ansible centos -m setup -a ‘filter=ansible_domain’
— ansible centos -m setup -a ‘filter=ansible_fqdn’
— ansible centos -m setup -a ‘filter=ansible_interfaces’
— ansible centos -m setup -a ‘filter=ansible_kernel’
— ansible centos -m setup -a ‘filter=ansible_memtotal_mb’
— ansible centos -m setup -a ‘filter=ansible_proc*’

=================================================

Executing Playbook:

– ansible-playbook file.yaml

February 22, 2021

Contact Address

Rise ‘n’ Shine Technologies:
Third Floor, Plot No1(Part), near KPHB Metro Station, KPHB Bagyanagar Colony, Kukatpally Main road, Balanagar Mandal, Rangareddy Dist-500072

Landmarks : Above VIOLET & PURPLE, near PJR statue, kphb metro station

  8686 98 8042
rnstech.fmw@gmail.com

Location

All rights reserved.
error: Alert: Content is protected !!
X