realize group before user ?

668 views
Skip to first unread message

Jan-Frode Myklebust

unread,
Mar 10, 2010, 2:54:15 AM3/10/10
to puppet...@googlegroups.com
I have this user and group that I need to realize:

@user { "policyd":
ensure => "present",
uid => "103",
gid => "103",
comment => "Postfix Policy Daemon",
home => "/home/policyd",
shell => "/bin/bash",
}
@group { "policyd":
ensure => "present",
gid => "103",
}

but how do I make sure the group is created before the user? Only way
I can think of is realizing the group in a class that I "require" in
the class realizing the user, but that seems silly...


-jf

David Schmitt

unread,
Mar 10, 2010, 3:04:42 AM3/10/10
to puppet...@googlegroups.com

You only have to take care that both the user and the group are
realized. Puppet will automatically take care of creating a proper
dependency between the two.


If your question was actually about how to realize both user and group,
I'd recommend you using tags to mark both and then realize based on the
tags.


Regards, David Schmitt
--
dasz.at OG Tel: +43 (0)664 2602670 Web: http://dasz.at
Klosterneuburg UID: ATU64260999

FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg

janfrode

unread,
Mar 10, 2010, 6:05:11 AM3/10/10
to Puppet Users
Sorry, but it doesn't seem to be that simple. I just tried to include
a class that does:

realize (
Group["policyd"],
User["policyd"]
)

and see on the puppet client:

Mar 10 12:00:16 asav puppetd[20247]: Starting Puppet client version
0.25.4
Mar 10 12:00:31 asav puppetd[20247]: (//user::virtual/User[policyd]/
ensure) change from absent to present failed: Could not create user
policyd: Execution of '/usr/sbin/useradd -u 103 -g 103 -d /home/
policyd -c Postfix Policy Daemon -s /bin/bash -M policyd' returned 6:
useradd: unknown group 103
Mar 10 12:00:32 asav puppetd[20247]: (//user::virtual/Group[policyd]/
ensure) created
Mar 10 12:00:33 asav puppetd[20247]: Finished catalog run in 6.58
seconds


So, it fails to create the user on first run.. but will of course
succeed the next time since now the group is created... But how can I
force group creation before user creation, when the order listed in
realize() obviously doesn't matter.


-jf

Daniel Kerwin

unread,
Mar 10, 2010, 6:24:59 AM3/10/10
to puppet...@googlegroups.com
Add this line to your user definition:

require => Group["policyd"]

That should work

> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>

--

Cheers,

Daniel

janfrode

unread,
Mar 10, 2010, 6:54:31 AM3/10/10
to Puppet Users

That worked. Great, thanks!


-jf

Reply all
Reply to author
Forward
0 new messages