Ansible Session Notes August 2025

DevOps

YOUR COSMETIC CARE STARTS HERE

Find the Best Cosmetic Hospitals

Trusted • Curated • Easy

Looking for the right place for a cosmetic procedure? Explore top cosmetic hospitals in one place and choose with confidence.

“Small steps lead to big changes — today is a perfect day to begin.”

Explore Cosmetic Hospitals Compare hospitals, services & options quickly.

✓ Shortlist providers • ✓ Review options • ✓ Take the next step with confidence

Survey
https://survey.zohopublic.com/zs/ZffAIC

Tutorials – https://www.devopsschool.com/blog/?s=ansible
Notes – https://www.bestdevops.com/ansible-session-notes-august-2025/
Slides – https://devopsschool.com/slides/ansible/index.html
Commands – https://www.devopsschool.com/commands/tools/ansible
Videos – https://www.devopsschool.com/blog/top-4-youtube-channel-for-free-videos-tutorials/
Certificates – https://www.devopsschool.com/certificates/
QA – https://www.devopsschool.com/forum/
Rajesh kumar – https://www.rajeshkumar.xyz/

Dynamic Inventory script

  • https://github.com/vshn/ansible-dynamic-inventory-ec2/blob/master/ec2.py
  • https://www.devopsschool.com/blog/ansible-dynamic-ansible-inventory-script-for-aws-ec2-public-ips/

Ansible Module

Ansible Module Sample Code to Work with API – Example 1

Ansible Module Sample Code to Work using github API – Example 2

Ansible Module Sample Code to Work using OS commands (curl) – Example 3

Ansible Module Sample Code to Work for user data – Example 4

Ansible Module Sample Code using Linux Bash script Example 5

Day 4


https://13.233.139.133
admin
Admin12345
==============================
Lab 
<blockquote class="wp-embedded-content" data-secret="tA7mfgYbyv"><a href="https://www.devopsschool.com/blog/ansible-tower-workflow-tutorials/">Ansible Tower Workflow tutorials</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Ansible Tower Workflow tutorials” — DevOpsSchool.com" src="https://www.devopsschool.com/blog/ansible-tower-workflow-tutorials/embed/#?secret=3IxcRHz9ij#?secret=tA7mfgYbyv" data-secret="tA7mfgYbyv" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
Code language: HTML, XML (xml)

Day 3

ACS - 13.127.104.130

ARS  - 13.201.58.68
ARS  - 3.109.143.247
ARS - 65.2.31.110Code language: CSS (css)

DAY 2 WRAP UPhttps://www.bestdevops.com/lets-understand-ansible-playbooks/

================================================================
Ansible Playbook
==============================
- Tasks
	-> one.yaml
	-> two.yaml
	-> three.yaml
- Vars
	-> hardcode in playbook
	-> vars file
- template
	- 1.j2
	- 2.j2
	- 3.j2

- handlers
	-> one.yaml
	-> two.yaml
	-> three.yaml

- files
	index.html
	deploy.sh
-- test file

- libs ---- custom module
=====================================================
WHOLE SETUP ------> GIT---> Other team members -> 
==============================================================================

Package Structure 
Why?

================================================================================
=== ROLE
	Directory structure
	Package structure
		for org
			tasks
			vars
			hand
			temp
			files
			lib
			test
===============================================================================

Step 1 - Develop your roles
Step 2 - test your role
Step 3 - Share a role at GitHub

Step 4 - Apply this role 	
		using inve
			UAT
			stg
			pre
			prod
=================================================================================
95% -- 5%

https://galaxy.ansible.com/ui/

ansible-galaxy init web


2058  git init
 2059  git config user.name "Rajesh Kumar"
 2060  git config user.email "devops@rajeshkumar.xyz"
 2061  git add --all
 2062  git commit -m"Adding Role - First version"
 2063  clear
 2064  ls
 2065  git remote add origin git@github.com:devopsschool-training-notes/ansible-role.git
 2066  git push origin master
 2067  git branch
 2068  git push origin master
 2069  clear
 2070  ls
 2071  vi .git/config
 2072  git push origin master

 2073  ansible-galaxy role install geerlingguy.java

