torstai 11. huhtikuuta 2013

Puppet - file, package, service

Scenario: I want to install ssh server, replace the default config with my own settings and check that the service is running.

First create a new module folder named for example sshd and inside it folder manifests. Then create init.pp file inside manifests with
$ sudo nano init.pp
inside init.pp write this:


class sshd {
package { 'openssh-server':
ensure => "installed",
}

file { '/etc/ssh/sshd_config':
content => template("/home/xubuntu/Templates/sshd_template.erb"),
require => Package["openssh-server"],
notify => Service["ssh"],
}

service { 'ssh':
ensure => 'running',
enable => 'true',
require => Package["openssh-server"],

hasstatus => 'false',
status => "/etc/init.d/ssh status|grep running",
}
}

Then create new template file in /home/xubuntu/Templates/sshd_template.erb inside the .erb file put your own sshd config file.

Run puppet with: $ sudo puppet apply -e "include sshd"

Ei kommentteja:

Lähetä kommentti