也许我不正确地理解它:
我想通过傀儡来定义一些适用于所有连接主机的任务。
这是我的网站.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', } } }
不幸的是用户“testing”没有被设置在testing节点pp-test
阅读你的评论后,我创build了另一个布局:
profile/ `-- manifests |-- backup | |-- client.pp | `-- server.pp |-- backup.pp `-- base.pp role/ `-- manifests |-- backup.pp `-- init.pp
profile / manifests / base.pp包含:
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', } } }
现在我创build了我的site.pp,如下所示:
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 }
那么,问题依然存在:只要我定义pp-test默认软件包没有安装。
引用文档 :
缺省名称(不带引号)是节点名称的特殊值。 如果找不到与给定节点匹配的节点语句,则将使用默认节点。 […]
由于您的节点pp-test的名称是在您的configuration中find的,因此您的default节点configuration将无法应用。
关于你的问题:看看克雷格·邓恩(Craig Dunn)关于“angular色和概况”的博客文章。 如果你要走这条路,你可以拿出这样的东西:
class role { include profile::base } class role::www inherits role { # All WWW servers get tomcat include profile::tomcat } class role::www::dev inherits role::www { include profile::webserver::dev include profile::database } class role::www::live inherits role::www { include profile::webserver::live } class role::mailserver inherits role { include profile::mailserver }
将所有的默认值放在profile::base