0% found this document useful (0 votes)
91 views

Ansible Commands

This document provides instructions for using Ansible commands in Telugu to configure and manage Linux nodes. It describes setting up an Ansible server and two nodes, installing Ansible and required packages, configuring the Ansible hosts file and permissions to allow managing the nodes, generating SSH keys to access nodes without passwords, and using basic Ansible commands to install packages, manage services, create users and files across multiple nodes defined in an Ansible group. Playbooks are introduced as a way to automate common tasks, with examples shown for playbooks that install packages conditionally based on OS, handle restarting services, loop over a list of users to create, and encrypt sensitive data in a vault. Directories and files are created for organizing

Uploaded by

karim shaik
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

Ansible Commands

This document provides instructions for using Ansible commands in Telugu to configure and manage Linux nodes. It describes setting up an Ansible server and two nodes, installing Ansible and required packages, configuring the Ansible hosts file and permissions to allow managing the nodes, generating SSH keys to access nodes without passwords, and using basic Ansible commands to install packages, manage services, create users and files across multiple nodes defined in an Ansible group. Playbooks are introduced as a way to automate common tasks, with examples shown for playbooks that install packages conditionally based on OS, handle restarting services, loop over a list of users to create, and encrypt sensitive data in a vault. Directories and files are created for organizing

Uploaded by

karim shaik
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Ansible commands in telugu

Interdiction:-

Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type (linux-2 tiskovali)
Commands run cheyalisinave :-

Linux-machine = ansible server (1)


Linux-machine = node (1) , node (2)
Three linux-machine ni putty dwara login avthom 1.ansible server 2.node(1)
3.node(2)
 Sudo su = root user ke veltham
 Sudo amazon-linux-extras install ansible2 -y = ansible ni install cheyadaniki
command
 Yum install git python python-pip python-level openssl -y = manaki kavalisena
