1

Need to save std.out lines to a file in delegated host using below playbook. I am able to save the data, but the saved data is in json format. I need this data as list format as like command output.

- name: Host Collection
  hosts:  rcht01
  tasks:
    - name: Host coll
      shell:    mysql -ulnx -plnx  -D inventory -se "select Host_Name from servers where OS= 'Linux' AND Server_Status = 'Live' AND Server_loc = 'Richardson' "| tr 'A-Z' 'a-z'
      register: all_hosts_list

    - name: Saving data to local file
      copy:
        content:  "{{  all_hosts_list.stdout_lines  }}"
        dest: /tmp/host_coll
      delegate_to: rchabs01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.