LOCATION - ~/.ansible/roles/

 2074  ls /etc/ansible/
 2075  ls
 2076  cd ..
 2077  ls
 2078  vi site.yaml
 2079  ansible-playbook site.yaml
 2080  more site.yaml



more site.yaml
---
- name: Update web servers
  hosts: localhost

  roles:
    - web
    - geerlingguy.java


Assignment
- What the code you have done so far, create a role and publish to GitHub and share an url with us.
- use 1 role from ansible galaxy

PROJECT 
https://www.devopsschool.com/blog/ansible-role-project-1/Code language: JavaScript (javascript)

DAY 2

ansible web -i inventory -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem
ansible app -i inventory -m apt -a "name=tomcat state=present" -u ubuntu -b --key-file=node.pem
ansible db -i inventory -m apt -a "name=mysqld state=present" -u ubuntu -b --key-file=node.pem
ansible all -i inventory -m apt -a "update_cache=yes" -u ubuntu -b --key-file=node.pem
ansible web -i inventory -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem
ansible app -i inventory -m apt -a "name=tomcat state=present" -u ubuntu -b --key-file=node.pem


ACS - 13.201.50.27
ARS - 35.154.178.189
ARS - 13.233.85.156


What is playbook?
====================
 Collection of Play
 Yaml file

What is play?

Hosts: localhost OR all OR web
Tasks: 
        Task1 == module name & its param
        Task2 == module name & its param
        Task3 == module name & its param


ansible all -i inventory -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem
ansible all -i inventory -m copy -a "src=index.html dest=/var/www/html/index.html" -u ubuntu -b --key-file=node.pem
ansible all -i inventory -m service -a "name=apache2 state=started" -u ubuntu -b --key-file=node.pem

- name: Update web servers
  hosts: localhost

  tasks:
  - name: Install apache httpd (state=present is optional)
    ansible.builtin.apt:
      name: apache2
      state: present
  - name: Copy file with owner and permissions
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Start service httpd, if not started
    ansible.builtin.service:
      name: apache2
      state: started

ansible-playbook web.yaml

- name: Update web servers
  hosts: all

  tasks:
  - name: Install apache httpd (state=present is optional)
    ansible.builtin.apt:
      name: apache2
      state: present
  - name: Copy file with owner and permissions
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Start service httpd, if not started
    ansible.builtin.service:
      name: apache2
      state: started

ansible-playbook -i 13.201.50.27, web.yaml -u ubuntu -b --key-file=node.pem

- name: Update web servers
  hosts: web

  tasks:
  - name: Install apache httpd (state=present is optional)
    ansible.builtin.apt:
      name: apache2
      state: present
  - name: Copy file with owner and permissions
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Start service httpd, if not started
    ansible.builtin.service:
      name: apache2
      state: started

ansible-playbook -i inventory web.yaml -u ubuntu -b --key-file=node.pem


Refere
- https://www.devopsschool.com/tutorial/ansible/ansible-linux-playbooks.html
- https://www.devopsschool.com/blog/ansible-playbook-example/Code language: JavaScript (javascript)


How to run multiple playbook?
=======================

module 
- import_tasks

echo print prite cout == ansible debug


- hosts: localhost
  tasks:
    - ansible.builtin.debug:
        msg: task1

    - name: Include task list in play
      ansible.builtin.import_tasks:
        file: stuff.yaml -------------- this can contain multiple TASKS

    - ansible.builtin.debug:
        msg: task10



=====================
- name: Update web servers
  hosts: web

  tasks:
  - name: Install apache httpd (state=present is optional)
    ansible.builtin.apt:
      name: apache2
      state: present
  - name: Copy file with owner and permissions
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Start service httpd, if not started
    ansible.builtin.service:
      name: apache2
      state: started
==========stuff.yaml===============
 - name: Install apache httpd (state=present is optional)
    ansible.builtin.apt:
      name: apache2
      state: present
  - name: Copy file with owner and permissions
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Start service httpd, if not started
    ansible.builtin.service:
      name: apache2
      state: started
============================

- hosts: localhost
  tasks:
    - ansible.builtin.debug:
        msg: play1

- name: Include a play after another play
  ansible.builtin.import_playbook: otherplays.yaml



  - name: Update web servers
  hosts: localhost

  tasks:
  - name: Install apache httpd (state=present is optional)
    ansible.builtin.apt:
      name: apache2
      state: present

- name: Update web servers
  hosts: localhost

  tasks:
  - name: Copy file with owner and permissions
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html


- name: Update web servers
  h osts: localhost

  tasks:
  - name: Start service httpd, if not started
    ansible.builtin.service:
      name: apache2
      state: started

- import_playbook: one.yaml
- import_playbook: two.yaml
- import_playbook: threee.yaml

===========================
Large Code == not a good practice

Option 1- Create multiple playbook and call from master playbook
option 2 - Create a playbook with multiple seprate tasks file.

reference
- https://www.devopsschool.com/blog/ansible-include-scnario-with-list-of-plays-or-tasks/



Code language: JavaScript (javascript)

inventory Behavioural parameters


=======================================================
inventory Behavioural parameters

reference
- https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html#connecting-to-hosts-behavioral-inventory-parameters
- https://www.devopsschool.com/tutorial/ansible/inventory/index.html


root@ip-172-31-32-71:~/rajesh# more inventory 
[web]
13.201.50.27 ansible_user=ubuntu ansible_ssh_private_key_file=node.pem ansible_become=yes
3.111.218.155 ansible_port=24 ansible_user=raj ansible_ssh_private_key_file=raj.pem       
3.111.218.12 ansible_port=23 ansible_user=ram

[db]
13.235.113.18
3.111.218.190


[lb]
13.225.113.18
3.117.218.190

[cdn]
13.235.123.18
3.111.23.190



ansible-playbook -i inventory web.yaml

root@ip-172-31-32-71:~/rajesh# more inventory 

[web]
13.201.50.27 
3.111.218.155      
3.111.218.12  
3.111.218.155      
3.111.218.12  
3.111.218.155      
3.111.218.12  

[web:vars]
ansible_user=ubuntu 
ansible_ssh_private_key_file=node.pem 
ansible_become=yes

[db]
13.235.113.18
3.111.218.190


[lb]
13.225.113.18
3.117.218.190

[cdn]
13.235.123.18
3.111.23.190

======================
HOSTS vars
GROUPS varsCode language: PHP (php)

Ansible Variables in Playbook


13.201.50.27
=============================
PROGRAMMING
------------
vars
conditions
Looping
Functions
Reserved Keywords
===================
OOPS
==============
Compiler --> Interpreted --> DSL
=======================================
java		python		yaml
========================================
vars - 38
==================================
VARS in 
	Playbook
	Inventory

What are the way you can declare vars in Playbook?
https://www.devopsschool.com/blog/example-code-of-ansible-variable-with-playbook/

How set vars?

How to use vars?
============================
---
- name: Update web servers
  hosts: web
  vars:
    myname: "Rajeshkumar"
    age: "18"
    packagename: "apache2"
    servicename: "apache2"
  vars_files:
    - "vars.yaml"
  vars_prompt:
    - name: "version"
      prompt: "Which version Do you want to install?"
      private: no

  tasks:
  - name: Install Apache in ubuntu
    ansible.builtin.apt:
      name: "{{ packagename }}"
      state: latest
  - name: Copy index.html
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Starting a Apache Server
    ansible.builtin.service:
      name: "{{ servicename }}"
      state: started
  - name: Print return information from the previous task
    ansible.builtin.debug:
      var: myname
  - name: include default step variables
    include_vars: tasks_var.yaml
  - name: Print return information from the previous task
    ansible.builtin.debug:
      msg: "My Name is {{ myname }} and My age is {{ age }}"
  - name: Print return information from the previous task
    ansible.builtin.debug:
      var: version
  - name: Ansible register variable basic example
    shell: "find *.txt"
    args:
      chdir: "/root/rajesh/dir"
    register: find_output
  - debug:
      var: find_output
  - debug:
      var: find_output.stdout_lines
  - debug:
      var: find_output.stdout_lines[0]

Reference
<blockquote class="wp-embedded-content" data-secret="1VoSwor1F9"><a href="https://www.devopsschool.com/blog/example-code-of-ansible-variable-with-playbook/">Ansible Tutorials: Ansible Variables in Playbook</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Ansible Tutorials: Ansible Variables in Playbook” — DevOpsSchool.com" src="https://www.devopsschool.com/blog/example-code-of-ansible-variable-with-playbook/embed/#?secret=v7VVwURkbN#?secret=1VoSwor1F9" data-secret="1VoSwor1F9" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>


Assignment
---------------------------------------------------
If I set the same vars at 
		vars
		varsfile
		task vars
Which would have highest precedence.

Code language: HTML, XML (xml)

Ansible Template

===========================================================
First RULE - file must be .j2
Second Rule - use template module

Reference
https://www.devopsschool.com/blog/ansible-template-and-handlers-explained-with-example/



---
- name: Update web servers
  hosts: web
  vars:
    myname: "Rajesh Kumar"
    port: 81

  tasks:
  - name: Install Apache in Ubuntu
    ansible.builtin.apt:
      name: apache2
      state: latest
  - name: Copy index.html
    ansible.builtin.copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: stopped a Apache Server
    ansible.builtin.service:
      name: apache2
      state: stopped
  - name: Template for httpd.conf
    template:
      src: ports.conf.j2
      dest: /etc/apache2/ports.conf
  - name: Starting a Apache Server
    ansible.builtin.service:
      name: apache2
      state: started

Reference
<blockquote class="wp-embedded-content" data-secret="SYQZOJyp1R"><a href="https://www.devopsschool.com/blog/ansible-template-and-handlers-explained-with-example/">Ansible Template and Handlers explained with Example</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Ansible Template and Handlers explained with Example” — DevOpsSchool.com" src="https://www.devopsschool.com/blog/ansible-template-and-handlers-explained-with-example/embed/#?secret=hBqYhn6rnG#?secret=SYQZOJyp1R" data-secret="SYQZOJyp1R" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
Code language: HTML, XML (xml)

Day 1

Fill the form for lab

Google Form

Lab

USERNAMEubuntu
keyhttps://github.com/devopsschool-training-notes/Master-in-Devops-Engineering-MDE/tree/master/key
Name ajj-devops
Praveen Mootha  “13.233.106.85”,
Badelal Yadav  “43.205.233.149”,
Ajay kumar yadav  “65.0.130.40”,
Arun Sambandan  “13.126.244.155”,
Srikanth Aratla  “13.201.59.47”,
Karthick Chandrasekaran  “3.109.214.153”,
Rama Yerramsetti  “35.154.114.184”,
Insha Begum Shaikh  “13.127.132.177”,
Sumit Upadhyay  “13.127.196.59”,
Muruganandham S  “13.232.113.31”,
Khushi Srivastava  “13.201.135.191”,
Uttam Kumar  “65.2.168.169”,
Prashanth Athimala  “13.201.62.24”,
Rohit Pahwa  “13.233.8.62”,
Abdul Rahim Khan  “13.201.56.196”,
Kiran kumar M  “13.233.95.49”,
Gopinath Selvanathan  “3.109.62.126”,
Iyyappan Santhanam  “13.233.141.9”,
Hem Chander  “35.154.6.40”,
  “3.111.218.155”,
  “13.235.113.142”,
  “43.205.177.34”,
  “43.205.125.200”,

