[ansible-project] how to determine group's id?

2020-07-14 Thread Laci
Do you guys have a good idea what is the best way to determine a group's id 
them reuse that in a variable?

For ex:
% getent group monitor
monitor:x:990:polkitd

I need 990, then I have to add a line to /etc/fstab including 990
Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/517da774-3826-4de3-b5da-17f128df2a68o%40googlegroups.com.


Re: [ansible-project] how to determine group's id?

2020-07-14 Thread Vladimir Botka
On Tue, 14 Jul 2020 23:02:56 +0200
Jean-Yves LENHOF  wrote:

> Hi, Not tested, but should be closed to what you're looking into : - 
> getent: database: group key: monitor split: ':' - debug: var: 
> getent_group[1]

For example

  - getent:
  database: group
  - debug:
  var: getent_group.nobody

gives

  getent_group.nobody:
  - '*'
  - '65534'

-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200714231038.4fdd65b1%40gmail.com.


pgpmu7VnSYDAs.pgp
Description: OpenPGP digital signature


Re: [ansible-project] how to determine group's id?

2020-07-14 Thread Jean-Yves LENHOF
Hi, Not tested, but should be closed to what you're looking into : - 
getent: database: group key: monitor split: ':' - debug: var: 
getent_group[1]



Regards,

JYL


Le 14/07/2020 à 21:58, Laci a écrit :
Do you guys have a good idea what is the best way to determine a 
group's id them reuse that in a variable?


For ex:
% getent group monitor
monitor:x:990:polkitd

I need 990, then I have to add a line to /etc/fstab including 990
Thanks!
--
You received this message because you are subscribed to the Google 
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to ansible-project+unsubscr...@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/517da774-3826-4de3-b5da-17f128df2a68o%40googlegroups.com 
.


--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6d99c89a-1bca-90b5-c878-95ff864cda0b%40lenhof.eu.org.


Re: [ansible-project] how to determine group's id?

2020-07-15 Thread Laci
Thank you guys, this fixes the first part.
But how do I reuse the output of getent, I tried, the following but didn't 
work

 - getent:
  database: group
  - debug:
  var: getent_group.monitor

  - name: add line to fstab
lineinfile:
  path: /etc/fstab
  line: proc/procprocdefaults,hidepid=2,gid={{ var }}
 0 0

"The task includes an option with an undefined variable. The error was: 
'var' is undefined

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bc51a905-f54b-44da-8a70-6c5645dcbc71o%40googlegroups.com.


Re: [ansible-project] how to determine group's id?

2020-07-15 Thread Vladimir Botka
On Wed, 15 Jul 2020 06:34:10 -0700 (PDT)
Laci  wrote:

>   - name: add line to fstab
> lineinfile:
>   path: /etc/fstab
>   line: proc/procprocdefaults,hidepid=2,gid={{ var }}

Use "mount". It will create the entry in fstab
https://docs.ansible.com/ansible/latest/modules/mount_module.html

-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200715162806.201991d8%40gmail.com.


pgpS15oyx9p7v.pgp
Description: OpenPGP digital signature


Re: [ansible-project] how to determine group's id?

2020-07-15 Thread Vladimir Botka
On Wed, 15 Jul 2020 06:34:10 -0700 (PDT)
Laci  wrote:

>  - getent:
>   database: group
>   - debug:
>   var: getent_group.monitor
> 
>   - name: add line to fstab
> lineinfile:
>   path: /etc/fstab
>   line: proc/procprocdefaults,hidepid=2,gid={{ var }}
>  0 0

Set the variable first. "gid" is the second item in the list. For example

- getent:
database: group
- set_fact:
my_gid: "{{ getent_group.monitor.1 }}"

See if this is what you want

- debug:
var: my_gid

Then use this variable to mount procfs. For example

- mount:
path: proc
src: /proc
fstype: proc
opts: "defaults,hidepid=2,gid={{ my_gid }}"
dump: 0
passno: 0
backup: true
state: mounted

(not tested)

It's a good idea to "backup: true" /etc/fstab. Take a look at the parameter
"state" and decide when you want to mount procfs.

Check the playbook first and see what's going to be changed

shell> ansible-playbook pb.yml -CD

-- 
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200715165658.3623f94e%40gmail.com.


pgpVZp85r4CAX.pgp
Description: OpenPGP digital signature