CORRECT TEXT
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.
Solution:
Solution as:
Does this meet the goal?
Correct Answer:A
CORRECT TEXT
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.
Solution:
* 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'
Does this meet the goal?
Correct Answer:A
CORRECT TEXT
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'
Solution:
Solution as:
Does this meet the goal?
Correct Answer:A
CORRECT TEXT
=====================================================================
==============
control.realmX.example.com _ workstation.lab.example.com
node1.realmX.example.com _ servera.lab.example.com
node2.realmX.example.com _ serverb.lab.example.com
node3.realmX.example.com _ serverc.lab.example.com
node4.realmX.example.com _ serverd.lab.example.com
node5.realmX.example.com
- username:root, password:redhat
- username:admin, password:redhat
note1. don??t change ??root?? or ??admin?? password.
note2. no need to create ssh-keygen for access, its pre-defined
note3. SELinux is in enforcing mode and firewalld is disabled/stop on whole managed hosts.
=====================================================================
==============
Create a playbook called web.yml as follows:
* The playbook runs on managed nodes in the "dev" host group
* Create the directory /webdev with the following requirements:
--> membership in the apache group
--> regular permissions: owner=r+w+execute, group=r+w+execute, other=r+execute s.p=set group-id
* Symbolically link /var/www/html/webdev to /webdev
* Create the file /webdev/index.html with a single line of text that reads: ??Development??
--> it should be available on http://servera.lab.example.com/webdev/index.html
Solution:
Solution as:
# pwd
/home/admin/ansible/
# vim web.yml
---
- name: hosts: dev tasks:
- name: create group yum:
name: httpd state: latest
- name: create group group:
name: apache state: present
- name: creating directiory file:
path: /webdev state: directory mode: '2775' group: apache
- sefcontext:
target: '/webdev/index.html' setype: httpd_sys_content_t state: present
- name: Apply new SELinux file context to filesystem command: restorecon -irv
- name: creating symbolic link file:
src: /webdev
dest: /var/www/html/webdev state: link
force: yes
- name: creating file file:
path: /webdev/index.html sate: touch
- name: Adding content to index.html file copy:
dest: /webdev/index.html content: "Development"
- name: add service to the firewall firewalld:
service: http permanent: yes state: enabled immediate: yes
- name: active http service service:
name: httpd state: restarted enabled: yes wq
# ansible-playbook web.yml -–syntax-check
# ansible-playbook web.yml
Does this meet the goal?
Correct Answer:A
CORRECT TEXT
===================================================================================
control.realmX.example.com _ workstation.lab.example.com
node1.realmX.example.com _ servera.lab.example.com
node2.realmX.example.com _ serverb.lab.example.com
node3.realmX.example.com _ serverc.lab.example.com
node4.realmX.example.com _ serverd.lab.example.com
node5.realmX.example.com
- username:root, password:redhat
- username:admin, password:redhat
note1. don??t change ??root?? or ??admin?? password.
note2. no need to create ssh-keygen for access, its pre-defined
note3. SELinux is in enforcing mode and firewalld is disabled/stop on whole managed hosts.
===================================================================================
Create a role called apache in "/home/admin/ansible/roles" with the following requirements:
--> The httpd package is installed, enabled on boot, and started.
--> The firewall is enabled and running with a rule to allow access to the web server.
--> template file index.html.j2 is used to create the file /var/www/html/index.html with the output:
Welcome to HOSTNAME on IPADDRESS
--> Where HOSTNAME is the fqdn of the managed node and IPADDRESS is the IP-
Address of the managed node.
note: you have to create index.html.j2 file.
--> Create a playbook called httpd.yml that uses this role and the playbook runs on hosts in the webservers host group.
Solution:
Solution as:
----------
# pwd
/home/admin/ansible/roles/
# ansible-galaxy init apache
# vim apache/vars/main.yml
---
# vars file for apache http_pkg: httpd firewall_pkg: firewalld http_srv: httpd firewall_srv: firewalld rule: http
webpage: /var/www/html/index.html template: index.html.j2
wq!
# vim apache/tasks/package.yml
---
- name: Installing packages yum:
name:
- "{{http_pkg}}"
- "{{firewall_pkg}}" state: latest
wq!
# vim apache/tasks/service.yml
---
- name: start and enable http service service:
name: "{{http_srv}}" enabled: true
state: started
- name: start and enable firewall service service:
name: "{{firewall_srv}}" enabled: true
state: started wq!
# vim apache/tasks/firewall.yml
---
- name: Adding http service to firewall firewalld:
service: "{{rule}}" state: enabled permanent: true immediate: true wq!
# vim apache/tasks/webpage.yml
---
- name: creating template file template:
src: "{{template}}"
dest: "{{webpage}}" notify: restart_httpd
!wq
# vim apache/tasks/main.yml
# tasks file for apache
- import_tasks: package.yml
- import_tasks: service.yml
- import_tasks: firewall.yml
- import_tasks: webpage.yml wq!
# vim apache/templates/index.html.j2
Welcome to {{ ansible_facts.fqdn }} on {{ ansible_facts.default_ipv4.address }}
# vim apache/handlers/main.yml
---
# handlers file for apache
- name: restart_httpd
service: name: httpd
state: restarted wq!
# cd ..
# pwd
/home/admin/ansible/
# vim httpd.yml
---
- name: Including apache role hosts: webservers
pre_tasks:
- name: pretask message debug:
msg: 'Ensure webserver configuration' roles:
- ./roles/apache post_tasks:
- name: Check webserver uri:
url: "http://{{ ansible_facts.default_ipv4.address }}" return_content: yes
status_code: 200 wq!
# ansible-playbook httpd.yml –-syntax-check
# ansible-playbook httpd.yml
# curl http://serverx
Does this meet the goal?
Correct Answer:A