I ended up learning a little python3 so I could use it to generate the 
dictionary for me.

On Wednesday, September 23, 2015 at 1:48:50 PM UTC-5, Joanna Delaporte 
wrote:
>
> I am trying to build a hash of users from a csv file. I am stuck on this 
> last step, where the playbook just hangs:
>
>    - name: print user details into hash
>      lineinfile: 'dest=~csit-ansible/files/auto_students.yml
>                  line="{{ item }}"
>                  state=present'
>      with_items:
>       - "  username: {{ item[0] }}"
>       - "    firstname: {{ item[1] }}"
>       - "    lastname: {{ item[2] }}"
>       - "    studentid: {{ item[3] }}"
>       - "    dob: {{ item[4] }}"
>      with_nested:
>       - "{{ usernames.stdout_lines }}"
>       - "{{ firstnames.stdout_lines }}"
>       - "{{ lastnames.stdout_lines }}"
>       - "{{ studentids.stdout_lines }}"
>       - "{{ dobs.stdout_lines }}"
>
>
> Earlier in the playbook, I register the values like so:
>    - name: print all usernames to stdout
>      shell: awk -F ':' '{print $1}' ~csit-ansible/files/sortedu${date}.csv
>      register: usernames
>
>    - name: print all firstnames to stdout
>      shell: awk -F ':' '{print $2}' ~csit-ansible/files/sortedu${date}.csv
>      register: firstnames
>
>    - name: print all lastnames to stdout
>      shell: awk -F ':' '{print $3}' ~csit-ansible/files/sortedu${date}.csv
>      register: lastnames
>
>    - name: print all studentids to stdout
>      shell: awk -F ':' '{print $4}' ~csit-ansible/files/sortedu${date}.csv
>      register: studentids
>
>    - name: print all dobs to stdout
>      shell: awk -F ':' '{print $5}' ~csit-ansible/files/sortedu${date}.csv
>      register: dobs
>
>

-- 
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/7b74d4e7-ff57-47da-ab2f-1dca38b57870%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to