# create a dir for user if its in group

**URL:** <https://forum.ansible.com/t/create-a-dir-for-user-if-its-in-group/20845>\
**Category:** Ansible Project\
**Created:** [March 11, 2016, 6:23pm UTC](https://forum.ansible.com/t/create-a-dir-for-user-if-its-in-group/20845 "2016-03-11T18:23:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roy](https://avatars.discourse-cdn.com/v4/letter/r/4da419/32.png) [@Roy](https://forum.ansible.com/u/Roy)\
**Post date:** [March 11, 2016, 6:23pm UTC](https://forum.ansible.com/t/create-a-dir-for-user-if-its-in-group/20845/1 "2016-03-11T18:23:30Z")

</div>

Hi,

I was trying following task, to create a user if user is a part on **hdfsuser** group

> `
> 
> - name: create user tmp dir /srv/tmp/$USER on gateway  
> file: path=/srv/tmp/{{ item.name }} owner={{ item.name }} group={{ item.name }} mode=0755 state=directory  
> when: “‘hdfsuser’ in {{ item.groups }}”  
> with\_items: ssh\_users  
> tags:
> - hadoop
> 
> `

But getting this error :

`  
fatal: [[hadoop-client001.dev.abc.com](http://hadoop-client001.dev.abc.com)]: FAILED! =\> {“failed”: true, “msg”: “The conditional check ‘‘hdfsuser’ in {{ item.groups }}’ failed. The error was: template error while templating string: expected token ‘,’, got ‘string’. String: {% if ‘hdfsuser’ in [u’users’] %} True {% else %} False {% endif %}\n\nThe error appears to have been in ‘/Users/xyz/ansible/roles/luigi/tasks/main.yml’: line 81, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: create user tmp dir /srv/tmp/$USER on gateway\n ^ here\n”}

`

anyone knows workaround this ?

Thanks
