YAML
- hosts: localhost
tasks:
- name: checking
shell: |
a=$(hostnamectl | grep Chassis)
a=$a{a// /}
b=$(hostnamectl | grep "Icon name")
b=$b{b// /}
echo "<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h2>Ansible Generating report</h2>
<p>Author - Anirban.</p>
<table style="width:20%">
<tr>
<th>Name</th>
<th>Information</th>
</tr>
<tr>
<td>Chassis</td>
<td>$a</td>
</tr>
<tr>
<td>Icon name</td>
<td>$b</td>
</tr>
</table>
</body>
</html>"
register: output
- name: message
debug:
msg: "{{output.stdout}}"
- name: Generating the report
local_action: "copy content='{{output.stdout}}' dest=/home/anirban/Desktop/report.html"
Ansible Syntax check
ansible-playbook systemreport.yml --syntax-check
Ansible Playbook
ansible-playbook systemreport.yml
The outPut of the Playbook