Execution
Date 19 Mar 2024 09:40:44 +0000
Duration 00:00:10.47
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.4
ara 1.7.1 / 1.7.2.dev2
Python 3.10.10
Summary
27 Hosts
2 Tasks
52 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/a.yaml

---
- name: Playbook to save the hostname
  hosts: all
  vars:
    folder: /home/ssh-gateway/ansible/playbook_output
  gather_facts: false
  tasks:
    - name: Get the hostnbame
      command:
        hostname
      register: hname
    - name: Save it to a file
      ansible.builtin.lineinfile:
        path: "{{ folder }}/hnames.txt"
        mode: '0640'
        create: true
        line: ' {{ hname.stdout }}'
      delegate_to: 127.0.0.1