Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a custom GID in groupadd cloud-init?

Is it possible to create group with specify ID example in cloud-init:

groupadd -g 1234 sapsys

#cloud-config
groups:
  - sapsys
like image 710
unixdisk Avatar asked Dec 12 '25 15:12

unixdisk


1 Answers

cloud-init surprisingly does not have this ability. And in fact older versions such included with RHEL6 do not even support uid on users.

We can not use useradd as commented because user_groups module runs before the runcmd so I worked around this by letting the user_group module choose whatever UID/GID it wanted and then in the runcmd change them to what I wanted them to be.

runcmd:
  - 'usermod -u 1234 sapsys'
  - 'groupmod -g 1234 sapsys'
like image 196
Andrew Avatar answered Dec 15 '25 08:12

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!