Created
June 21, 2012 14:19
-
-
Save traylenator/2966012 to your computer and use it in GitHub Desktop.
Create a block of pool accounts for grid with puppet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/puppet apply | |
class {'grid_users':} | |
class grid_users { | |
#group { "cmsusr": | |
# ensure => present, | |
# gid => 4050 | |
#} | |
#group { "cmssgm": | |
# ensure => present, | |
# gid => 4070 | |
#} | |
userblock{ 'cmssgm': | |
startuid => 43590, | |
count => 9, | |
prefix => 'cmsusr', | |
group => 'cmsusr', | |
secondary => ['cmssgm','random'] | |
} | |
} | |
define userblock ($prefix = $title, $count = 1, $startuid , $secondary = [], $group = $title ) { | |
$yaml = inline_template(' | |
--- | |
<% @count.to_i.times do |i| -%> | |
<%= @prefix %><%= i.to_s %>: | |
uid: <%= i + @count.to_i %> | |
gid: <%= @title %> | |
<% if @secondary.length >= 1 then -%> | |
groups: | |
<% @secondary.each do |grp| -%> | |
<%= grp %> | |
<% end -%> | |
<% end -%> | |
<% end -%> | |
') | |
notice($yaml) | |
$userdata = parseyaml($yaml) | |
create_resources(user,$userdata) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
cmsusr0: | |
uid: 9 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr1: | |
uid: 10 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr2: | |
uid: 11 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr3: | |
uid: 12 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr4: | |
uid: 13 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr5: | |
uid: 14 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr6: | |
uid: 15 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr7: | |
uid: 16 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random | |
cmsusr8: | |
uid: 17 | |
gid: cmssgm | |
groups: | |
cmssgm | |
random |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fantastic, you use inline_template to represent the hash of user data as yaml and then parseyaml to
convert to a hash before feeding the whole lot to create_resources.
Job done.