我一直在学习 puppet 并用它来设置 jenkins 框。我通过 tomcat 连接 jenkins,因为我可能最终还会在那里运行其他 webapps。
编辑:我已经安装了(通过puppet module install puppetlabs-stdlib
)puppetlabs 提供的 stdlib 来使用 file_line 类型。
这是用于设置 jenkins 和 tomcat 并将两者连接在一起的 puppet 模块清单。
class tomcat_jenkins {
package{'java-1.7':
ensure => installed,
name => 'java-1.7.0-openjdk',
}
package{'tomcat6':
ensure => installed,
require => Package['java-1.7'],
}
package{'jenkins':
ensure => installed,
require => Yumrepo['jenkins'],
}
file{'jenkins-symlink':
name => '/usr/share/tomcat6/webapps/jenkins.war',
require => [Package['tomcat6'], Package['jenkins']],
ensure => link,
target => '/usr/lib/jenkins/jenkins.war',
}
file{ '/srv':
ensure => directory,
owner => 'root',
group => 'root',
}
file{ '/srv/jenkins':
ensure => directory,
owner => 'tomcat',
group => 'tomcat',
require => Package['tomcat6'],
}
file_line{'jenkins_home':
ensure => present,
path => '/etc/tomcat6/tomcat6.conf',
line => 'JENKINS_HOME=/srv/jenkins',
require => [Package['tomcat6'], File['/srv/jenkins']],
}
service{'tomcat6':
ensure => running,
enable => true,
require => [Package['tomcat6'], Package['jenkins'], File_line['jenkins_home']],
subscribe => [Package['jenkins'], File['jenkins-symlink']],
}
}
我看到 Puppet 代理的输出表明它正在正确应用目录,并且它假装继续应用更改,但我的 /etc/tomcat6/tomcat6.conf 文件中没有/jenkins/
。我没有其他任何东西来管理该文件。
puppet agent -t -d
输出:
info: Applying configuration version '1343250206'
debug: /Stage[main]/Tomcat_jenkins/File_line[jenkins_home]/require: requires Package[tomcat6]
debug: /Stage[main]/Tomcat_jenkins/File_line[jenkins_home]/require: requires File[/srv/jenkins]
debug: /Stage[main]/Epel_repo/Yumrepo[epel]/require: requires File[/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6]
debug: /Stage[main]/Tomcat_jenkins/Package[jenkins]/require: requires Yumrepo[jenkins]
debug: /Stage[main]/Tomcat_jenkins/Service[tomcat6]/require: requires Package[tomcat6]
debug: /Stage[main]/Tomcat_jenkins/Service[tomcat6]/require: requires Package[jenkins]
debug: /Stage[main]/Tomcat_jenkins/Service[tomcat6]/require: requires File_line[jenkins_home]
debug: /Stage[main]/Tomcat_jenkins/Service[tomcat6]/subscribe: subscribes to Package[jenkins]
debug: /Stage[main]/Tomcat_jenkins/Service[tomcat6]/subscribe: subscribes to File[jenkins-symlink]
答案1
在 irc.freenode.net 上的 #puppet 上询问后,我发现 puppet 代理缺少一个配置参数。我需要:
pluginsync=true
在[main]
部分中。添加该行后,它愉快地下载了插件,并设置了我的内容。赢了。