RedHat EX294 Exam - Topic 15 Question 16 Discussion
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+executes.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''
A) Explanation:
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
Hyman
10 months agoCaitlin
10 months agoDell
11 months agoPaulina
11 months agoOzell
11 months agoKimbery
11 months agoPete
11 months agoKathrine
11 months agoDouglass
11 months agoDorian
11 months agoFabiola
11 months agoLisbeth
11 months agoMiesha
11 months agoMireya
12 months ago