Subject: [ansible-project] iterating over stdout_lines list


I want ansible to create a csv file for me.  For example I need the output
to be in this format:

Server, User, Approve, Remove
serverA, user1,X,
serverA, user2,X
ServerA, user3,X
ServerB, user1,X
ServerC, user1,X
ServerC, user2,X

In order to do this I need to iterate over a var I registered.  ie:
*
ok: [ansible-oel6] => {
    "other_users": {
        "changed": false,
        "cmd": "cat /etc/passwd | awk -F: \"\\$3 >= $(grep ^UID_MIN
/etc/login.defs | awk '{print $2}')\" | awk -F: '{print $1}' | sort | uniq
| grep -ve ^nfsnobody # Use this line for all users\n",
        "delta": "0:00:00.009172",
        "end": "2018-07-05 10:19:02.053099",
        "failed": false,
        "rc": 0,
        "start": "2018-07-05 10:19:02.043927",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "gomer\nbugsbunny\nelmer",
        "stdout_lines": [
            "gomer",
            "bugsbunny",
            "elmer"
        ]
    }
}

I have been reviewing what I can find online, but am running into dead ends
(lack of understanding on my part I am sure).

- name: Create Header for CSV file
  lineinfile:
    dest: "/tmp/prod_admin_users.csv"
    line: "Server,User,Approve,Remove,Reviewed by: YourNameHere"
    insertbefore: BOF
    create: yes
    state: present
  delegate_to: localhost
  run_once: true

- name: Create CSV file
  lineinfile:
    dest: "/tmp/prod_admin_users.csv"
    line: "{{ item.server }},{{ item.user }},X,,"
    insertafter: EOF
    state: present
  delegate_to: localhost
  with_items:
    - {server: "{{ host }}", user: "{{ other_users.stdout_lines[all] }}"}
<----- I know this is wrong, but I don't have a clue as to how to
accomplish this with ansible.

Hope this makes sense.  If not let me know and I will try to clarify.  If
it were in bash I would do the following:

for user in other_users; do
  echo "$host,$user,X," >> $TMP_CSV_FILE
done
--
To post to this group, send email to [EMAIL PROTECTED].