How to use Putty

CLICK HERE

Notes

What is Ansible?
=================================
	Config mgmt tool
	Server(S) Config mgmt tool
	From Redhat
	Written in python
	Release 
		ansible - Community - CMD - FREE & Opensource
		ansible Tower     - GUI - PAID  - Formal release and Support
		ansible AWX	  - GUI - FREE	-> Latest Code of Tower which is tested and no support.
	Version
	    3.x

	tool
	- save time
		1 Dep --- 10 mins
		SSH --- 100 Dep --->100X10=  1000mins
		1 Dep -- 10 mins
		100 ----> 10 mins
			---- 4 5 mins
	- save cost
		FREE + Done through coding - automated
 
	- imp eff in work
		1000s == Consistent change

	- IDEOMPOTENT
		CODE (Desire) - 10 things -----1 st -----> 10 things would be done... - 10 mins
				1 changes  ----2nd------= 1 things - 1mins


	mgmt 
		Software
	file
	directory
	user
	group
	service
	apt
	yum
	cmd
	script
	bash
	package
		Hardware
	Hypervisor
		People
	user
	group
		Process
	OS Config

		100s Server(S)


	What Config in the server we manage using Ansible?
	==============================================

	file
	directory
	user
	group
	service
	apt
	yum
	cmd
	script
	bash
	package
	

	OTHERS 
		---> Chef - puppet - salt - cfengine == Ansible
		UDeploy - UBuild - Digital.ai - Octopus Deploy
	

	How it works? Aka Architecture
=====================================================================


HUMAN ----> ACS ---> ARS
HUMAN ----> TOWER ---> ARS

ACS = Ansible Control Server -> Ansible Remote Server
===========================================================================

	ACS				ARS
	Linux64				Any
	Python3				Linux - Python3
					Windows - DOTNET, PS3.0
	------------------------Agent Less--------------------------------

	Linux		SSH		Linux 		22
	Linux		WINRM 		WINDOWS		5585/86 = 	HTTPS

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

	Ansible 

		Executables ---- /usr/bin/ansi*
				ansible
					ssh - 22
				ansible-playbook
				ansible-doc

		Modules - A python code in ACS --> RUN in ARS -> Make Changes in ARS
					copy.py param1 param2
						cp src dest
					package.py
						install git
					service.py
						start apache2
		copy /tmp/file1.txt /opt/fil2.txt
		=================================
               		 ACS             ARS


		https://docs.ansible.com/ansible/2.9/modules/modules_by_category.html

		Plugins - A python code --> RUN in ACS - Feature of Ansible
			connection
			auth
			yamlparsing
		https://docs.ansible.com/ansible/latest/plugins/plugins.html

		Configfile
			/etc/ansible/ansible.cfg
		<blockquote class="wp-embedded-content" data-secret="z0mxSjWB8o"><a href="https://www.devopsschool.com/blog/ansible-tutorials-example-of-ansible-cfg/">Ansible Tutorials: Example of ansible.cfg</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Ansible Tutorials: Example of ansible.cfg” — DevOpsSchool.com" src="https://www.devopsschool.com/blog/ansible-tutorials-example-of-ansible-cfg/embed/#?secret=tGAw5JrZZ9#?secret=z0mxSjWB8o" data-secret="z0mxSjWB8o" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
==========================================================================================

What --> Why --> How --> 
=======================================================================

RUN 1 commands - 1 server
			CMD
			SCRIPT

