标签: puppet

在Puppet中更改节点声明中的类变量

我正在尝试为我的所有服务器创建一个"模板".我有2个配置.一个NTP客户端(在基类类中处理.我想通过在节点声明中声明特定的东西来创建特定于NTP服务器的覆盖.类似于"baseclass :: ntp:restrict => true".或者或者,我如何从baseclass :: ntp更改已声明的变量之一?

有没有人有任何想法主办这样做?

这是我到目前为止:

templates.pp

class baseclass {
    include defaultusers
    include sudoers
    include issue

    class { ntp:
            ensure => running,
            servers => ['ntpserver1.host.com',
                        'ntpserver2.host.com',],
            autoupdate => false,
    }
}
Run Code Online (Sandbox Code Playgroud)

nodes.pp

node default {
    include baseclass
}

node "ntpserver1.host.com" inherits default {
    <some code here to declare new variable in baseclass::ntp>
    <some code here to change existing variable, such as "ensure">
}
Run Code Online (Sandbox Code Playgroud)

linux puppet

3
推荐指数
1
解决办法
6786
查看次数

如何在Puppet模板中包含子模板

我正在尝试在我的一个Puppet模块的模板中包含一个子模板.以下是我在基本模板中执行include的方法:

<%
  def import(fname)
    erb =
      File.open(File.dirname(__FILE__) + "/" + fname) { |fp| ERB.new(fp.read) }
    erb.run
  end
%>

<%= import("subtemplate.erb") %>
Run Code Online (Sandbox Code Playgroud)

如果我使用erb命令行工具渲染它,这可以正常工作.但是,在Puppet运行期间,将默默忽略导入,即基本模板使用空白行渲染,其中渲染的子模板应该是.没有生成错误.

我究竟做错了什么?谢谢!

erb puppet

3
推荐指数
2
解决办法
5128
查看次数

木偶找不到我刚刚安装的模块

我发现的问题是我可以成功安装Puppet模块。例如:

[puppet@swarmcritic ~]$ puppet module install puppetlabs/mysql
Notice: Preparing to install into /home/puppet/.puppet/modules ...
Notice: Created target directory /home/puppet/.puppet/modules
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/home/puppet/.puppet/modules
??? puppetlabs-mysql (v2.1.0)
  ??? puppetlabs-stdlib (v4.1.0)
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用nodes.pp文件调用模块时,如下所示:

 node 'example.com' {
    include '::mysql::server'
 }
Run Code Online (Sandbox Code Playgroud)

然后我得到这样的错误:

[puppet@example mysql]$ sudo puppet apply ~puppet/puppet/manifests/site.pp
Error: Could not find class ::mysql::server for example.com on node example.com
Error: Could not find class ::mysql::server for example.com on node example.com
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

linux module puppet

3
推荐指数
1
解决办法
4196
查看次数

Puppet:嵌套的hash/dict,数组:如何在erb中访问?

玩木偶,我最终在一个嵌套字典/哈希 - 看起来或多或少像

$settings =
{
  "var1" => 
  {
    "ip" => "0.0.0.0",
    "port" => "1234",
    "option" => ["foo", "bar"],
    "machines" =>
    {
      "maschine-1" => { "ip" => "1.2.3.4", "port" => "1234"},
      "maschine-2" => { "ip" => "1.2.3.5", "port" => "1235"},
    }  
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,我还没有设法在对应的erb模板中正确解析它.

<% @settings.each_pair do |settings_key, settings_value_hash| %>
<%= settings_value_hash['ip']%>:<%= settings_value_hash['port'] %>

option <% @settings_value_hash['option'].each do |option| -%> <%= option  %>   <% end -%>

<% @{settings_value_hash['machines']}.each_pair do |machine_key, machine_value_hash| %>
  server <%= machine_key %>  <%= machine_value_hash['ip'] %>:<%= machine_value_hash['port'] …
Run Code Online (Sandbox Code Playgroud)

ruby arrays dictionary erb puppet

3
推荐指数
1
解决办法
1万
查看次数

如何使用Vagrant,Puppet和Hiera配置时区?

我正在使用PuPHPet作为我的测试环境,它基于Vagrant/Puppet + Hiera.

在config.yml(Hiera配置文件)中,我想为我的时区添加部分

并使用命令 vagrant provision正确设置它.

这可能吗?

puppet vagrant puphpet hiera

3
推荐指数
2
解决办法
4030
查看次数

PuPHPet Vagrant盒子需要apt-get更新吗?

我正在尝试使用PuPHPet流浪汉机器.

除了通过gui提供的东西之外我还没有定制它,但它不想提供 - 我收到以下错误:

如果我进入机器并运行命令然后我得到相同的输出 - 但它可以通过sudo apt-get update在运行命令之前先运行一个来修复- 所以我的问题是如何解决这个问题,以便我可以正确配置?

Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install software-properties-common' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  python3-pycurl python3-software-properties unattended-upgrades
Suggested packages:
  libcurl4-gnutls-dev python3-pycurl-dbg bsd-mailx mail-transport-agent
The following NEW packages will be installed:
  python3-pycurl python3-software-properties software-properties-common
  unattended-upgrades
0 upgraded, 4 newly installed, 0 to remove and 62 not upgraded.
Need to get 102 kB of archives.
After …
Run Code Online (Sandbox Code Playgroud)

ubuntu apt puppet vagrant puphpet

3
推荐指数
1
解决办法
1629
查看次数

如何从源本地构建和安装Puppet模块?

我发现了一个木偶模块,其作者只是添加了一些修改,否则我必须手动完成.

字面上发生在20个小时前.

我已将master分支下载到zip文件,将其解压缩到我的modules文件夹,并运行puppet module build --verbose /etc/puppet/modules/arioch-redis,但无济于事.

我明白这绝对不是正常行为,但我觉得这个问题值得关注.

从源代码中使用模块肯定有一个用例,特别是在快速移动或依赖快速反馈的项目中.

我已就此做了一些研究,请随意问一下,"你有没有看过X"的问题.

例如,我查看了https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#build-your-module,但它似乎主要是为了将模块上传到Forge,而不是从本地安装资源.

另外,我的尝试在" 构建您的模块 "部分失败了.

下面的所有三个似乎用"安装librarian-puppet"来回答这个问题,但考虑到我们可以编写自己的模块,librarian-puppet使用来自公共可用git存储库的源代码来使用简单的代码似乎很愚蠢.模块:

更改木偶模块源(我在寻找的答案,会发生什么情况的OP将会造成这个问题的答案私人回购协议.)

如何使用puppet模块安装从本地仓库安装puppet文件(我的借口:我不需要只使用该puppet module install工具.我也可以使用其他木偶工具.)

直接从克隆的回购中使用puppet模块(我的借口:答案似乎与此问题无关.)

从清单脚本安装puppet模块(我的借口:再次,我认为最适合该问题的最佳答案是"不要使用Puppet,找到解决方法."在这种情况下,解决方法是让Vagrant部分使用Shell Provisioning.)

如果这确实是重复或摘要,请在评论中说明,也许我可以解释一下.编辑欢迎!

我需要破解metadata.json内容吗?

我应该在某个地方克隆这个存储库并将其链接到我自己的临时Forge帐户,还是什么?

摘要:

我怎样才能获得该模块的最新版本,当它在其Git存储库中传递Travis时,但在Forge使其可用之前?

module build puppet

3
推荐指数
1
解决办法
1736
查看次数

仅在先前未执行的情况下使用puppet运行命令

假设我想确保我的虚拟机已经开发了它.

exec{ "openstack":
  command => "git clone https://git.openstack.org/openstack-dev/devstack",
}
Run Code Online (Sandbox Code Playgroud)

这是我为它写的木偶代码,它第一次正常工作.现在我想做个检查.我想只在尚未完成的情况下克隆存储库.怎么做

puppet

3
推荐指数
1
解决办法
488
查看次数

puppet在循环中添加数组元素

我想要这样的东西:

$ssl_domains = ['dev.mydomain.com']

['admin', 'api', 'web'].each |$site| {
  ['tom', 'jeff', 'harry'].each |$developer| {
    $ssl_domains << "$site.$developer.dev.mydomain.com"
  }
}

letsencrypt::certonly { 'dev-cert':
  domains     => $ssl_domains,
  plugin      => 'apache',
  manage_cron => true,
}
Run Code Online (Sandbox Code Playgroud)

现在因为Puppet的变量范围而不可能.如何通过嵌套循环收集数组中的某些变量?

arrays loops puppet

3
推荐指数
1
解决办法
4516
查看次数

安装了Puppet 5,并且Puppet代理-t不应用更改,也没有错误

我在主服务器和服务器上安装了puppet 5,并从代理安装了设置/签名证书...现在我想尝试运行一个简单的代理...

我遵循了也测试Hiera 5的人偶官方文档(下面的链接):https : //docs.puppet.com/puppet/5.0/hiera_quick.html

但是当我运行时,代理永远不会应用更改:

# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for xxxxxx.xxx.xxx
Info: Applying configuration version '1504530655'
Notice: Applied catalog in 0.04 seconds
Run Code Online (Sandbox Code Playgroud)

在主服务器上,当我运行puppet时,应用/[manifest-location]/manifest.pp可以正常工作。

我的主人puppet.conf:

[main]
   server = puppet-master-test.xxx.xxx
   dns_alt_names = puppet-master-test.xxx.xxxx
   certificate_revocation = false
   modulepath = /etc/puppetlabs/code/environments/production/modules

   [master]
   certname = puppet-master-test.xxx.xxx
   vardir = /opt/puppetlabs/server/data/puppetserver
   logdir = /var/log/puppetlabs/puppetserver
   rundir = /var/run/puppetlabs/puppetserver
   pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
   codedir = /etc/puppetlabs/code
   environment_timeout = unlimited
Run Code Online (Sandbox Code Playgroud)

特工的puppet.conf:

[main]
    server = …
Run Code Online (Sandbox Code Playgroud)

puppet

3
推荐指数
1
解决办法
2969
查看次数

标签 统计

puppet ×10

arrays ×2

erb ×2

linux ×2

module ×2

puphpet ×2

vagrant ×2

apt ×1

build ×1

dictionary ×1

hiera ×1

loops ×1

ruby ×1

ubuntu ×1