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
8 months agoCaitlin
8 months agoDell
9 months agoPaulina
9 months agoOzell
9 months agoKimbery
9 months agoPete
9 months agoKathrine
9 months agoDouglass
9 months agoDorian
9 months agoFabiola
9 months agoLisbeth
9 months agoMiesha
9 months agoMireya
10 months ago