RedHat EX294 Exam - Topic 17 Question 12 Discussion
Modify file content.------------------------Create a playbook called /home/admin/ansible/modify.yml as follows:* The playbook runs on all inventory hosts* The playbook replaces the contents of /etc/issue with a single line of text asfollows:--> On hosts in the dev host group, the line reads: ''Development''--> On hosts in the test host group, the line reads: ''Test''--> On hosts in the prod host group, the line reads: ''Production''
A) Explanation:
Solution as:
# pwd
/home/admin/ansible
# vim modify.yml
---
- name:
hosts: all
tasks:
- name:
copy:
content: 'Development'
dest: /etc/issue
when: inventory_hostname in groups['dev']
- name:
copy:
content: 'Test'
dest: /etc/issue
when: inventory_hostname in groups['test']
- name:
copy:
content: 'Production'
dest: /etc/issue
when: inventory_hostname in groups['prod']
:wq
# ansible-playbook modify.yml ---syntax-check
# ansible-playbook modify.yml
France
10 months agoIzetta
10 months agoCallie
11 months agoDaniel
11 months agoScot
11 months agoShelton
11 months agoJohnson
11 months agoLucille
11 months agoLarue
11 months agoCherry
11 months agoRosendo
12 months ago