Handson1: Difference between revisions
From Gridkaschool
Jump to navigationJump to search
Line 72: | Line 72: | ||
# Write your first module |
# Write your first module |
||
## A module is directory tree which stores all manifests, files, templates, tests which belong to one feature |
## A module is directory tree which stores all manifests, files, templates, tests which belong to one feature |
||
## Create the following tree structure<br /> |
## Create the following tree structure<br />sshd/<br />sshd/files<br />sshd/manifests<br /> |
||
sshd/<br /> |
|||
sshd/files<br /> |
|||
sshd/manifests<br /> |
|||
## Copy the sshd class manifest as sshd/manifests/init.pp |
## Copy the sshd class manifest as sshd/manifests/init.pp |
Revision as of 14:41, 27 August 2014
Hands-On
Environment
- Login via ssh to the workgroup server naf-school01.desy.de with your assigned account
- Check if you can login via ssh to you assigned VM as root
- Check if you can edit a text file on the wgs and the node. We provide vim, emacs, nano
Puppet first steps
- Use the puppet RAL to examine and configure the VM node solution
- Show all managed resources
- Show description of the resource service
- Show all configured services
- Create a testuser
- Show resource of the created user
- Delete the testuser
- HINT:
- puppet resource --help
- puppet describe
- https://docs.puppetlabs.com/references/latest/type.html#user-attribute-ensure
- Write the first Manifest
- Create a puppet manifest which creates two testuser. Filename: handson1create.pp
- Create a puppet manifest which removes both testuser. Filename: handson1remove.pp
- Concatenate both puppet manifest. Filename: handson1combine.pp
- Apply the manifests to your node.
- Try to understand why the handson1combine.pp manifest fails?
- Hint:
- https://docs.puppetlabs.com/puppet/latest/reference/lang_resources.html
- puppet apply --help
- Write the second Manifest solution
- Create a puppet manifest which creates the file /etc/motd with the content Hello World!. Filename: handson1motd.pp
- Apply the manifest to your node
- Examine what happens if you re-apply the manifest.
- Add a line to the file /etc/motd and re-apply the manifest
- Hint:
- Write the third Manifest solution
- Write a manifest which writes 10 debug messages in the following order
- Hello World 1
Hello World 2
Hello World 3
...
Hello World 10
- Hello World 1
- Hint:
- https://docs.puppetlabs.com/references/latest/type.html#notify
- https://docs.puppetlabs.com/learning/ordering.html#before-and-require
- Resources with lower case are instantiating, Resources with first letter upper case are reference
- Write a manifest which writes 10 debug messages in the following order
- Write the fourth manifest to configure the sshd daemon solution
- Create the folder /root/example
- Copy the file /etc/ssh/sshd_config in the folder /root/example
- Create a manifest which defines the following resources in the described order
- Install package sshd
- Copy the file from /root/example to /etc/ssh/sshd_config
- Start the sshd daemon
- Apply the manifest with "--noop" parameter the /etc/ssh/sshd_config file shouldn't be changed. No line like
Notice: /Stage[main]/Main/File[foo]/content: current_value {md5}...., should be {md5}.... (noop)
- Apply the manifest without "--noop" parameter
- Write the fifth manifest solution
- Improve the third manifest. The text Hello World should be in a variable.
- Examine the facts of the VM locally with facter
- Write a manifest which gives a debug message if the machine is virtual machine and the uptime
- Run the manifest on your VM and on naf-school01
- Hints:
- Write your first class
- Classes are blocks of resources
- They divide the definition and the declarations
- Classes could could parameterized
- Syntax:
class my_class {
... puppet code ...
} - transform the fourth manifest (the sshd example) to a class.
- Apply the manifest. And examine if the manifest is still working
- Add the declaration to the end of the manifest. And re-apply the manifest
- Add a string as parameter to the class and print this string as debug message
- Hints:
- Write your first module
- A module is directory tree which stores all manifests, files, templates, tests which belong to one feature
- Create the following tree structure
sshd/
sshd/files
sshd/manifests - Copy the sshd class manifest as sshd/manifests/init.pp