How do I write a puppet module to create new users (and leverage smart parameters)?

I'm new to Foreman (and pretty new to puppet as well). Go easy on me.

Thanks!

Michael,

I came here to ask the very same question. I began writing a parameterized
class to provision new unix users, but quickly realized that this model
doesn't appear to work if you wish to create more than one user! It would
be wonderful to see how anyone else is performing the task of user creation
while also leveraging the Smart Parameters.

Josh

··· On Friday, October 25, 2013 10:16:11 AM UTC-7, Michael Buckner wrote: > > I'm new to Foreman (and pretty new to puppet as well). Go easy on me. > > Thanks! >

Hello,

first of all, start with Puppet. Get a decent book about puppet and read
that - that's the best thing you can do, because learning by writing is
not the best thing as I learned on myself.

Then write your first manifests and test them locally. On the next level
write or download some parametrized classes:

http://docs.puppetlabs.com/guides/parameterized_classes.html

Then move to the next level - puppet master. Try to deploy some puppet
remotely. And only and only if everything works, then move forward and
integrate that with Foreman.

LZ

··· From my experience, this is good approach for new users.

On Fri, Oct 25, 2013 at 10:16:11AM -0700, Michael Buckner wrote:

I’m new to Foreman (and pretty new to puppet as well). Go easy on me.

Thanks!


You received this message because you are subscribed to the Google Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


Later,

Lukas “lzap” Zapletal
irc: lzap #theforeman

Here's how I rigged this up, it's a little hacky, but seems to be the best
way to deal with any modules that are using defines:

Download the accounts module from the forge:
https://forge.puppetlabs.com/torrancew/account

Then edit the init.pp, and place this at the bottom, outside of the class:

class accounts($user_data){
create_resources('account', $user_data)
}

Then import this into Foreman. After this, you can bring up the class in
Foreman and you'll see 1 parameter for user data. Change this parameter to
yaml, at which point you can just put straight yaml to define your users,
ex:

test_user:
home_dir: /home/test_user
uid: 1100
gid: 1100
ssh_key: (some ssh key)
test_user_2:
home_dir: /home/test_user_2
uid: 1101
gid: 1101
ssh_key: (some other ssh key)

This is working great for us.

··· On Tuesday, October 29, 2013 10:47:53 AM UTC-7, Josh Preston wrote: > > Michael, > > I came here to ask the very same question. I began writing a > parameterized class to provision new unix users, but quickly realized that > this model doesn't appear to work if you wish to create more than one > user! It would be wonderful to see how anyone else is performing the task > of user creation while also leveraging the Smart Parameters. > > Josh > > > > On Friday, October 25, 2013 10:16:11 AM UTC-7, Michael Buckner wrote: >> >> I'm new to Foreman (and pretty new to puppet as well). Go easy on me. >> >> Thanks! >> >

As Lukas says, getting some Puppet background is good. Once you're there,
try a pattern like this:

users/manifests/user.pp
define users::user {
user { $name:
ensure => present
}
}

users/manifests/init.pp
class users ($users={}) {
create_resources(users::user, $users)
}

In foreman, assign a class param (Hash type):
$users => {
'greg' => {}
'josh' => {}
'lukas => {}
}

You can easily add more attributes to the per-user hashes for managing more
attributes. For example:

HTH,
Greg

··· On 29 October 2013 17:47, Josh Preston wrote:

Michael,

I came here to ask the very same question. I began writing a
parameterized class to provision new unix users, but quickly realized that
this model doesn’t appear to work if you wish to create more than one
user! It would be wonderful to see how anyone else is performing the task
of user creation while also leveraging the Smart Parameters.

Thanks for the advice. I'm getting the following when trying to apply it:

Error 400 on SERVER: Could not find class accounts

Here's the yaml output for the host:

··· --- classes: accounts: user_data: test_user: home_dir: /home/test_user uid: 1100 gid: 1100 password: my_hash augeasproviders: git: motd: ntp: servers: - XX.XXX.XXX rsyslog: snmp: ro_community: not_public ro_network: XX.XXX.X/24 ssh: stdlib: sudo: vim: parameters: puppetmaster: puppetmaster.mydomain.com hostgroup: Common_Production/Common_development root_pw: my_hash foreman_env: production environment: production

On Tuesday, October 29, 2013 2:23:24 PM UTC-4, Jack Watroba wrote:

Here’s how I rigged this up, it’s a little hacky, but seems to be the best
way to deal with any modules that are using defines:

Download the accounts module from the forge:
https://forge.puppetlabs.com/torrancew/account

Then edit the init.pp, and place this at the bottom, outside of the class:

class accounts($user_data){
create_resources(‘account’, $user_data)
}

Then import this into Foreman. After this, you can bring up the class in
Foreman and you’ll see 1 parameter for user data. Change this parameter to
yaml, at which point you can just put straight yaml to define your users,
ex:

test_user:
home_dir: /home/test_user
uid: 1100
gid: 1100
ssh_key: (some ssh key)
test_user_2:
home_dir: /home/test_user_2
uid: 1101
gid: 1101
ssh_key: (some other ssh key)

This is working great for us.

On Tuesday, October 29, 2013 10:47:53 AM UTC-7, Josh Preston wrote:

Michael,

I came here to ask the very same question. I began writing a
parameterized class to provision new unix users, but quickly realized that
this model doesn’t appear to work if you wish to create more than one
user! It would be wonderful to see how anyone else is performing the task
of user creation while also leveraging the Smart Parameters.

Josh

On Friday, October 25, 2013 10:16:11 AM UTC-7, Michael Buckner wrote:

I’m new to Foreman (and pretty new to puppet as well). Go easy on me.

Thanks!

Hi,

I'm testing this right now on Foreman 1.5 and I get errors whatever I do:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
create_resources(): second argument must be a hash at
/etc/puppet/environments/common/accounts/manifests/init.pp:195

There seems to be a bug in Foreman pasting the yaml ?

Jul 24 09:40:56 fm-01 puppet-master[142151]: YAML in network requests is
deprecated and will be removed in a future version. See
http://links.puppetlabs.com/deprecate_yaml_on_network
Jul 24 09:40:56 fm-01 puppet-master[142151]: (at
/usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:136:in
`decode_params')
^C

I hope someone can help me out here!

Thanks,

Matt

··· Op dinsdag 29 oktober 2013 19:23:24 UTC+1 schreef Jack Watroba: > > Here's how I rigged this up, it's a little hacky, but seems to be the best > way to deal with any modules that are using defines: > > Download the accounts module from the forge: > https://forge.puppetlabs.com/torrancew/account > > Then edit the init.pp, and place this at the bottom, outside of the class: > > class accounts($user_data){ > create_resources('account', $user_data) > } > > Then import this into Foreman. After this, you can bring up the class in > Foreman and you'll see 1 parameter for user data. Change this parameter to > yaml, at which point you can just put straight yaml to define your users, > ex: > > test_user: > home_dir: /home/test_user > uid: 1100 > gid: 1100 > ssh_key: (some ssh key) > test_user_2: > home_dir: /home/test_user_2 > uid: 1101 > gid: 1101 > ssh_key: (some other ssh key) > > This is working great for us. > > On Tuesday, October 29, 2013 10:47:53 AM UTC-7, Josh Preston wrote: >> >> Michael, >> >> I came here to ask the very same question. I began writing a >> parameterized class to provision new unix users, but quickly realized that >> this model doesn't appear to work if you wish to create more than one >> user! It would be wonderful to see how anyone else is performing the task >> of user creation while also leveraging the Smart Parameters. >> >> Josh >> >> >> >> On Friday, October 25, 2013 10:16:11 AM UTC-7, Michael Buckner wrote: >>> >>> I'm new to Foreman (and pretty new to puppet as well). Go easy on me. >>> >>> Thanks! >>> >>

Ah, sorry, change the name of the module folder to accounts.

··· On Thursday, October 31, 2013 12:54:58 PM UTC-7, Michael Buckner wrote: > > Thanks for the advice. I'm getting the following when trying to apply it: > > Error 400 on SERVER: Could not find class accounts > > Here's the yaml output for the host: > > --- > classes: > accounts: > user_data: > test_user: > home_dir: /home/test_user > uid: 1100 > gid: 1100 > password: my_hash > augeasproviders: > git: > motd: > ntp: > servers: > - XX.XXX.XXX > rsyslog: > snmp: > ro_community: not_public > ro_network: XX.XXX.X/24 > ssh: > stdlib: > sudo: > vim: > parameters: > puppetmaster: puppetmaster.mydomain.com > hostgroup: Common_Production/Common_development > root_pw: my_hash > foreman_env: production > environment: production > > > On Tuesday, October 29, 2013 2:23:24 PM UTC-4, Jack Watroba wrote: >> >> Here's how I rigged this up, it's a little hacky, but seems to be the >> best way to deal with any modules that are using defines: >> >> Download the accounts module from the forge: >> https://forge.puppetlabs.com/torrancew/account >> >> Then edit the init.pp, and place this at the bottom, outside of the class: >> >> class accounts($user_data){ >> create_resources('account', $user_data) >> } >> >> Then import this into Foreman. After this, you can bring up the class in >> Foreman and you'll see 1 parameter for user data. Change this parameter to >> yaml, at which point you can just put straight yaml to define your users, >> ex: >> >> test_user: >> home_dir: /home/test_user >> uid: 1100 >> gid: 1100 >> ssh_key: (some ssh key) >> test_user_2: >> home_dir: /home/test_user_2 >> uid: 1101 >> gid: 1101 >> ssh_key: (some other ssh key) >> >> This is working great for us. >> >> On Tuesday, October 29, 2013 10:47:53 AM UTC-7, Josh Preston wrote: >>> >>> Michael, >>> >>> I came here to ask the very same question. I began writing a >>> parameterized class to provision new unix users, but quickly realized that >>> this model doesn't appear to work if you wish to create more than one >>> user! It would be wonderful to see how anyone else is performing the task >>> of user creation while also leveraging the Smart Parameters. >>> >>> Josh >>> >>> >>> >>> On Friday, October 25, 2013 10:16:11 AM UTC-7, Michael Buckner wrote: >>>> >>>> I'm new to Foreman (and pretty new to puppet as well). Go easy on me. >>>> >>>> Thanks! >>>> >>>