AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[puppet](server)

Martin Hope
Patrick
Asked: 2023-10-23 08:41:46 +0800 CST

在 SNMP 导出器上配置 Prometheus 抓取时出现 Puppet 语法问题

  • 5

一些背景

我有一个 SNMP 导出器作为服务在服务器上运行,它允许我使用以下 URL 访问某些 PDU 的数据:http://my.host.name:9116/snmp?target=10.0.1.200&auth=public_v1&module=apcups

我有一个 Prometheus 服务器,我在同一主机上使用 puppet 配置了该服务器。我想添加一个抓取作业来检索 PDU 提供的信息。

依靠本页上的教程和其他一些来源,我能够确认手动修改文件/etc/prometheus/prometheus.yaml以插入以下内容可以给我带来预期的结果。为了简短起见,我只包含配置文件的相关部分。

- job_name: snmp_scrapper
  scrape_interval: 60s
  scrape_timeout: 10s
  metrics_path: /snmp
  static_configs:
  - targets:
    - my.host.name:9116
  params:
    target: [10.0.1.200]          # IP of the PDU on the private network
    auth: [public_v1]             # authentication method
    module: [apcups]              # module to retrieve APC PDU/UPS information

这完全符合我的预期,我可以在 Prometheus 和 Grafana 等中绘制我的功耗。

我的问题

为了配置 Puppet 来生成上面的 prometheus 配置,我在配置了 prometheus 的配置文件中添加了以下作业(我还有另一项作业在许多主机上抓取 node_exporter,我可以从中获得灵感):

        {
          'job_name'        => 'snmp_scrapper',
          'scrape_interval' => '60s',
          'scrape_timeout'  => '10s',
          'metrics_path'    => '/snmp',
          'static_configs'  => [{ 'targets' => ['my.host.name:9116'], }],
          'params' => {
            'target' => '[10.0.1.200]',
            'auth' => '[public_v1]',
            'module' => '[apcups]',
          }
        },

问题是这会产生prometheus.yaml下面的错误文件,其中metrics_path和 的三个元素周围有额外的引号params。

 - job_name: snmp_scrapper
   scrape_interval: 60s
   scrape_timeout: 10s
   metrics_path: "/snmp"
   static_configs:
   - targets:
     - my.host.name:9116
   params:
     target: "[10.0.1.200]"
     auth: "[public_v1]"
     module: "[apcups]"

Prometheus 的配置解析器失败并出现以下错误:

  FAILED: parsing YAML file /etc/prometheus/prometheus.yaml20231023-1016214-j3iqrx: yaml: unmarshal errors:
  line 47: cannot unmarshal !!str `[10.0.1...` into []string
  line 48: cannot unmarshal !!str `[public...` into []string
  line 49: cannot unmarshal !!str `[apcups]` into []string

