![Puppet 在 icinga2 上使用 puppet-icinga2 模块失败](https://linux22.com/image/674486/Puppet%20%E5%9C%A8%20icinga2%20%E4%B8%8A%E4%BD%BF%E7%94%A8%20puppet-icinga2%20%E6%A8%A1%E5%9D%97%E5%A4%B1%E8%B4%A5.png)
我正在尝试使用 vagrant 为 icinga2 调出一个盒子,我正在使用 puppet-icinga2https://github.com/Icinga/puppet-icinga2/tree/v0.6.2
所以我有一个如下所示的角色
class role::icinga2_server {
class { 'postgresql::server':
ip_mask_deny_postgres_user => '0.0.0.0/32',
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => 'localhost',
postgres_password => 'password',}
postgresql::server::db {
'icinga2_data':
user => 'icinga2',
password => 'password'
}
class { 'icinga2::server':
server_db_type => 'pgsql',
db_host => 'localhost',
db_port => '5432',
db_name => 'icinga2_data',
db_user => 'icinga2',
db_password => 'password',
}
}
因此,当我配置盒子时,我通过 puppet (使用 puppet-postgres 模块)成功安装了 postgres,然后 puppet 抛出了错误
==> centos7: Notice: /Stage[main]/Vagrant/Group[vagrant]/gid: gid changed '1000' to '500'
==> centos7: Debug: /Stage[main]/Vagrant/Group[vagrant]: The container Class[Vagrant] will propagate my refresh event
==> centos7: Debug: Exec[postgres_schema_load](provider=posix): Executing 'su - postgres -c 'export PGPASSWORD='\''password'\'' && psql -U icinga2 -h localhost -d icinga2_data < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt'
==> centos7: Debug: Executing 'su - postgres -c 'export PGPASSWORD='\''password'\'' && psql -U icinga2 -h localhost -d icinga2_data < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt'
==> centos7: Notice: /Stage[main]/Icinga2::Server::Install::Execs/Exec[postgres_schema_load]/returns: psql: could not connect to server: Connection refused
==> centos7: Notice: /Stage[main]/Icinga2::Server::Install::Execs/Exec[postgres_schema_load]/returns: Is the server running on host "localhost" (::1) and accepting
==> centos7: Notice: /Stage[main]/Icinga2::Server::Install::Execs/Exec[postgres_schema_load]/returns: TCP/IP connections on port 5432?
==> centos7: Notice: /Stage[main]/Icinga2::Server::Install::Execs/Exec[postgres_schema_load]/returns: could not connect to server: Connection refused
==> centos7: Notice: /Stage[main]/Icinga2::Server::Install::Execs/Exec[postgres_schema_load]/returns: Is the server running on host "localhost" (192.168.10.131) and accepting
==> centos7: Notice: /Stage[main]/Icinga2::Server::Install::Execs/Exec[postgres_schema_load]/returns: TCP/IP connections on port 5432?
==> centos7: Error: su - postgres -c 'export PGPASSWORD='\''password'\'' && psql -U icinga2 -h localhost -d icinga2_data < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt returned 2 instead of one of [0]
我看到错误提示 psql 无法连接,但当我打开 vagrant box 并 ssh 时,我看到 postgres 已安装并运行正常。我也可以使用 psql 进行连接,但 puppet 无法在 postgres 上创建架构,如调试输出所示。
我也登录并对 postgres 模式加载执行了相同的命令,并且它确实运行良好。
为什么 Puppet 无法加载架构?