title: How can I find the user ID using ansible and use that in a jinja2 template?
body: <p>I have to create a number of users using ansible. I pass the users as a list inside my ansible play in the vars section:</p>
  
  <pre><code>  vars:
      users: ['user1', 'user2']
  </code></pre>
  
  <p>I then have to create a script that uses this users' ID as an argument. The command inside the script is something like this:</p>
  
  <p><code>blobfuse $1 --tmp-path=/mnt/resource/{{ item }}/ -o attr_timeout=240 -o entry_timeout=240 -o negative_timeout=120 -o uid=$USER_ID -o allow_other --container-name={{ item }} --file-cache-timeout-in-seconds=120 --config-file=/root/connection-{{ item }}.cfg
  </code></p>
  
  <p>Everything works fine, with the exception of <strong>uid=</strong>
  I have tried with the lookup's pipe plugin but this doesn't get me the correct UID:</p>
  
  <p><code>{{ lookup('pipe', 'grep -w {{ item }} /etc/passwd | cut -d : -f3') }}</code></p>
  
  <p>My end goal is to get the UID of each of the created users, and pass that to the blobfuse command above.</p>