I have the following in my playbook, and when it writes the contents it 
writes in this format:

ServerA:
 sudoers

ServerB:
 sudoers

ServerA:
 other_users

ServerB:
 other_users.

I would like the following format if possible:

ServerA
 sudoers

ServerA
 other_users

ServerB
 sudoers

ServerB
 other_users

- name: Write users
  lineinfile:
    dest: "/tmp/users.txt"
    line: "HOST: {{ansible_nodename}}\n{{item}}\n\n"
    insertafter: EOF
    create: yes
    state: present
  delegate_to: localhost
  with_items:
    - "{{sudoers.stdout_lines|to_nice_json}}"
    - "{{other_users.stdout_lines|to_nice_json}}"
  notify:
    - email
    - cleanup

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/10adea7f-7cee-4721-9073-f531a96890ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to