Teht1 (W43)
Tehtävänanto:
"w43 läksy: Opiskele Learning Puppet luvut Resources and the RAL ja Manifests. Kirjoita esimerkkiohjelmia, vähintään 1 kunkin luvun aiheesta."
(http://terokarvinen.com/2012/aikataulu-linuxin-keskitetty-hallinta-ict4tn011-2-puppet)
Kokoonpano:
HP EliteBook 2560p └── SanDisk Cruzer 32GB (USB 2.0) └── Xubuntu 12.10 32-bit
Puppet Manifestien luonti:
Tässä pari manifestia, jotka loin kokeilumielessä.
# Testi manifesti, joka luo kansion, tiedoston ja symbolic linkin
# luo tiedoston 'test' kohteeseen '/tmp/'
file {'/tmp/test':
ensure => directory,
mode => 0644,
}
# tekee tiedoston 'test1' kohteeseen '/tmp/test/' ja laittaa hieman tekstiä siihen
file {'/tmp/test/test1':
ensure => present,
content => "This is a test file, made with puppet.\n
Hopefully this works..! \n",
}
# luo symbolic linkin '/tmp/test1_link' , joka osoittaa '/tmp/test/test1'
file {'/tmp/test1_link':
ensure => link,
target => '/tmp/test/test1',
}
# ilmoittaa muutoksista
notify {'Changes':
message => "I made a folder '/tmp/test/' \n
and a file 'test1' inside the folder \n"
and a link '/tmp/test1_link' to direct '/tmp/test/test1' \n",
}
# testi manifesti, joka ajaa komennon 'apt-get update' ja asentaa apache2:n
# määrittää yleisesti käytetyn polun
Exec { path => [ '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin' ] }
# ajaa komennon 'apt-get update'
exec { 'apt-get update':
command => 'apt-get update',
}
# asentaa apache2:n, jos 'apt-get update' on ajettu
package { 'apache2':
ensure => present,
require => Exec['apt-get update'],
}
service { 'apache2':
ensure => running,
require => Package['apache2'],
}
## Lisää käyttäjän 'testman', määrittää tälle kotikansion polun ja käytettävän shellin
user { 'testman':
ensure => 'present',
home => '/home/testman',
shell => '/bin/bash'
}
