Lab 2 - Solution¶
Mandatory¶
Create the Ansible Configuration¶
Connect to your
srv.<firstname>.labasansibleuserSwitch into your git repo
/home/ansible/trainingCreate a
ansible.cfgfile and configure- inventory path to
hosts - enable
become
- inventory path to
vi ansible.cfg
# file: ansible.cfg
[defaults]
inventory = hosts
[privilege_escalation]
become = True
Create a static inventory¶
Create a
hostsfileadd all your servers to the inventory file
- web1.<firstname>.lab
- web2.<firstname>.lab
- db.<firstname>.lab
vi hosts
# file: hosts
web1.firstname.lab
web2.firstname.lab
db.firstname.lab
Run some Ansible commands¶
- Run
uname -aon all servers - Run
whoamion all servers
ansible -a "uname -a" all
ansible -a "whoami" all
Commit your changes¶
- add all files to your git repo and commit it
git add hosts
git add ansible.cfg
git commit -m 'added inventory and ansible config'