# Error when create users with an external list

**URL:** <https://forum.ansible.com/t/error-when-create-users-with-an-external-list/24743>\
**Category:** Ansible Project\
**Created:** [June 16, 2017, 6:41am UTC](https://forum.ansible.com/t/error-when-create-users-with-an-external-list/24743 "2017-06-16T06:41:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neddy](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@Neddy](https://forum.ansible.com/u/Neddy)\
**Post date:** [June 16, 2017, 6:41am UTC](https://forum.ansible.com/t/error-when-create-users-with-an-external-list/24743/1 "2017-06-16T06:41:16Z")

</div>

I’m using Ansible 2.3.0 and writing a playbook that creates MySQL users based on a list of user.

My playbook tree:

`

> –inventories
> 
> > –staging
> > 
> > > –hosts  
> > > –roles  
> > > –create\_mysql\_users  
> > > –tasks
> > > 
> > > > –main.yml  
> > > > –vars  
> > > > –mysql\_users.yml  
> > > > –site.yml  
> > > > `

site.yml

`

- hosts: mysql  
remote\_user: centos  
become: yes  
become\_method: sudo  
roles:
- create\_mysql\_users

`

roles/create\_mysql\_users/tasks/main.yml

`

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 20, 2017, 12:00am UTC](https://forum.ansible.com/t/error-when-create-users-with-an-external-list/24743/2 "2017-06-20T00:00:15Z")

</div>

When you are using include-vars to import into the mysql-users  
variable, you are creating an 'unsafe object' that Ansible uses  
internally to track 'data from modules' and avoid templating them as  
they can lead to security issues.

if you create a vars file with:  
mysql\_user:  
&nbsp;&nbsp;- name: user1  
...

and use vars\_files, it should work normally.

I'm going to check with the rest of the team to see if this is a  
behaviour we want for include vars (it is not a 'normal module'). For  
now you can use the workaround above.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 20, 2017, 12:04am UTC](https://forum.ansible.com/t/error-when-create-users-with-an-external-list/24743/3 "2017-06-20T00:04:25Z")

</div>

I just noticed, mysql\_users is NOT a list, its a dictionary:

user1: { username: user1, password: secret, host: "%", priv:  
"\*.\*:ALL,GRANT", state: present }

would require:  
&nbsp;&nbsp;&nbsp;name: "{{ mysql\_users[item]['username'] }}"

to use as you expect you would have to define as:  
- { username: user1, password: secret, host: "%", priv:  
"\*.\*:ALL,GRANT", state: present }

or  
- username: user1  
&nbsp;&nbsp;password: secret  
....
