# ansible coding help

**URL:** <https://forum.ansible.com/t/ansible-coding-help/36374>\
**Category:** Ansible Developer\
**Created:** [February 27, 2022, 8:12pm UTC](https://forum.ansible.com/t/ansible-coding-help/36374 "2022-02-27T20:12:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nancy\_Desai](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@Nancy\_Desai](https://forum.ansible.com/u/Nancy_Desai)\
**Post date:** [February 27, 2022, 8:12pm UTC](https://forum.ansible.com/t/ansible-coding-help/36374/1 "2022-02-27T20:12:16Z")

</div>

Hello. I’m in an ansible coding class and I need some assistance if you can provide it. I’ve been given an assignment to create an ansible playbook on CentOS which will do the following: check users in a csv file to see if they have user accounts on the computer. If they do, when I run the playbook, I would get a success message. If they do not exist, I would get a failure message.

So my CSV file is named ckusers.csv and is made up for 5 usernames and only usernames. Each username is on a different line of the csv file.

There is a python script that was included in the assignment called ckeck\_user.py that looks like this:

 ![6.PNG](https://us1.discourse-cdn.com/ansible/original/2X/1/10f71ed96b57f38385f699715dbb6b84768696b9.png)

So far, I have this in my playbook knowing that I’m at least 70% wrong. The playbook is called ckusers.yml.

 ![playbook.PNG](https://us1.discourse-cdn.com/ansible/original/2X/7/7deb520f955a937350d5761c46a0324a0cecb42c.png)

---

<div class="post-metadata">

**Author:** ![Jan\_Bergner](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@Jan\_Bergner](https://forum.ansible.com/u/Jan_Bergner)\
**Post date:** [March 5, 2022, 9:00pm UTC](https://forum.ansible.com/t/ansible-coding-help/36374/2 "2022-03-05T21:00:14Z")

</div>

Hello Nancy,

you might start by simply printing your users-variable to see, what is really in there.

You could do that for example with the debug-module [1] like this:

- name: “Print, what is in users”  
debug:  
msg: “{{ users }}”

You might also want to look up, how the read\_csv-plugin actually works. [2]

In general, I highly recommend using the documentation frequently. Most of the time, you have quite decent odds of finding what you need in the examples-sections. Additionally, it will help you learning and is normally faster than hoping for a response via email.

Best,  
Jan

[1] [https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html)  
[2] [https://docs.ansible.com/ansible/latest/collections/community/general/read\_csv\_module.html](https://docs.ansible.com/ansible/latest/collections/community/general/read_csv_module.html)