天真地,我认为删除参数/snmp中方括号周围的引号可以解决我的问题,即:

          'job_name'        => 'snmp_scrapper',
          'scrape_interval' => '60s',
          'scrape_timeout'  => '10s',
          'metrics_path'    => /snmp,
          'static_configs'  => [{ 'targets' => ['my.host.name:9116'], }],
          'params' => {
            'target' => [10.0.1.200],
            'auth' => [public_v1],
            'module' => [apcups],

但这会导致 Puppet 语法错误。

我的问题

如何通过 Puppet 获得/etc/prometheus/prometheus.yaml此问题顶部所需的显示?我的猜测是一定有某种语法允许生成不带引号的文本字符串,但我不知道如何。

我正在使用 Puppet 版本 8.2.0 和puppet/prometheus v13.3.0 模块。

puppet
  • 1 个回答
  • 82 Views
Martin Hope
Wildcard
Asked: 2023-10-19 01:39:24 +0800 CST

如何修复 ifupdown2 的 puppet 安装以便网络恢复(或不中断)?

  • 5

我有傀儡代码,它会自动在新配置的物理服务器上安装 ifupdown2 (以及所有其他新主机配置)。(这是 Debian 11 Bullseye。)

但是,安装此软件包后应用的几乎所有配置都会失败,因为安装 ifupdown2 时网络会中断,因此无法从 puppet 服务器或 apt 存储库等下载文件。

不仅如此,Puppet 也无法从中恢复过来。该盒子必须在带外(即控制台、ipmi 等)进行处理,ifup -a或者重新启动,以便网络恢复。

我发现这是 ifupdown2 安装的一个已知问题:https://www.mail-archive.com/ [email protected] /msg1703008.html

那里的建议是:

对于像 ansible、puppet 等配置系统,我建议您将其设置为将脚本推送到节点,该节点基本上执行相当于使用 nohup 或其他方式执行“apt-get install ifupdown2 && systemctl restartnetworking”的操作如果网络本身出现故障,则会失败。

我当前的相关木偶节只是:

    package { "ifupdown2":
      ensure => 'latest',
    }

我应该如何解决这个问题,以便木偶配置的其余部分能够正确应用,即网络将作为应用该资源的一部分出现?

puppet
  • 1 个回答
  • 42 Views
Martin Hope
Christian
Asked: 2022-09-01 00:28:16 +0800 CST

puppet 7:File.content 中的延迟值不可能?

  • 0

我正在尝试在 puppet 7(服务器 7.4.2 和代理 7.14.0)中使用延迟值来编写文件,如下所示:

  file { "/tmp/testfile":
    ensure => 'present',
    content => Deferred("node_decrypt", [node_encrypt("abc")]),
  }

但是在编译目录时,服务器会打印

Puppet File[/tmp/testfile]['content'] contains a Deferred value. It will be converted to the String 'Deferred({'name' => 'node_decrypt', 'arguments' => ["-...

该文件的效果是它包含文本“Deferred(...”而不是“abc”。

同样适用于 Notify.message。我是否配置错误?或任何线索为什么这对 File.content 不起作用/不应该起作用。如果是,将延迟值写入文件的替代方法是什么?

puppet
  • 1 个回答
  • 35 Views
Martin Hope
Jorge Mauricio
Asked: 2022-02-28 14:28:23 +0800 CST

用于 docker 镜像验证的 Puppet manifest 配置

  • 1

我对 devops/ci/cd 很陌生,所以请耐心等待。

目前,我正在为 docker 图像验证设置一个 puppet manifest 配置。让我尝试布局它:

我有一个具有以下配置的 puppet master 服务器:

  • Puppetmaster 版本:5.5.10-4ubuntu3
  • 两台服务器都是linux 20.04
  • 全部托管在 AWS 上

/etc/puppet/code/environments/production/manifests/site.pp

node default {
    include 'docker'
    docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }
}

每次在 .pp 中尝试新的验证命令时,我都会使用以下命令重新启动 puppet master 服务器:sudo systemctl restart puppet-master

我在我的两台服务器(代理和主服务器)上都安装了一个名为 garethr-docker 的模块。

在从/代理服务器上,我有这个镜像 docker 镜像存在并正在运行:jorgemauriciodev/ubuntu-dockerfile-dev-v1 第一步,我只想检查我的从属服务器中是否存在该镜像。稍后,我将确定它正在运行或使用 Dockerfile 构建。

在从/代理服务器上,我运行:sudo puppet agent –test

我收到以下错误消息:

错误:无法从远程服务器检索目录:服务器上的错误 500:服务器错误:评估错误:评估函数调用时出错,找不到类 ::docker 用于 ip-123-123-123-123.us-east- 2.compute.internal(文件:/etc/puppet/code/environments/production/manifests/site.pp,行:2,列:5)在节点 ip-123-123-123-123.us-east-2 .compute.internal 警告:未在失败的目录上使用缓存错误:无法检索目录;跳过跑步

有人知道我对 puppet 清单文件有什么问题吗?

编辑1:

我做了一些建议的更改。现在,我的文件有一个不同的名称并更改了内容:/etc/puppet/code/environments/production/manifests/init.pp

include 'docker'
class { 'docker':
  version => 'latest',
}
docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }

仍然返回相同的错误消息。

这是完整的消息:

/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Retrieving plugin
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Retrieving locales
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::docker for ip-172-31-21-116.us-east-2.compute.internal (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 1, column: 1) on node ip-172-31-21-116.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
/usr/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0

编辑2:

我使用以下命令在主服务器和从/代理服务器上安装了更多模块:

sudo puppet module install puppetlabs-docker --version 4.1.2

它仍然向我返回一条错误消息,但现在似乎它是一个不同的消息。所以,现在可能是一个语法问题。

这是消息的重要部分。

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Class[Docker] is already declared; cannot redeclare (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 3) (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 3, column: 1) on node ip-123-123-123-123.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

除了这条消息,它仍然向我返回那些警告,但列表要大得多。但是,我认为目前这不是问题。

ubuntu puppet devops puppetmaster puppet-agent
  • 1 个回答
  • 103 Views