Ansible Training Flow
<blockquote class="wp-embedded-content" data-secret="m64IrOKh95"><a href="https://www.devopsschool.com/blog/ansible-training-flow/">Ansible Training Flow</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Ansible Training Flow” — DevOpsSchool.com" src="https://www.devopsschool.com/blog/ansible-training-flow/embed/#?secret=SxjTTjqqEw#?secret=m64IrOKh95" data-secret="m64IrOKh95" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
=====================================================================
Components of Ansible ACS
=======================================
Ansible - Need to be installed
<blockquote class="wp-embedded-content" data-secret="qOrcuV9NVW"><a href="https://www.devopsschool.com/blog/ansible-installation-and-configuration-guide/">Ansible Installation and Configuration Guide</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="“Ansible Installation and Configuration Guide” — DevOpsSchool.com" src="https://www.devopsschool.com/blog/ansible-installation-and-configuration-guide/embed/#?secret=HsQg9FzvWB#?secret=qOrcuV9NVW" data-secret="qOrcuV9NVW" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>

Playbook - 
		a Yaml file
		Contains
			TASKS, 
			Vars, 
			Handles
			Templates

Inventory or Hosts
		- List of IPADD/Hostname of ARS
			- CMD
			- FILE
			- Script
			- Directory

Ansible config

=========================================================
PROJECT - Automated a Setting up a Webserver
	
	BASH
	Ansible
	Chef	
	Puppet
=========================================================
Psucode
------------------------
Step 1 - Install Apache2 
Step 2 - Copy package index.html
Step 3 - Start a Apache2
 
Step 1 - Install Apache2  - Module ???? apt
Step 2 - Copy package index.html - Module ?? copy
Step 3 - Start a Apache2 - Module - service

				state
	file			C E D
	directory		C E D
	user			A E D
	group			A E D
	service			S S R E D 
	apt			i R
	yum			i R
	cmd			cmd param1 param2
	script			ps | bash
	bash			cmd
	package			install remove

old pattern
==============================================
apache module name for installing package in ansible
apache module name for copy file in ansible
apache module name for start service in ansible
============================================


ansible localhost -m apt -a "name=apache2 state=present"
ansible localhost -m copy -a "src=index.html dest=/var/www/html/index.html"
ansible localhost -m service -a "name=apache2 state=started"


   36  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html"
   37  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -v
   38  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vv
   39  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vvv
   40  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vvvv
   41  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vvvvv



  1  clear
    2  ls
    3  sudo apt update
    4  sudo apt install software-properties-common
    5  sudo add-apt-repository --yes --update ppa:ansible/ansible
    6  sudo apt install ansible
    7  clear
    8  ansible
    9  clear
   10  ansible --version
   11  ls /usr/bin/anse*
   12  ls /usr/bin/ansi*
   13  cd /usr/lib/python3/dist-packages/ansible
   14  ls
   15  cd modules
   16  ls
   17  cd ..
   18  ls
   19  cd plugins/
   20  ls
   21  clear
   22  ls
   23  cd connection
   24  ;s
   25  ls
   26  more ansible.cfg
   27  clear
   28  ls
   29  ansible
   30  clear
   31  which apache2
   32  ansible localhost -m apt -a "name=apache2 state=present"
   33  clear
   34  ansible localhost -m apt -a "name=apache2 state=present"
   35  clear
   36  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html"
   37  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -v
   38  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vv
   39  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vvv
   40  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vvvv
   41  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html" -vvvvv
   42  history
   43  clear
   44  ls
   45  cd
   46  ls
   47  vi index.html
   48  ansible localhost -m copy -a "src=index.html dest=/var/www/local/index.html"
   49  clear
   50  ls
   51  ansible localhost -m copy -a "src=index.html dest=/var/www/html/index.html"
   52  ansible localhost -m service -a "name=apache2 state=started"
   53  clear
   54  ansible localhost -m service -a "name=apache2 state=started"
=======================================================================

systemd
Code language: HTML, XML (xml)

Assignment

Ansible Inventory

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

Inventory or Hosts
		- List of IPADD/Hostname of ARS
			- CMD
			- FILE - INI FORMAT
			- Script
			- Directory
10.4.5.6 - no list
10.4.5.6, - its list
10.4.5.6,12.3.45.6 - no list
10.4.5.6,12.3.45.6, - its a list




13.235.113.142
3.111.218.155


ansible all -i 13.235.113.142, -m apt -a "name=apache2 state=present"
ansible all -i 13.235.113.142, -m copy -a "src=index.html dest=/var/www/html/index.html"
ansible all -i 13.235.113.142, -m service -a "name=apache2 state=started"

ansible all -i 13.235.113.142,3.111.218.155, -m apt -a "name=apache2 state=present"
ansible all -i 13.235.113.142,3.111.218.155, -m copy -a "src=index.html dest=/var/www/html/index.html"
ansible all -i 13.235.113.142,3.111.218.155, -m service -a "name=apache2 state=started"

Host Group - Inventory Group
==============================
all
ungroup


AUTHENTICATION and AUTHORIZATION options in Ansible

			LINUX			LINUX

AUTHENTICATION		username/Pas		username/key
			-u -k			-u --key-file

AUTHORIZATION		sudo			-b
						sudo with Password	-b -K
						sudo without Password	-b
	
						sudo with diff user and password -b --become-user -K 
						sudo with diff user and key -b --become-user --key-file



ansible all -i 13.235.113.142,3.111.218.155, -m apt -a "update_cache=yes" -u ubuntu -b --key-file=node.pem
ansible all -i 13.235.113.142,3.111.218.155, -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem
ansible all -i 13.235.113.142,3.111.218.155, -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem
ansible all -i 13.235.113.142,3.111.218.155, -m copy -a "src=index.html dest=/var/www/html/index.html" -u ubuntu -b --key-file=node.pem
ansible all -i 13.235.113.142,3.111.218.155, -m service -a "name=apache2 state=started" -u ubuntu -b --key-file=node.pem



ansible all -i 13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155,13.235.113.142,3.111.218.155, -m apt -a "update_cache=yes" -u ubuntu -b --key-file=node.pem


inventory

13.235.113.142
3.111.218.155




ansible all -i inventory -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem
ansible all -i inventory -m copy -a "src=index.html dest=/var/www/html/index.html" -u ubuntu -b --key-file=node.pem
ansible all -i inventory -m service -a "name=apache2 state=started" -u ubuntu -b --key-file=node.pem



ansible all -i inventory -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem

ansible all -i inventory -m apt -a "name=tomcat state=present" -u ubuntu -b --key-file=node.pem

ansible all -i inventory -m apt -a "name=mysqld state=present" -u ubuntu -b --key-file=node.pem


inventory

[web]
13.235.113.142
3.111.218.155

[app]
13.235.113.14
3.111.218.12

[db]
13.235.113.18
3.111.218.190

ansible web -i inventory -m apt -a "name=apache2 state=present" -u ubuntu -b --key-file=node.pem

ansible app -i inventory -m apt -a "name=tomcat state=present" -u ubuntu -b --key-file=node.pem

ansible db -i inventory -m apt -a "name=mysqld state=present" -u ubuntu -b --key-file=node.pem

ansible all -i inventory -m apt -a "update_cache=yes" -u ubuntu -b --key-file=node.pem


inventory

[web]
13.235.113.142
3.111.218.155

[app]
13.235.113.14
3.111.218.12

[db]
13.235.113.18
3.111.218.190


[lb]
13.225.113.18
3.117.218.190

[cdn]
13.235.123.18
3.111.23.190


ansible web,app -i inventory -m apt -a "update_cache=yes" -u ubuntu -b --key-file=node.pem


inventory

[web]
13.235.113.142
3.111.218.155

[app]
13.235.113.14
3.111.218.12

[db]
13.235.113.18
3.111.218.190
app
web


[lb]
13.225.113.18
3.117.218.190

[cdn]
13.235.123.18
3.111.23.190

[middleware:children]
web
db


ansible middleware -i inventory -m apt -a "update_cache=yes" -u ubuntu -b --key-file=node.pem
Code language: PHP (php)

Day 1 Feedback

CLICK HERE

Assignment 2

CLICK HERE

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x