0% found this document useful (0 votes)
43 views2 pages

Ansible Project Workflow

The document outlines the workflow for using Ansible to configure infrastructure. It describes establishing SSH keys to connect Ansible to dependent servers, creating an inventory file and git repo, installing Ansible on the main server, using commands to run modules like ping, yum, and gather facts on hosts, creating YAML playbooks to automate tasks, and using tags to target specific plays. Key steps include setting up SSH keys, creating an inventory and config file, installing Ansible, running modules to update packages and install software, and creating playbooks to automate configurations.

Uploaded by

Seenivas Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Ansible Project Workflow

The document outlines the workflow for using Ansible to configure infrastructure. It describes establishing SSH keys to connect Ansible to dependent servers, creating an inventory file and git repo, installing Ansible on the main server, using commands to run modules like ping, yum, and gather facts on hosts, creating YAML playbooks to automate tasks, and using tags to target specific plays. Key steps include setting up SSH keys, creating an inventory and config file, installing Ansible, running modules to update packages and install software, and creating playbooks to automate configurations.

Uploaded by

Seenivas Rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ANSIBLE PROJECT WORKFLOW

***check ufw for listening port for hhtpd/apache if webserver not running in host machine***

1) Have 1 server as the main Ansible server.


2) Establish ssh token using pub key connection to all the dependent servers to the main
Ansible server.
3) Establish ssh token using private key connection to all the dependent servers to the main
Ansible server. This is the one that will allow ansible to configure the infra in the dependent
servers.
4) Create a git repository for the main Ansible server.
5) Create an inventory file containing all the dependent ip addresses and push to the git repo.
6) Install Epel repository and then install Ansible
7) To connect ansible to all the dependent server(hosts) use :
a. Use command :
i. ansible all –key-file <path to key file> -i (inventory file)<inventory file> -
m(module) ping  ansible all –key-file ~/.ssh/ansible -I inventory -m ping
8) Add ansible config file inside the git repo directory:
a. Inside it include  [defaults] -> inventory, private_key_file
b. By doing this the command at 7a. will be shortened to  ansible all -m ping
9) Other commands include:
a. List of hosts  ansible all –list-hosts
b. Facts about hosts  ansible all -m gather_facts --limit <ip address>
10) Sudo yum update to other host with sudo privileges ansible all -m(module) <package (yum
for rhel)(apt for debian)> -a(argument)=true –become(sudo) –ask-become-pass(ask sudo
pw)  ansible all -m yum -a update_cache=true –become –ask-become-pass
[check docs.ansible.com for yum module or apt module arguments]
11) Installing other packages (vim-nox)  ansible all -m yum -a name=vim-nox --become –ask-
become-pass
12) To check logs of installation  in the hosts, cd /var/log/apt(Debian) or dnf.log(rhel)
13) Making sure all packages are up to date  ansible all -m yum -a “name=* state=latest” –
becom –ask-become-pass
14) Create a yaml file for your ansible playbook. Then you can run your playbook using ansible-
playbook –ask-become-pass <playbook name>
15) To remove a package, update the state in the yaml file  state: absent
16) If you configure tags in your playbook, you can use the tags to target specific plays 
ansible-playbook –tags < ”tag name1, tag name2” > --ask-become-pass
<playbookname>.yml
17) Regular expressions(regexp)?
18) Other modules:
a. Ansible.builtin.systemd
b. Lineinfile
c. Package/yum/apt
d. Unarchive
e. user
19) Register is used to make a variable for change (system)
INVENTORY FORMAT

[webserver]

54.243.18.36

[docker-server]

50.17.85.226

ANSIBLE CONFIGURATION FILE FORMAT

[defaults]

inventory = /home/ansibleadmin/ansible2.0/inventory

remote_user = ansibleadmin

private_key_file = /home/ansibleadmin/ansible

become = True

for reference = https://gist.github.com/alivx/2a4ca3e577ead4bd38d247c258e6513b

ANSIBLE PLAYBOOK FILE FORMAT

You might also like