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?
See the Ansible module getent with
database=passwd
.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.While Bruce P's answer is often a good solutions in some situations there is no way to just supply a name. Following Satish Koppisetty's approach here is some code to do it:
You now have two dictionaries (
getent_passwd
andgetent_group
), from which you can retrieve the data. The following code just outputs the ids:A tiny bit of background: this is the case because
getent
returns a dictionary that looks something like this: