Ask Your Question
2

Answers to Learning Puppet Exercises

asked 2013-11-04 20:23:49 -0600

GeneBean gravatar image

updated 2014-11-29 08:29:11 -0600

I am working through the Learning Puppet series and have gotten a little stumped on one of them. Are the answers available anywhere? I found another user stumped by the same one as me ( https://ask.puppetlabs.com/question/2520/learning-puppet-exercise/ ) but the answer to their post didn't clear it up for me. The one I am stuck on right now is http://docs.puppetlabs.com/learning/definedtypes.html . Any help would be appreciated.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-11-05 00:17:44 -0600

spuder gravatar image

updated 2013-11-05 10:13:18 -0600

The answers are not posted anywhere that I can find. Luckily there is ask.puppetlabs.com !

Defined types let you take your typical static puppet code and wrap it in a class that accepts parameters.

To set the ssh keys, use the 'user' type and the 'key' resource like normal

    user { "bob" :
        name  =>  "bob",
        keys  => "12343",
    }

To set the bashrc, use the file 'type' like you normally would.

    file { "/home/bob/.bashrc":
        ensure  =>  present,
        source  => "puppet://modules/foo/bashrc",
        require =>  User["bob"],
    }

All of this code would normally be wrapped in a class

class human::user {
....
}

To leverage the defined ... (more)

edit flag offensive delete link more
0

answered 2014-04-16 06:43:11 -0600

dubis gravatar image

updated 2014-04-16 06:44:04 -0600

Hello, thank you for comprehensive answer. I'dl like to ask something different. I guess your code should be stored in /modules/human/manifests/user.pp. But what should be the content of /modules/human/manifests/init.pp?

Thank you

edit flag offensive delete link more

Comments

In a masterless setup, the manifest can be located anywhere, and called anything, and you run `puppet apply foo.pp --debug`. If you want to turn this into a reusable ...(more)

spuder gravatar imagespuder ( 2014-04-16 10:52:32 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-11-04 20:23:49 -0600

Seen: 630 times

Last updated: Apr 16 '14