maybe I do not understand it correctly:
I would like to define some tasks via puppet that are applied on all connected hosts.
This is my site.pp:
node default {
## Add default user ##
user { 'test':
ensure => present,
managehome => true,
password => '$6$XYZ',
}
## Create sudoers ##
class { 'sudo': }
sudo::conf {
'test':
priority => 60,
content => "test ALL=(ALL) ALL"
}
## Install bareos client ##
class {
'bareos':
manage_client => 'true',
}
}
## Create test-file ##
node 'pp-test' {
file { '/tmp/puppet-test':
ensure => present,
mode => 0644,
content => "Only test-servers get this file.\n",
}
include base-software
class {
'ssh':
server_options => {
'Port' => '2211',
'Protocol' => '2',
'HostKey' => '/etc/ssh/ssh_host_rsa_key',
'HostKey' => '/etc/ssh/ssh_host_dsa_key',
'HostKey' => '/etc/ssh/ssh_host_ecdsa_key',
'UsePrivilegeSeparation' => 'yes',
'KeyRegenerationInterval' => '3600',
'ServerKeyBits' => '1024',
'SyslogFacility' => 'AUTH',
'LogLevel' => 'INFO',
'LoginGraceTime' => '120',
'PermitRootLogin' => 'no',
'StrictModes' => 'yes',
'RSAAuthentication' => 'yes',
'PubkeyAuthentication' => 'yes',
'IgnoreRhosts' => 'yes',
'RhostsRSAAuthentication' => 'no',
'HostbasedAuthentication' => 'no',
'PermitEmptyPasswords' => 'no',
'ChallengeResponseAuthentication'=> 'no',
'PasswordAuthentication' => 'yes',
'AllowUsers' => 'test',
}
}
}
Unfortunately the user "test" is not being set up on the test-node pp-test
After reading your comments I created another layout:
profile/
`-- manifests
|-- backup
| |-- client.pp
| `-- server.pp
|-- backup.pp
`-- base.pp
role/
`-- manifests
|-- backup.pp
`-- init.pp
profile/manifests/base.pp contains:
class profile::base {
## Add MOTD ##
class {
'motd':
template => '/etc/puppet/modules/motd/templates/motd.erb',
}
## Add default user ##
user { 'test':
ensure => 'present',
managehome => 'true',
password => '$6$XYZ',
}
## Create sudoers ##
class { 'sudo': }
sudo::conf {
'test':
priority => '60',
content => "test ALL=(ALL) ALL"
}
## Install base-software
include base-software
## Configuration of OpenSSH-Server ##
class {
'ssh':
server_options => {
'Port' => '2211',
'Protocol' => '2',
'HostKey' => '/etc/ssh/ssh_host_rsa_key',
'HostKey' => '/etc/ssh/ssh_host_dsa_key',
'HostKey' => '/etc/ssh/ssh_host_ecdsa_key',
'UsePrivilegeSeparation' => 'yes',
'KeyRegenerationInterval' => '3600',
'ServerKeyBits' => '1024',
'SyslogFacility' => 'AUTH',
'LogLevel' => 'INFO',
'LoginGraceTime' => '120',
'PermitRootLogin' => 'no',
'StrictModes' => 'yes',
'RSAAuthentication' => 'yes',
'PubkeyAuthentication' => 'yes',
'IgnoreRhosts' => 'yes',
'RhostsRSAAuthentication' => 'no',
'HostbasedAuthentication' => 'no',
'PermitEmptyPasswords' => 'no',
'ChallengeResponseAuthentication'=> 'no',
'PasswordAuthentication' => 'yes',
'AllowUsers' => 'test',
}
}
}
Now I created my site.pp as follows:
node default {
include role::backup::client ##add bacula to all servers
}
node 'pp-test' {
file { '/etc/test.txt':
ensure => present,
mode => 0644,
content => "Test\n",
}
}
node 'backupserver' {
include role::backup::server
}
Well, the problem persists: As soon as I define pp-test
default packages are not installed.
Quoting the docs:
As the name of your node
pp-test
is found inside your config, your configuration of thedefault
node will not get applied.Regarding your problem: Have a look at this great blog post by Craig Dunn about "Roles and Profiles". If you would be going this route, you could come up with something like:
...putting all your defaults inside
profile::base
.