Using the Simulation Program, perform the following tasks:
Static Inventories Task:
1. Add a new group to your default ansible host file. call the group [ec2]
2. Add a new host to the new group you created.
3. Add a variable to a new host entry in the /etc/ansible/hosts file. Add the following. localhost
http_port=80 maxRequestsPerChild=808
4. Check to see if maxRequestsPerChild is pulled out with an ad-hoc command.
5. Create a local host file and put a target group and then a host into it. Then ping it with an ad-hoc
command.
A
A. Explanation:
1. Edit the /etc/ansible/hosts file. Add a group.
2. Edit the /etc/ansible/hosts file. Add a user under the group you created.
3. Edit the /etc/ansible/hosts file. Find a host. if we add a variable called maxRequestsPerChild to the
host it would look like this. host1 maxRequestsPerChild=808
4. ansible ec2 -m shell -a "echo {{ maxRequestsPerChild }}"
5. Edit a local file. It could be called anything. Lets call it myhosts. Inside the file it would have a host
like the following. [mygroup] myusername1.mylabserver.com
Using the Simulation Program, perform the following tasks:
Ad-Hoc Ansible Commands (Number Two) Task:
1. Use the ad-hoc command to make sure php is installed.
2. Use the ad-hoc command to make sure that php is installed and is the latest version.
3. Use the ad-hoc command to make sure that httpd is installed.
4. Use the ad-hoc command to remove httpd from the servers.
A
A. Explanation:
1. ansible all -b -m yum -a 'name=php state=present'
2. ansible all -b -m yum -a 'name=php state=latest'
3. ansible all -b -m yum -a 'name=httpd state=latest'
4. ansible all -b -m yum -a 'name=httpd state=absent'
Using the Simulation Program, perform the following tasks:
1. Use an ansible ad-hoc command, check the connectivity of your servers.
2. Use an ad-hoc ansible command, find the free space of your servers.
3. Use an ad-hoc ansible command, find out the memory usage of your servers.
4. Do an ls -l on the targets /var/log/messages file.
5. Tail the contents of the targets /var/log/messages file.
A
A. Explanation:
1. ansible all -m ping
2. ansible all -a "/bin/df -h"
3. ansible all -a "/usr/bin/free"
4. ansible all -a "ls -l /var/log/messages"
5. ansible local -b -a "tail /var/log/messages"
Create a role called sample-apache and store it in /home/bob/ansible/roles. The role should
satisfy the following requirements:
*In the role, install and enable httpd. Also enable the firewall to allow http. Also run the template
*index.html.j2 and make sure this runs Create a template index.html.j2 that displays "Welcome to
the server HOSTNAME"
In a play called apache.yml in /home/bob/ansible/ run the sample-apache role.
A
A. Explanation:
/home/sandy/ansible/apache.yml
/home/sandy/ansible/roles/sample-apache/tasks/main.yml/home/sandy/ansible/roles/sample-apache/templates/index.html.j2
In /home/sandy/ansible/roles/sample-apache/handlers/main.yml
Create a playbook /home/bob/ansible/timesync.yml that runs on hosts in the webservers host group
and does the following:
Uses the timesync RHEL system role.
Sets the ntp server to 0.uk.pool.ntp.org
Sets the timezone to UTC
A
A. Explanation:
Solution as:
Create a file called mysecret.yml on the control host using ansible vault in home/bob/ansible. Set
the password to 'notasafepass' and inside the file create a variable called dev_pass with the value of
devops. Save the file. Then go back in the file and change dev_pass value to devops123. Then change
the vault password of mysecret.yml to verysafepass
A
A. Explanation:
ansible-vault create lock.yml
New Vault Password: reallysafepw
Confirm: reallysafepw
Create a file in /home/sandy/ansible/ called report.yml. Using this playbook, get a file called
report.txt (make it look exactly as below). Copy this file over to all remote hosts at /root/report.txt.
Then edit the lines in the file to provide the real information of the hosts. If a disk does not exist then
write NONE.
A
A. Explanation:
Solution as:
Install and configure ansible
User sandy has been created on your control node with the appropriate permissions already, do not
change or modify ssh keys. Install the necessary packages to run ansible on the control node.
Configure ansible.cfg to be in folder /home/sandy/ansible/ansible.cfg and configure to access remote
machines via the sandy user. All roles should be in the path /home/sandy/ansible/roles. The
inventory path should be in /home/sandy/ansible/invenlory.
You will have access to 5 nodes.
node1.example.com
node2.example.com
node3.example.com
node4.exa
mple.com
node5.example.com
Configure these nodes to be in an inventory file where node I is a member of group dev. nodc2 is a
member of group test, node3 is a member of group proxy, nodc4 and node 5 are members of group
prod. Also, prod is a member of group webservers.
A
A. Explanation:
In/home/sandy/ansible/ansible.cfg
[defaults]
inventory=/home/sandy/ansible/inventory
roles_path=/home/sandy/ansible/roles
remote_user= sandy
host_key_checking=false
[privilegeescalation]
become=true
become_user=root
become_method=sudo
become_ask_pass=false
In /home/sandy/ansible/inventory
[dev]
node 1 .
example.com
[test]
node2.example.com
[proxy]
node3 .
example.com
[prod]
node4.example.com
node5 .
example.com
[webservers:children]
prod
Create a playbook /home/bob /ansible/motd.yml that runs on all inventory hosts and docs the
following: The playbook should replaee any existing content of/etc/motd in the following text. Use
ansible facts to display the FQDN of each host
On hosts in the dev host group the line should be "Welcome to Dev Server FQDN".
On hosts in the webserver host group the line should be "Welcome to Apache Server FQDN".
On hosts in the database host group the line should be "Welcome to MySQL Server FQDN".
A
A. Explanation:
/home/sandy/ansible/apache.yml
/home/sandy/ansible/roles/sample-apache/tasks/main.yml
Create a playbook that changes the default target on all nodes to multi-user tarqet. Do this in
playbook file called target.yml in /home/sandy/ansible
A
A. Explanation:
- name: change default target
hosts: all
tasks:
- name: change target
file:
src: /usr/lib/systemd/system/multi-user.target dest: /etc/systemd/system/default.target state: link
Create an empty encrypted file called myvault.yml in /home/sandy/ansible and set the password to
notsafepw. Rekey the password to iwejfj2221.
A
A. Explanation:
ansible-vault create myvault.yml
Create new password: notsafepw Confirm password: notsafepw ansible-vault rekey myvault.yml
Current password: notsafepw New password: iwejfj2221 Confirm password: iwejfj2221
Create a playbook called issue.yml in /home/sandy/ansible which changes the file /etc/issue on all
managed nodes: If host is a member of (lev then write "Development" If host is a member of test
then write "Test" If host is a member of prod then write "Production"
A
A. Explanation:
Solution as:
Create a playbook called regulartasks.yml which has the system that append the date to
/root/datefile every day at noon. Name is job 'datejob'
A
A. Explanation:
Solution as:
Create a playbook called timesvnc.yml in /home/sandy/ansible using rhel system role timesync. Set
the time to use currently configured nip with the server 0.uk.
pool.ntp.org
. Enable burst. Do this on
all hosts.
A
A. Explanation:
Solution as:
Create a playbook called webdev.yml in 'home/sandy/ansible. The playbook will create a directory
Avcbdev on dev host. The permission of the directory are 2755 and owner is webdev. Create a
symbolic link from /Webdev to /var/www/html/webdev. Serve a file from Avebdev7index.html
which displays the text "Development" Curl
http://node1.example.com/webdev/index.html
to test
A
A. Explanation:
Solution as: