Created
March 17, 2014 09:43
-
-
Save alex-harvey-z3q/9596548 to your computer and use it in GitHub Desktop.
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
Imagine our user from before: | |
class users { | |
user { 'elmo': | |
ensure => present, | |
shell => '/bin/zsh', | |
home => '/home/elmo', | |
} | |
file { '/home/elmo': | |
ensure => directory, | |
} | |
file { '/home/elmo/.profile': | |
ensure => file, | |
source => 'puppet:///modules/users/profile', | |
} | |
} | |
What if we want more users? | |
class users { | |
user { 'elmo': | |
ensure => present, | |
shell => '/bin/zsh', | |
home => '/home/elmo', | |
} | |
user { 'piggy': | |
ensure => present, | |
shell => '/bin/zsh', | |
home => '/home/piggy', | |
} | |
user { 'kermit': | |
ensure => present, | |
shell => '/bin/bash', | |
home => '/home/kermit', | |
} | |
file { '/home/elmo': | |
ensure => directory, | |
} | |
file { '/home/piggy': | |
ensure => directory, | |
} | |
file { '/home/kermit': | |
ensure => directory, | |
} | |
file { '/home/elmo/.profile': | |
ensure => file, | |
source => 'puppet:///modules/users/profile', | |
} | |
file { '/home/piggy/.profile': | |
ensure => file, | |
source => 'puppet:///modules/users/profile', | |
} | |
file { '/home/kermit/.profile': | |
ensure => file, | |
source => 'puppet:///modules/users/profile', | |
} | |
} | |
Show students how to collapse into: | |
define myuser ( | |
#user = $name, | |
shell = '/bin/zsh', | |
) { | |
user { $name: | |
ensure => present, | |
shell => '/bin/zsh', | |
home => '/home/elmo', | |
} | |
file { "/home/$name": | |
ensure => directory, | |
} | |
file { "/home/${name}/.profile": | |
ensure => file, | |
source => 'puppet:///modules/users/profile', | |
} | |
} | |
class users { | |
myuser { 'elmo': } | |
myuser { 'piggy': } | |
myuser { 'kermit': | |
shell => '/bin/bash', | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment