假设我有一个值数组
["node1.example.org", "node2.example.org"]
Run Code Online (Sandbox Code Playgroud)
我想使用 facter 传递它,并在 puppet 中使用它:
host {
$nodes:
...
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我有一个 html 文件,我想使用 Puppet 用具有相同文件名的空文件替换该文件。我想知道 Puppet 是否可以删除文件的全部内容?
例如,这是在 Puppet 中删除一行的正确方法吗?
file_line { 'delete a line':
ensure => absent,
path => /tmp/test,
line => '\ '
match => '^(?:.*)'
}
Run Code Online (Sandbox Code Playgroud) 我想做的很简单:
1.
复制/source/file到/target/file. 我使用以下方法实现了这一点:
file { 'my_file_copy':
ensure => file,
source => 'file:/source/file',
path => "/target/file",
}
Run Code Online (Sandbox Code Playgroud)
2.
但是,如果文件/source/file不存在,我不希望它执行此任务。
我真的很纠结这个逻辑。我尝试了下面的解决方案,但它在木偶运行期间抛出异常。
有没有更好的方法来完成这项任务?理想情况下,我只想使用“文件”而避免使用“exec”。但在这一点上,我会满足于一个解决方案!
我在木偶中有这样的数据结构:
Struct[
'ssh_keys' => Hash[
String,
Struct[
'path' => String,
'content' => String,
]
]
] $myStructure
Run Code Online (Sandbox Code Playgroud)
我想将所有“路径”值提取到一个数组中。
我使用映射内部结构
$testvariable = $myStructure['ssh_keys'].map |$items| { $items[1] }
Run Code Online (Sandbox Code Playgroud)
但这里有点糟糕,任何帮助将不胜感激。
我试图用bash脚本调用puppet,虽然它有效,但它会导致我的脚本过早结束.
#!/bin/bash
...
function runPuppetLocally()
{
echo "...running Puppet locally"
exec puppet agent --test
echo "Puppet complete"
}
runPuppetLocally
Run Code Online (Sandbox Code Playgroud)
我认为Puppet正在发布退出或类似的东西,导致我的脚本结束.是否有一种方法可以在不终止我的脚本的情况下调用它?
是否有人有使用这三种技术的经验?我发现谋杀是Twitter的代码部署开源项目,它使用BitTorrent达到分发文件的高速度,但木偶和厨师也用于软件分发.任何人都可以简单介绍这三个吗?
是否可以使用Puppet设置,使用JClouds在云上实例化新虚拟机,然后通过Puppet定义和实现其配置(软件堆栈)?
或者Puppet的本质是否存在某些内在因素阻止其在AWS,RackSpace或Heroku等云提供商上的使用?
下面的代码示例纯粹是学术性的,但它很好地说明了我的问题.
define touch($file=$title, $unless='/bin/false') {
exec { "/bin/touch ${file}": unless => $unless }
}
Run Code Online (Sandbox Code Playgroud)
如果我定义我自己的包装另一个exec资源的资源类型,并且我想添加一个可选的"除非"条件,我 - 如果设置 - 传递给exec的可选"除非"条件- 我是否必须使用'/预设字段斌/假"?
我的理解是,对于每个目录运行和此自定义资源的所有使用类型此资源,除非检查将生成运行'/ bin/false'的bash进程,如果尚未设置"touch"的除非字段.
如果字段尚未设置,我实际上打算不进行任何"除非"检查 - 包括调用"/ bin/false".
有什么想法吗?谢谢!
我正在使用这个CIS模块arildjensen/cis-puppet
并希望覆盖/etc/profileCIS模块上的文件声明
所以我在这篇文章之后创建了这个新的清单
class profile::hadoop::settings inherits cis {
file { '/etc/profile':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0600',
source => 'puppet:///modules/profile/hadoop/etc/profile',
}
}
Run Code Online (Sandbox Code Playgroud)
但是这仍然会给出错误
Error: Duplicate declaration: File[/etc/profile] is already declared in file /tmp/vagrant-puppet/modules-ab9b45e51a68912cdc576c81d46a2260/profile/manifests/hadoop/settings.pp:9; cannot redeclare at /tmp/vagrant-puppet/modules-ab9b45e51a68912cdc576c81d46a2260/cis/manifests/linuxcontrols/c0076.pp:12 on node server.localdomain
Run Code Online (Sandbox Code Playgroud) 假设我有一个安装packages(profile::base::tools)的类和另一个定义profile::base::yum这些包所需的yumrepos()的类.
tools.pp:
class profile::base::tools {
$packages = [
'package1',
'package2'
]
package { $packages:
ensure => present,
}
}
Run Code Online (Sandbox Code Playgroud)
目前它的运行方式是通过base.pp:
base.pp:
include profile::base::yum
include profile::base::tools
Class['profile::base::yum'] -> [
Class['profile::base::tools']]
Run Code Online (Sandbox Code Playgroud)
所以当我运行base.pp它时首先创建yum repos然后安装包.目前,tools.pp首先要求yumrepos定义的依赖关系仅在提及中提及base.pp.
我的问题是,如果我tools.pp单独运行(出于测试目的),它不会知道依赖性,因此会失败.我可以添加include profile::base::yum在tools.pp类,但想知道如果为每个类标准的了解的依赖,即使它已经在别处定义的(像base.pp)
puppet ×10
automation ×1
bash ×1
centos ×1
chef-infra ×1
cloud ×1
dependencies ×1
facter ×1
java ×1
jclouds ×1
linux ×1
shell ×1
standards ×1
twitter ×1