RedHat EX294 Exam - Topic 6 Question 54 Discussion
Create a playbook called hwreport.yml that produces an output file called /root/hwreport.txt on all managed nodes with the following information:--------------------------------------------------------------------------------------------------------> Inventory host name--> Total memory in MB--> BIOS version--> Size of disk device vda--> Size of disk device vdbEach line of the output file contains a single key-value pair.* Your playbook should:--> Download the file hwreport.empty from the URL http://classroom.example.com/hwreport.empty andsave it as /root/hwreport.txt--> Modify with the correct values.note: If a hardware item does not exist, the associated value should be set to NONE----------------------------------------------------------------------------------------------while practising you to create these file hear. But in exam have to download as perquestation.hwreport.txt file consists.my_sys=hostnamemy_BIOS=biosversionmy_MEMORY=memorymy_vda=vdasizemy_vdb=vdbsize
A) Explanation:
Solution as:
# pwd
/home/admin/ansible
# vim hwreport.yml
- name:
hosts: all
ignore_errors: yes
tasks:
- name: download file
get_url:
url: http://classroom.example.com/content/ex407/hwreport.empty
dest: /root/hwreport.txt
- name: vdasize
replace:
regexp: 'vdasize'
replace: '{{ ansible_facts.devices.vda.size }}'
dest: /root/hwreport.txt
register: op1
- debug:
var: op1
- name: none
replace:
regexp: 'vdasize'
replace: NONE
dest: /root/hwreport.txt
when:
op1.failed == true
- name: vdbsize
replace:
regexp: 'vdbsize'
replace: '{{ ansible_facts.devices.vdb.size }}'
dest: /root/hwreport.txt
register: op2
- debug:
var: op2
- name: none
replace:
regexp: 'vdbsize'
replace: NONE
dest: /root/hwreport.txt
when:
op2.failed == true
- name: sysinfo
replace:
regexp: '{{item.src}}'
replace: '{{item.dest}}'
dest: /root/hwreport.txt
loop:
- src: 'hostname'
dest: '{{ ansible_facts.fqdn }}'
- src: 'biosversion'
dest: '{{ ansible_facts.bios_version }}'
- src: 'memory'
dest: '{{ ansible_facts.memtotal_mb }}'
:wq!
# ansible-playbook hwreport.yml ---syntax-check
# ansible-playbook hwreport.yml
Royal
7 months agoAaron
8 months agoPortia
8 months agoVal
8 months agoRaymon
8 months agoJanine
9 months agoArlette
9 months agoHayley
9 months agoAshley
9 months agoVelda
9 months agoElinore
9 months agoJunita
9 months agoAnnmarie
9 months agoMadelyn
1 year agoSimona
1 year agoDesiree
1 year agoLashandra
1 year agoCharlene
1 year agoShenika
1 year agoGraciela
1 year agoMyra
1 year agoDoug
1 year agoEvan
1 year agoMelynda
1 year agoOliva
1 year agoQuentin
1 year agoOliva
1 year ago