Puppet ユーザーマニフェストは puppetclient に影響を与えます
概要
VirtualBox には 2 つのサーバーがあります。
1)ホスト名: puppetmaster 192.168.100.8
2)ホスト名:pupetclient 192.168.100.9
両方のサーバーで Puppet が実行されています
ubuntuのdocuを使用してインストールしました。
https://translate.google.com/translate?hl=ja&sl=en&tl=ja&u=https://ubuntu.com/server/docs/tools-puppet
サーバーはubuntu 20.04です
pupetclientを実行するとマスターが証明書に気づき、署名しました
サーバーは相互に 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 サーバーには新しいユーザーがいません:(
解決策
その名前とノード宣言が含まれているという事実に基づいて、/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 になりますが、これは存在することさえ表示されません。そのフォルダーを作成し、そのフォルダーに正しいアクセス許可があることを確認し、2 つの site.pp ファイルの内容をそこに移動します。 (おそらく、それらを 1 つのファイルにマージする必要があるでしょう。)