Martin Hope
hymie
Asked: 2021-10-13 05:45:32 +0800 CST

Puppet/Augeas -- ins 命令在 RH6 上工作,在 RH7 上失败

  • 0

我在我的 puppet 模块中有这个构造,可以在/etc/sudoers最后一个“默认”行之后添加一行:

  augeas { "sudoers.ssh_auth_sock" :
    lens => "Sudoers.lns",
    incl => "/etc/sudoers",
    onlyif  => "match Defaults/env_keep/var[. = 'SSH_AUTH_SOCK'] size==0",
    changes => [
       # Create a new Defaults line for the two variables
       "ins Defaults after Defaults[last()]",
       # Make this Defaults line a += type
       "clear Defaults[last()]/env_keep/append",
       # assign values to the two variables
       "set Defaults[last()]/env_keep/var[1] SSH_AUTH_SOCK",
    ],
  }

它在我的 RedHat 6 机器上完美运行

Notice: Augeas[sudoers.ssh_auth_sock](provider=augeas):
--- /etc/sudoers        2021-10-12 13:30:52.880901115 +0000
+++ /etc/sudoers.augnew 2021-10-12 13:31:28.697931561 +0000
@@ -77,6 +77,7 @@
 # Defaults   env_keep += "HOME"

 Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
+Defaults env_keep += SSH_AUTH_SOCK

 ## Next comes the main part: which users can run what software on

Notice: /Stage[main]/Sudoers/Augeas[sudoers.ssh_auth_sock]/returns: executed successfully

但它在我的 RedHat 7 机器上失败了:

Warning: Augeas[sudoers.ssh_auth_sock](provider=augeas): Loading failed for one or more files, see debug for /augeas//error output
Error: /Stage[main]/Sudoers/Augeas[sudoers.ssh_auth_sock]: Could not evaluate: Error sending command 'ins' with params ["Defaults", "after", "/files/etc/sudoers/Defaults[last()]"]/Error sending command 'ins' with params ["Defaults", "after", "/files/etc/sudoers/Defaults[last()]"]

有人可以帮助我了解发生了什么变化,或者我做错了什么,以便我可以让这个代码段在两种环境中都可以工作吗?

redhat puppet augeas
  • 1 个回答
  • 63 Views
Martin Hope
Tombart
Asked: 2021-10-01 00:48:22 +0800 CST

如何为(辅助)编译 puppetserver 生成证书?

  • 0

我正在尝试使用循环 DNS 来扩展 puppetserver,以获得冗余。次要puppetserver(版本7.4.0)配置为使用来自主要的 CA 权限puppetserver:

/etc/puppetlabs/puppet/puppet.conf:

[main]
ca_name = Puppet CA: puppet-ca-master.company.com
ca_server = puppet-ca-master.company.com
[agent]
server = puppet-ca-master.company.com
runinterval=1800

在辅助服务器上,我禁用了 CA 服务,因为在以下位置可能只有一个证书颁发机构/etc/puppetlabs/puppetserver/services.d/ca.cfg:

# To enable the CA service, leave the following line uncommented
# puppetlabs.services.ca.certificate-authority-service/certificate-authority-service
# To disable the CA service, comment out the above line and uncomment the line below
puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service
puppetlabs.trapperkeeper.services.watcher.filesystem-watch-service/filesystem-watch-service

我已经从辅助服务器中删除了证书,以便从 CA 主服务器获取证书签名证书:

rm -rf /etc/puppetlabs/puppet/ssl && mkdir -p /etc/puppetlabs/puppet/ssl/certs
chmod 0700 /etc/puppetlabs/puppet/ssl
chown -R puppet /etc/puppetlabs/puppet/ssl

但是,puppetserver由于缺少证书,服务拒绝启动:

2021-09-30T09:06:18.220+02:00 ERROR [async-dispatch-2] [p.t.internal] Error during service start!!!
java.lang.IllegalArgumentException: Unable to open 'ssl-cert' file: /etc/puppetlabs/puppet/ssl/certs/secondary-puppetserver.company.com.pem

当我尝试puppet agent -t在辅助 puppetserver 上运行时,它无法签署证书:

Couldn't fetch certificate from CA server; you might still need to sign this agent's certificate (secondary-puppetserver.company.com)

此外,会生成私钥,但不会生成公钥:

ll /etc/puppetlabs/puppet/ssl/public_keys/
total 0
puppet ssl-certificate puppetmaster
  • 1 个回答
  • 387 Views
