Assumptions

For use with eg CentOS or Ubuntu.

Assumes you have a file /etc/ansible/hosts with groups and members already configured.

A properly formatted .yml-file can be found at the end of the article.

 

---
- hosts: cyndane2 ceres2
gather_facts: yes
become: false
tasks:
- name: Gather Version
debug:
msg: "The server Operating system is {{ ansible_distribution }} {{ ansible_distribution_version }}"
- name: Write Version
local_action: shell echo "{{ inventory_hostname }} is running {{ ansible_distribution_version }}" >> /home/sorin/hostname-os-version-output.txt
 ...

 

 

Sources

https://serverfault.com/questions/804387/how-to-send-ansible-debug-messages-to-another-file

https://serverfault.com/questions/901433/how-can-i-log-inventory-hostname-to-a-file-on-the-remote-using-a-playbook

 

 

 

 

 

 

 

Stop Spam Harvesters, Join Project Honey Pot

 

Get a free SSL certificate!

 

The leading nonprofit defending digital privacy, free speech, and innovation.

 

The Linux Foundation provides a neutral, trusted hub for developers and organizations to code, manage, and scale open technology projects and ecosystems.

 

Kubuntu is an operating system built by a worldwide community of developers, testers, supporters and translators.

 

 43ef5c89 CanonicalUbuntudarktext