In my playbook I install the amavis package. Later in a task I use the mount module to setup a ramdisk (tmpfs).

In order to let the tmpfs-ramdisk be owned by the uid and gid created during amavis package install (amavis-user and amavis-group, in /etc/fstab then using the options parameter) how do I find out which uid and gid was created?

Goal (something like):

/dev/shm /var/lib/amavis/tmp tmpfs defaults,noexec,nosuid,nodev,noatime,size=500m,mode=770,uid=112,gid=116 0 0

Or should I create the users before package installation to explicitly set uid and gid via Ansible?


You should be able to just specify uid=amavis-user,gid=amavis-group in your /etc/fstab. The linux mount program will interpret them correctly.

  • This is true. I'll see in the future if it's always possible to avoiud uid/gid lookups (aka "knowledge"). Guess it's recommended anyway to not need it. – initall Dec 17 '15 at 7:40
  • Hmm - not quite the answer - NFS exports doesn't look like it can deal with this for the anonuid and anongid settings. – Danny Staple Jun 21 '16 at 15:53

See the Ansible module getent with database=passwd.

  • Out of interest, why the downvotes? Bruce P's answer does seem easier in the context of this specific question, but is 'getent' a viable way for Ansible to get a uid in the general case? – Jonathan Hartley Mar 5 '17 at 2:05
  • 2
    I would appreciate a straight to the point answer on how to actually get the uid for a provided username with ansible. – redanimalwar Mar 7 '18 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.