Martin Hope
bdetweiler
Asked: 2021-07-14 12:39:47 +0800 CST

Puppet - 我可以选择性地通知服务吗?

  • 0

我有一个 Puppet 脚本,可以根据if/else块在不同环境中以不同方式处理事情。但是我在底部有一堆适用于所有环境的通用文件资源块。目前,那些块notify => Service['my-service'],但对于生产,我希望它不通知。我只希望它更新文件,而不是启动或停止任何服务。

我最初的想法是,我可以将服务存储到一个变量中并在每个部分中设置它吗?

例子:

if ($env == 'dev') {
  $myService = Service['my-service']
} elsif ($env == 'prod') {
  $myService = Service['dummy-service']
}

file { "myfile.xml":
      ensure  => file,
      content =>
        template("mytemplate.erb"),
      require => Package['my-service'],
      notify  => $myService
}

我不确定这是否有效,但如果有效,我可以将什么用于虚拟服务?

puppet puppet-agent erb
  • 1 个回答
  • 320 Views
Martin Hope
Taz
Asked: 2020-07-13 22:55:55 +0800 CST

Puppetserver 无法找到宝石

  • 2

我正在尝试使用一个添加 AWS Secrets Manager hiera 后端的模块:

https://forge.puppet.com/accenture/hiera_aws_sm

这个模块需要我通过 puppetserver 安装的aws-sdk-secretsmanager gem:

$ sudo puppetserver gem install aws-sdk-secretsmanager

我还可以在 puppetserver 中看到这个 gem:

$ sudo puppetserver gem list

*** LOCAL GEMS ***

<trimmed>
aws-sdk-schemas (1.6.0)
aws-sdk-secretsmanager (1.40.0, 1.39.0)
aws-sdk-securityhub (1.29.0)
<trimmed>

模块本身包含以下行来导入 gem:

require 'aws-sdk-secretsmanager'

当我尝试运行代理测试时...

$ sudo puppet agent --test

...当此模块尝试运行时,我收到以下错误(在注释掉模块添加的一些错误处理混淆之后):

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Internal Server Error: org.jruby.exceptions.LoadError: (LoadError) no such file to load -- aws-sdk-secretsmanager

我无法弄清楚为什么 puppetserver jruby 实例无法加载 gem,因为它出现在列表中并且在调试它时遇到了一些问题。

puppet rubygems
  • 1 个回答
  • 290 Views
Martin Hope
logicaldiagram
Asked: 2020-07-11 05:11:40 +0800 CST

如何控制在 Windows 上运行哪个版本的 Powershell Puppet?

  • 1

Microsoft 最近更改了他们的 Windows Powershell 下载存储库以要求 TLS 1.2+,如果没有运行时设置更改为Net.ServicePointManager.

我可以更改 Puppet 以使用 Pwsh (7.x) 作为默认值,还是可以更改一些 Puppet 代码以将Net.ServicePointManager代码段注入到配置的 5.1 以在所有 Puppet 启动的 Windows Powershell 会话中支持 TLS 1.2?

我试图解决的根本问题是失败并出现与此类package似的错误。

windows powershell puppet
  • 2 个回答
  • 102 Views
Martin Hope
PopSpe
Asked: 2020-05-18 09:22:32 +0800 CST

DRBD 单主忽略文件类型

  • 0

是否可以为文件类型(甚至可能是特定文件)提供排除列表,以便它们不会尝试与辅助节点同步?我查看了 DRBD 配置文件,但找不到任何关于它的信息。如果没有,是否还有另一个允许排除的主->从同步系统?

为什么我要问:
尝试从单个服务器迁移到负载平衡器基础架构后面的集群。我想使服务器的操作/配置文件保持同步。有一些日志文件与相应的操作/配置文件写入相同的目录中。

最优目标:
当主服务器(主)有相关文件更新时,从(从)服务器文件同步。

我知道我可以重构代码,但我真的很想避免这种情况。

可能相关信息:
AWS ec2 服务器 AWS 负载均衡器 AWS NFS (EFS) 已尝试,但性能损失太大。也无法让詹金斯完成目标。考虑为主服务器设置一个 Git 存储库,在从服务器上克隆存储库,然后在提交时添加触发器。没有更好的解决方案吗?还没有完全看过 Puppet 可以选择吗?也许是 Corosync?如果您也可以向我指出良好的使用文档,那就太好了。

synchronization puppet drbd corosync
  • 1 个回答
  • 62 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve