我正在使用 puppet vm 来学习 puppet 教程,并具有以下清单:
# /root/learning-manifests/2.file.pp
file {
'/tmp/test1':
ensure => present,
content => "Hi.",
}
file {
'/tmp/test2':
ensure => directory,
mode => 0644,
}
file {
'/tmp/test3':
ensure => link,
target => '/tmp/test1',
}
notify {
"I'm notifying you.":
}
notify {
"So am I!":
}
Run Code Online (Sandbox Code Playgroud)
我的预期输出是:
notice: I'm notifying you.
notice: /Stage[main]//Notify[I'm notifying you.]/message: defined 'message' as 'I'm notifying you.'
notice: So am I!
notice: /Stage[main]//Notify[So am I!]/message: defined 'message' as 'So am I!'
Run Code Online (Sandbox Code Playgroud)
我的实际输出是: …
我的公司正在考虑采用 Puppet 来管理我们的基础设施。我们听说 Puppet 不如其他解决方案(例如 CFEngine)高效。有没有人有关于 Puppet 服务器可以支持多少个节点的硬数据?是否有关于此的大小调整或最佳实践文档?到目前为止,我找不到有关 Puppet 3 的任何信息。
编辑更多细节。我们正在考虑从分布在 3 个物理位置的 4000 个节点开始,并计划在这些位置扩展到多达 10k 个节点,并扩展到公共云提供商。我们为这些节点使用 CentOS 5 和 6。puppet 是正确的工具吗?我应该计划多少个 puppetmaster 来管理 4000 个节点?
我想通过 puppet 将一些配置文件推送到我的所有服务器。所有服务器的文件几乎相同,但有一个变化 - 主机名。
我已经用清单和临时配置文件在 puppet 中创建了模块。我包括所有节点。一切都很好。
我的问题是:如何通过更改该文件中的一/两行将该文件推送到所有服务器。但我不想在模块中为所有人设置配置文件。我想使用一个文件,并在两行推送更改期间使用。
谢谢你的帮助。
最好的事物,
拉法尔
我在 Puppet 仪表板中看到许多消息,说发生了变化,将组的所有权从“用户”更改为“用户”。它似乎与存在两次的“用户”组有关,一次在本地组 ID 为 100,一次在组 ID 为 3000。
[root@tst-01 ~]# puppet agent --test
info: Caching catalog for tst-01.tst.domain.tld
info: Applying configuration version '1370937308'
notice: /File[/var/opt/dolphin]/group: group changed 'users' to 'users'
notice: Finished catalog run in 3.41 seconds
[root@tst-01 ~]#
[root@puppetmaster ~]# cat init.pp
class dolphin {
file { "/var/opt/dolphin":
ensure => "directory",
owner => "dolphin",
group => "users",
mode => 755,
}
}
[root@puppetmaster ~]#
[root@tst-01 audit]# grep -A2 dolphin-own audit.log
type=SYSCALL msg=audit(1370894388.610:49571): arch=c000003e syscall=94 success=yes exit=0 a0=4e96770 a1=ffffffff …Run Code Online (Sandbox Code Playgroud) 这是我的一个片段 /etc/puppet/puppet.conf
[main]
modulepath = /etc/puppet
Run Code Online (Sandbox Code Playgroud)
当我尝试在init.pp文件中使用此路径时出现错误
etc/puppet/modules/fangs/manifests# puppet apply init.pp
err: /Stage[main]//File[/tmp/test]: Could not evaluate: Could not retrieve information
from environment production source(s) puppet:///modules/fangs/files/sample.txt at /etc/puppet/modules/fangs/manifests/init.pp:7
notice: Finished catalog run in 0.05 seconds
Run Code Online (Sandbox Code Playgroud)
这是我的init.pp文件的内容
file { '/tmp/test':
ensure => file,
mode => '0777',
source => "puppet:///modules/fangs/files/sample.txt",
# source => "/etc/puppet/modules/fangs/files/sample.txt",
}
Run Code Online (Sandbox Code Playgroud)
当我使用source => "/etc/puppet/modules/fangs/files/sample.txt",带有完整文件路径而不是puppet://模块路径的注释源时,它可以正确运行。
如何修复我的模块路径以确保它正常工作?
从表面上看,我需要能够在目标节点上安装一些软件守护程序才能使这些东西正常工作。如果我不能这样做(例如 Amazon RDS 实例),我有哪些选择?
同样,Ansible 似乎完全基于 SSH。这可以用来配置RDS吗?
感谢您的反馈——讨论让我在这里提出了一个更有针对性的问题:https : //serverfault.com/questions/588237/whats-a-good-cm-tool-for-managing-a-cloud-cluster-组合-多元化-资源-ac
我有一个非常简单的 Puppet(子)模块,它应该使用 Git 从远程位置克隆存储库:
class wppuppet::git(
$location = '/var/www/wp'
) {
file { $location:
ensure => 'directory',
mode => '0755',
}
exec { 'git-wp':
command => 'git clone https://github.com/WordPress/WordPress ${location}',
require => Package['git'],
}
Package['git']
-> File[ $location ]
-> Exec['git-wp']
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它经常失败并出现以下错误:
Error: git clone https://github.com/WordPress/WordPress ${location} returned 128 instead of one of [0]
Error: /Stage[main]/Wppuppet::Git/Exec[git-wp]/returns: change from notrun to 0 failed:
git clone https://github.com/WordPress/WordPress ${location} returned 128 instead one of [0]
Run Code Online (Sandbox Code Playgroud)
我用${location}和尝试过$location,但结果保持不变。
我正在运行 puppet 并且它运行正常,但是在没有任何更改的情况下同步需要大约 15 分钟,在我看来,这应该不会超过一两分钟。以下是一些统计数据:
我尝试过使用和不使用 Apache 隧道/WEBrick/passenger,结果相同。
有哪些诊断和改进同步时间的策略?
更新:就我而言,除了使用该--evaltrace选项的选定答案外,我使用strace并发现 TCP 连接超时并且我的防火墙正在限制速率。(为什么 puppet 没有报告超时以及为什么它没有重用连接,我不知道。)
我跑了puppet cert clean --all,认为它只会清除尚未签署的证书。大约有 300 个节点依赖于 puppet master。据我所知,puppet agent 仍然对它们有效,但我认为这是因为某处有证书的缓存副本。
有什么方法可以纠正这种情况而不必手动登录到 300 个不同的服务器?
谢谢
编辑:我应该提到 /var/lib/puppet 由于某种原因没有被备份。
如何使用 Puppet 中的 ERB 模板文件调整 ~/.ssh/config 文件中的“用户”行,使其包含与帐户名称匹配的正确用户名?
class accounts_global::tharold {
account { 'tharold':
ensure => present,
}
file { "/home/tharold/.ssh/config" :
require => Account['tharold'],
owner => 'tharold',
group => 'tharold',
mode => '0600',
content => template('accounts_global/user_ssh_config.erb'),
}
}
Run Code Online (Sandbox Code Playgroud)
user_ssh_config.erb 文件的内容如下所示:
Host ssh.example.com
Port 22
User tharold
IdentityFile ~/.ssh/ssh-key
Run Code Online (Sandbox Code Playgroud)
问题是,用用户的帐户名替换模板文件中的“User tharold”应该是什么样子的?这个 ERB 配置文件将被多个用户使用,所以我需要参数化文件的那部分。
尝试使用 <%= @name %> 最终将“accounts_global::tharold”放入文件中。