require Tagatu install cheystom
 vi /etc/ansible/hosts = i-press cheysi (ungrouped hosts velli mana nodes yoka
private ip’s ni paste cheyali) group name ‘demo’ teskunam
group lo ye group ayina add cheyachu develop,devops,aws
group ani company require tagatu groups ni teskuntom

 vi /etc/ansible/ansible.cfg = I press cheysi (some basic default values lo velli


‘inventory and sudo_user’ uncommited cheystom

 adduser ansible = user name create cheystom (employe ke evadaniki)


 passwd ansible = user name ke password vokati create cheystom
node(1) and node(2) ke user and password same iche create
cheystom
 su – ansible = ansible ke shift avthom three machines lo(server-node(1)-
node(2)) touch file1 file2 file3 create cheystom checking
purpose exit avthom ansible nudi
 visudo = I-press cheysi ansible ke kuda root permissions istom same
same node(1) and node(2) lo kuda cheyali
 su – ansible = ansible ke shift avthom and checking ke install cheystom
sudo yum install httpd -y (root privileges dorukutai ansible
kuda) tarvuta exit avthom
 vi /etc/ssh/sshd_config = i-press cheysi (v.v.v imp cmd) three changes cheystom
→ permitroot login-yes ni uncommited cheystom

→Passwordauthentication-yes ni kuda uncommited


cheystom
→Passwordauthentication-no ni commit cheystom
Same “three machines’ lo cheyali e three changes ni (ansible nudi logout ayi cheyali)
 service sshd restart = sshd mala restart cheystom e three changes apply avadaniki
three machines lo kuda (sshd restart) command evali
 su – ansible = ansible ke shift avthom (three machines lo)
 ssh 172.255.16.172 = node(1) yoka private ip ni paste cheystom and manom
create cheysina files ni chupistundi and alagey node(2)
access tiskotom “ssh private ip” istom

e process lo manom again and again nodes access cheyste password evalise
vastundi ani times login aythe ani times. so e process lo again password adakunda
cheystom
 ssh-keygen = ansible nudi cheystom key ni generate cheyadaniki cmd
ls -a = .ssh path show cheystundi
cd .ssh = path ke velthom (ls cheyste key ni chupistundi)
 ssh-copy-id [email protected] = ansible anadi user name (last time
password istom) and node2 same process
process anadi ansible server lo cheystom
 ansible --list-hosts = nodes yoka ip’s chupistundi
 ansible demo --list-hosts = group lo vuna ip’s ani chupistundi (nodes ve)
 ansible demo[0] --list-hosts = demo lo vuna first ip edo chupistundi
ansible demo(2) --list-hosts = wronging ani chupistundi andiku ante 3 node ledu
kabati
ansible dem0[0:1] -list-hosts = ani vunayo ani voka sare chudali ante first and last
evali
lab video- 2
 su – ansible = ansible lo shit avthom
 ansible demo -a “ls” = demo anadi group name (group lo vuna nodes and vatilo
create cheysina files ni chupistunndi)
ansible all -a “ls” = same content ni chupistunndi
 ansible all -a “touch kareem” = nodes lo file create avthundi node(1) and node(2)
lo ansible push mechanism antaru
 ansible demo -a “ls -al” = demo anadi group name (group lo vuna hidden files and
directorys ani show cheystundi)
 ansible demo -a “sudo yum install httpd -y” = httpd install avthundi nodes lo
 ansible demo -a “sudo yum remove httpd -y” = httpd remove avthundi (nodes lo
velli which httpd kodity show avadu)
ansible demo -ba “yum remove httpd -y” = sudo badulu manom (-ba) evachu
 ansible demo -b -m yum -a “pkg=httpd state=present” = httpd install cheystundi
(nodes lo velli which httpd kodity show cheystundi)
ansible demo -b -m service -a “name=httpd state=started” = service start cheyada
-niki command
ansible demo -b -m yum -a “pkg=httpd state=latest” = update cheyali anukunnte
e
command
ansible demo -b -m yum -a “pkg=httpd state=absent” = remove cheystundi httpd
 ansible demo -b -m user -a “name=kareem123” = demo group lo vuna nodes ke
user ni create cheydaniki command
cat /etc/passwd = nodes lo veli check cheyste user name kareem123 chupistuundi
 ansible demo[-1] -b -m copy -a “src=file1 dest=/tmp” = file1 anadi node(2) lo copy
avthundi.
ansible demo -b -m copy -a “src=filex dest=/tmp” = all nodes lo kuda copy avthun
-di.
 ansible demo -m setup = node yoka information chupistundi
ansible demo -m setup -a “filter=*ipv4*” = address details motom chupistundi
lab video-3
e process lo manom playbooks ela rayalo chustom and real scenarios lo use cheystom
(imp) concept
commands:-
vi target.yml = playbook create cheyadaniki e command
ansible-playbook target.yml = execute cheyadaniki command

first playbook sample (vi tagret.yml)


--- # my first testing yaml playbook
- hosts: demo
user: ansible
become: yes
connection: ssh
gather_facts: yes

second playbook sample (vi task.yml)


--- # my second playbook
- hosts: demo
user: ansible
become: yes
connection: ssh
tasks:
- name: install HTTPD on centos 7
action: yum name=httpd state=installed
third playbook sample (vi handler.ymml)
---
- hosts: demo
name: ansible
become: yes
connection: ssh
tasks:
- name: install httpd server on centos
action: yum name=httpd state=installed
notify: restart httpd
handlers:
- name: restart httpd
action: service name=httpd state=restarted

foruth playbook sample (vi loop.yml)


---
- hosts: demo
user: ansible
become: yes
connection: ssh
tasks:
- name: add list of users in my nodes
user: name='{{item}}' state=present
with_items:
- kareem_shaik
- srinu_nayak
- mahesh_babu

video lab-4
E process lo condition playbook ela create cheyalo chudom
 Vi condition.yml = file create cheystunam
First playbook sample (condition.yml)
---
- hosts: demo
name: ansible
become: yes
connection: ssh
tasks:
- name: install apache server for debian family
command: apt-get -y install apache2
when: ansible_os_family == “debian”
- name: install apache server for redhat family
command: yum -y install httpd
when: ansible_os_family == “RedHat”

→vault process (imp) encrypt and decrypt cheystom vault lo


ansible-vault create vault.yml = e sari vi editor tiskomu vault use cheystom
password :xxxxxxx
---
- hosts: demo
name: ansible
become: yes
connection: ssh
tasks:
- name: install apache server for debian family
command: apt-get -y install apache2
when: ansible_os_family == “debian”
name: install apache server for redhat family
command: yum -y install httpd
when: ansible_os_family == “redhat”

 ansible-vault edit vault.yml


 password = xxxxxx (e file open cheyali ante password telisena valy open cheysi
changes chaidaniki velavthundi
 ansible-vault rekey vault.yml = new password evali ante e command
vault password and new vault password type cheyali
 ansible-vault encrypt handlers.yml = file ni encrypt cheyali ante command
encrypt means vi-editor file open cheyste
encrypt chaisena tarvata open avadu
 ansible-vault decrypt handlers.yml = decrypt cheyali ante command

 sudo yum install tree -y = tree ni install cheystom


 mkdir -p playbook/roles/webserver/tasks = directory create cheystom
 cd playbook = playbook lo velthom
 touch roles/webservers/tasks/main.yml = main.yml file create cheystom
 vi roles/webserver/task/main.yml = main.yml lo e task rastom (httpd ni
nodes nudi remove cheystom)
- name: install apache on RedHat
yum: pkg=httpd state=latest
lab completed

(ansible documentation ani browse cheyste ansible samadiche theory motom


chadvachu.)

You might also like