ruby Puppet用户清单对puppetclient有任何影响吗

fcwjkofz  于 2023-10-17  发布在  Ruby
关注(0)|答案(1)|浏览(74)

在VirtualBox上,我有两个服务器:
1)主机名:puppetmaster 192.168.100.8
2)主机名:pupetclient 192.168.100.9
在两个服务器上,
我用Ubuntu的Docu安装了它:
https://ubuntu.com/server/docs/tools-puppet
Ubuntu 20.04
我运行pupetclient和master注意到证书,我签署了它
服务器可以互相ping。
师父:

cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   puppetmaster.example.com    puppetmaster
192.168.100.9   puppetclient.example.com puppetclient

委托方:

cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   puppetclient.example.com    puppetclient
192.168.100.8 puppetmaster.example.com puppetmaster puppet

首先,我创建了一个简单的代码来创建一个用户:

root@puppetmaster:/etc/puppet/code/environments# cd ../../
root@puppetmaster:/etc/puppet# tree
.
|-- auth.conf
|-- code
|   `-- environments
|       `-- production
|           `-- modules
|               |-- mymodule
|               |   |-- files
|               |   |   `-- test.txt
|               |   `-- manifests
|               |       |-- init.pp
|               |       `-- site.pp
|               `-- user
|                   `-- manifests
|                       |-- init.pp
|                       `-- site.pp
|-- hiera.yaml
`-- puppet.conf

cat puppet.conf 
[main]
ssldir = /var/lib/puppet/ssl

[master]
vardir = /var/lib/puppet
cadir  = /var/lib/puppet/ssl/ca
dns_alt_names = puppet

cat code/environments/production/modules/user/manifests/init.pp 
class user {
  user { 'testuser123':
    ensure => present,
    comment => 'bogo user',
    home => '/home/testuser123',
    managehome => true
  }
}

root@puppetmaster:/etc/puppet# cat code/environments/production/modules/user/manifests/site.pp 
node 'puppetclient.example.com' {
  include user
}

sudo puppet apply /etc/puppet/code/environments/production/modules/user/manifests/init.pp 
/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
Notice: Compiled catalog for puppetmaster.example.com in environment production in 0.01 seconds
/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/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0
Notice: Applied catalog in 0.01 seconds
/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:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/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/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0

user@puppetclient:/home$ sudo puppet agent --test
[sudo] password for user: 
/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
Info: Caching catalog for puppetclient.example.com
/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/util.rb:461: warning: URI.escape is obsolete
Info: Applying configuration version '1694262084'
/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/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0
Notice: Applied catalog in 0.01 seconds
/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

它是什么,哪里是错误?puppetclient服务器上没有新用户:(

5jvtdoz2

5jvtdoz21#

错误在哪里?puppetclient服务器上没有新用户

根据它的名称和它包含节点声明的事实,您似乎希望/etc/puppet/code/environments/production/modules/user/manifests/site.pp成为站点清单。它不是一个。也不是/etc/puppet/code/environments/production/modules/mymodule/manifests/site.pp
默认情况下,给定环境(即其站点清单)的目录编译起点是直接驻留在环境本身的manifests/文件夹中的清单文件集合。在您的示例中,这将是/etc/puppet/code/environments/production/manifests,您甚至没有显示它存在。创建该文件夹,确保它具有正确的权限,并将两个site.pp文件的内容移到那里。(您可能希望将它们合并到一个文件中。)

相关问题