我想在 Puppet 上安装/卸载 Windows 服务,但找不到执行此操作的内置函数。我想出了下面的脚本,它运行良好,但很丑陋。
exec{ "install_service" :
command => "${Sys32}\\cmd.exe /c installutil -i /LogFile=\"${logFile}\" \"${sourcePath}\" | exit 0",
path => $Framework4x64,
}
Run Code Online (Sandbox Code Playgroud)
有更好的方法吗?我尝试搜索插件,但尚未找到。
假设我有一种情况,我只需要在某些生产服务器上应用 Puppet 配置中的两个文件,而不需要触及配置的其余部分。
/opt/aservice/myfile/thekey.conf /opt/myfile/thekey.salt
我们还假设这些是由以下 Puppet 清单控制的:
#
# author: Nathan Basanese (nathan@basanese.com)
# date: 04/17/2048
#
class keyconfig ( $cluster ){
notify {"Deploying key config. files to $fqdn":}
file {'/opt/aservice/key/config/thekey.conf':
ensure => present,
mode => '0644',
owner => 'aservice-serv',
group => 'aservice-serv',
source => "puppet:///modules/keyconfig/$cluster/thekey.conf",
}
file {'/opt/aservice/key/config/thekey.salt':
ensure => present,
mode => '0644',
owner => 'aservice-serv',
group => 'aservice-serv',
source => "puppet:///modules/keyconfig/$cluster/thekey.salt",
}
}
Run Code Online (Sandbox Code Playgroud)
我如何从 Puppet Master 仅将这两个文件应用到给定服务器?
也许,在puppet agent目标服务器上运行的命令中,我可以指定要使用的特定 Puppet 类吗?
我以前使用过该puppet resource …
我正在尝试在 rundeck 中运行一个运行“puppet agent -tod”的任务,但是由于 puppet 返回的退出代码为 2,这意味着它应用了一些更改,如https://docs.puppetlabs.com/references /3.4.2/man/agent.html在 --detailed- exitcodes部分,但 rundeck 与 0 不同的所有标记为失败。我可以以某种方式强制显示 0 退出代码而不是 2 吗?
谢谢你们!
我是 puppet 的新手,并计划在我们的环境中实施它。
我有在不同版本的 Redhat 上运行的傀儡代理。
现在,我打算从 puppet master 推送 repo 文件,我需要你的指导来实现它。
我有以下清单。
file { 'local_repo':
ensure => file,
path => '/etc/yum.repos.d/local.repo',
mode => "600",
source => 'puppet:///modules/repo/rhel7.1',
}
file { 'local_repo':
ensure => file,
path => '/etc/yum.repos.d/local.repo',
mode => "600",
source => 'puppet:///modules/repo/rhel6.7',
}
Run Code Online (Sandbox Code Playgroud)
当我执行 Factor CLI 时,我得到以下输出。
[root@dheera ~]# facter os
{
architecture => "x86_64",
family => "RedHat",
hardware => "x86_64",
name => "RedHat",
release => {
full => "7.2",
major => "7",
minor => "2"
}
} …Run Code Online (Sandbox Code Playgroud) 如果您puppet agent -t在代理在后台运行时这样做,那么我们可以看到更改的日志文件在哪里,而不是在 puppet 仪表板上。
我查看了 puppet.conf 并在主要部分看到了logdir,但没有在该位置创建日志文件。
我有以下领事模板。
{{ range service "mysql_slave.mysql" "any" }}
host_name {{.Node}}
command check_nrpe!check_procs_1
{{end}}
Run Code Online (Sandbox Code Playgroud)
我想添加如果我的主机名匹配“database-1”然后命令“check_procs_1”和其他命令“check_procs_2”
输出
host_name node_server
command check_nrpe!check_procs_2
host_name database-1
command check_nrpe!check_procs_1
host_name webserver
command check_nrpe!check_procs_2
Run Code Online (Sandbox Code Playgroud) 我尝试向 /etc/profile 添加三个系统强化行:
TMOUT=43200
readonly TMOUT
export TMOUT
Run Code Online (Sandbox Code Playgroud)
当然,这些行需要按照这个特定的顺序排列,而且我还必须预料到文件会被弄乱并且顺序错误。 我无法使用模板,因为有些主机具有无法更改的自定义配置文件。所以我必须能够附加这三行
所以我在清单中写道:
file_line { 'TMOUT':
path => '/etc/profile',
ensure => present,
line => 'TMOUT=43200',
multiple => true,
before => 'readonly TMOUT',
match => '^TMOUT',
}
file_line { 'readonly TMOUT':
path => '/etc/profile',
ensure => present,
line => 'readonly TMOUT',
multiple => true,
before => 'export TMOUT',
after => '^TMOUT=43200',
match => '^readonly TMOUT',
}
file_line { 'export TMOUT':
path => '/etc/profile',
ensure => present,
line => 'export TMOUT',
multiple => true, …Run Code Online (Sandbox Code Playgroud) 我想使用 Terraform 创建一个 AWS 实例并在其中运行 Puppet 模块。我已经尝试了 github 上的许多模块,但似乎没有任何效果。有人试过这个吗?
我尝试使用工头安装程序与工头一起安装木偶。它使用 ruby 版本 2.0,之后我安装了 r10k,它需要 ruby 版本 >2.3。所以我使用 gems 更新了 ruby,之后我的工头停止了工作。任何解决方案将不胜感激。
我想用 pyyaml 解析与 puppet 相关的 yaml 配置。不幸的是,由于这部分,pyyaml 似乎无法解析某些 YAML 文件:
base::files:
/var/log/fpm:
ensure: 'directory'
mode: '777'
/etc/nginx/ssl/cert:
ensure: 'directory'
/apps:
ensure: 'directory'
owner: user
group: user
['/apps/ecert-public', '/apps/ecert-public/config', '/apps/ecert-public/releases']:
ensure: 'directory'
owner: 'user'
group: 'user'
['/apps/site-public', '/apps/site-public/config', '/apps/site-public/releases']:
ensure: 'directory'
owner: 'user'
group: 'user'
Run Code Online (Sandbox Code Playgroud)
问题是具有多个值的映射(在方括号内)。尝试使用 pyyaml 解析此部分时收到以下错误消息:
在“/hieradata/node/wc-de.yaml”第 133 行第 3 列中构建映射时,在“/hieradata/node/wc-de.yaml”第 212 行第 3 列中发现不可哈希键
一些 YAML 验证器说这是有效的 YAML(例如:http : //www.yamllint.com/),但我尝试过的大多数验证器在解析这部分时也有问题。有谁知道我如何用 pyyaml 解决这个问题?不幸的是我不能改变 YAML 本身,所以我需要一个解决方案来解析它是如何的。