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
8 months agoIzetta
8 months agoCallie
9 months agoDaniel
9 months agoScot
9 months agoShelton
9 months agoJohnson
9 months agoLucille
9 months agoLarue
9 months agoCherry
9 months agoRosendo
10 months ago