Hi all!
So this has worked at one point but is no longer.
I'm trying to gather information on each of my rhel clients and write that information to one file on my answer server.
Here is my playbook:
---
- hosts: 'ALL_LINUX'
become: yes
become_method: sudo
vars_files:
- passwd.yml
- vars.yml
vars:
- RHEL_INV: "/home/chris.bidwell/rhel_inventory"
- VAR: "{{ hostvars[item].facter_virtual }}"
tasks:
- name: Workstation or Server?
shell: cat /etc/redhat-release | awk '{print $5}'
register: rh_type
tags: name
- name: Append to file
lineinfile:
dest: "{{ RHEL_INV }}"
line: "{{ ansible_default_ipv4.address }},{{ inventory_hostname }},{{ ansible_default_ipv4.macaddress }},{{ansible_distribution }}, {{ ansible_distribution_major_version }}, {{ rh_type.stdout }}"
insertafter: EOF
create: yes
delegate_to: localhost
- debug:
msg: "{{ ansible_default_ipv4.address }},{{ inventory_hostname }},{{ ansible_default_ipv4.macaddress }},{{ ansible_distribution }} {{ ansible_distribution_major_version }} {{ rh_type.stdout }}"
with_items: "{{ ansible_play_hosts }}"
Where my output is saying:
chris.bidwell@atsb-swpc-pup-svr-lx:roles$ ap rhel_inventory.yml -K --limit 'rhel8-base-lx'
BECOME password:
PLAY [ALL_LINUX] **********************************************************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************
ok: [rhel8-base-lx]
TASK [Make sure files exist] **********************************************************************************************************************************************************************************************
Sorry, try again.
failed: [rhel8-base-lx] (item=/home/chris.bidwell/rhel.svr) => {"ansible_loop_var": "item", "changed": false, "item": "/home/chris.bidwell/rhel.svr", "module_stderr": "[sudo via ansible, key=hkjseytyeuvgdyqbndymptpnvkghxbld] password:\nsudo: no password was provided\nsudo: 1 incorrect password attempt\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
Sorry, try again.
failed: [rhel8-base-lx] (item=/home/chris.bidwell/rhel.wkstn) => {"ansible_loop_var": "item", "changed": false, "item": "/home/chris.bidwell/rhel.wkstn", "module_stderr": "[sudo via ansible, key=vhtrrvzwdhssvgmxrexsvvhxvzyonmeu] password:\nsudo: no password was provided\nsudo: 1 incorrect password attempt\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
PLAY RECAP ****************************************************************************************************************************************************************************************************************
rhel8-base-lx : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0