Here are trial and error logs when installing puppet modules and applying the module to agent nodes.
master: master.example.com
agent: agent01.example.com
install puppet modules on the master. ( not agent nodes )
To use puppet modules, there are two options.
download existing puppet modules from Puppet forge http://forge.puppetlabs.com/ or write puppet modules yourself.
[ download puppet modules from Puppet forge ]
install puppetlabs-motd module. this module displays contents of /etc/motd file.
to search modules, issue “puppet module search <keyword>” on the master
[root@master ~]# puppet module search motd
Notice: Searching https://forge.puppetlabs.com ...
NAME DESCRIPTION AUTHOR KEYWORDS
alkivi-motd Controls motd file on unix sy... @alkivi motd
attachmentgenie-motd Puppet motd Mo... @attachmentgenie motd
boogy-motd Motd Mo... @boogy motd
chris3-my_motd Just my motd module, do not use... @chris3
dhoppe-motd MOTD Mo... @dhoppe motd
gdsoperations-updatemotd Manage update-motd(5) on Ubuntu sys... @gdsoperations motd
jeffmccune-motd Manages the message of the... @jeffmccune motd
kreczko-motd A simple module to demonstrate managing /etc/motd as a temp... @kreczko
puppetlabs-motd A simple module to demonstrate managing /etc/motd as a temp... @puppetlabs
rcoleman-motd Manages the message of the... @rcoleman
saz-motd UNK... @saz motd
thias-cosmetic Cosmetic changes mo... @thias motd
|
search openstack-related puppet modules,
[root@master ~]# puppet module search openstack
Notice: Searching https://forge.puppetlabs.com ...
NAME DESCRIPTION AUTHOR KEYWORDS
davidcollom-raxmonitoragent Rackspace Server Monitor... @davidcollom openstack
ekarlso-quantum Puppet module for OpenStac... @ekarlso openstack
<snip>
|
Let’s install puppetlats-motd module.
on the master,
as for motd module, there is one class “motd”.
[root@master ~]# puppet module install puppetlabs/motd
Notice: Preparing to install into /etc/puppetlabs/puppet/modules ...
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/puppet/modules
└── puppetlabs-motd (v1.0.1)
[root@master ~]#
[root@master ~]# ls /etc/puppetlabs/puppet/modules/motd/
files manifests Modulefile spec tests
lib metadata.json README templates
[root@master ~]# cat /etc/puppetlabs/puppet/modules/motd/manifests/init.pp
# Class: motd
#
# This module manages the /etc/motd file using a template
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
# include motd
#
# [Remember: No empty lines between comments and class definition]
class motd {
if $kernel == "Linux" {
file { '/etc/motd':
ensure => file,
backup => false,
content => template("motd/motd.erb"),
}
}
}
|
add motd class
on the master,
PE console -> Classes -> add new classes
select motd class and click “add selected classes”
add class “motd” to the agent01.example.com
Nodes -> node name ( in this case, agent01 ) -> Edit
add class “motd” and click “Update”
trigger a puppet on both master and agent01.
PE console -> Live management -> control puppet -> runonce ( select both master and agent01 ) -> Run
This will configure the nodes using the newly-assigned classes. Wait one or two minutes.
on the agent01, check syslog ( /var/log/messages )
nnn, error..
Dec 8 02:00:47 agent01 puppet-agent[1122]: Caught USR1; calling reload
Dec 8 02:00:53 agent01 puppet-agent[8721]: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template motd/motd.erb:
Dec 8 02:00:53 agent01 puppet-agent[8721]: Filepath: /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/templatewrapper.rb
Dec 8 02:00:53 agent01 puppet-agent[8721]: Line: 81
Dec 8 02:00:53 agent01 puppet-agent[8721]: Detail: Could not find value for 'domain' at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:3
Dec 8 02:00:53 agent01 puppet-agent[8721]: at /etc/puppetlabs/puppet/modules/motd/manifests/init.pp:20 on node agent01
Dec 8 02:00:54 agent01 puppet-agent[8721]: Using cached catalog
Dec 8 02:01:02 agent01 puppet-agent[8721]: Finished catalog run in 8.49 seconds
|
master’s syslog
Dec 8 02:05:02 master puppet-agent[1631]: Caught USR1; calling reload
Dec 8 02:05:05 master puppet-master[19808]: Could not retrieve fact fqdn
Dec 8 02:05:07 master puppet-master[19636]: Could not retrieve fact fqdn
Dec 8 02:05:07 master puppet-master[19808]: Host is missing hostname and/or domain: agent01
Dec 8 02:05:08 master puppet-master[19636]: Host is missing hostname and/or domain: master
Dec 8 02:05:09 master puppet-master[19808]: Variable access via 'operatingsystem' is deprecated. Use '@operatingsystem' instead. template[/etc/puppetlabs/puppet/modules/motd/templates/motd.erb]:1
Dec 8 02:05:09 master puppet-master[19808]: (at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:1:in `block in result')
Dec 8 02:05:09 master puppet-master[19808]: Variable access via 'memoryfree' is deprecated. Use '@memoryfree' instead. template[/etc/puppetlabs/puppet/modules/motd/templates/motd.erb]:2
Dec 8 02:05:09 master puppet-master[19808]: (at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:2:in `block in result')
Dec 8 02:05:09 master puppet-master[19808]: Failed to parse template motd/motd.erb:
Dec 8 02:05:09 master puppet-master[19808]: Filepath: /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/templatewrapper.rb
Dec 8 02:05:09 master puppet-master[19808]: Line: 81
Dec 8 02:05:09 master puppet-master[19808]: Detail: Could not find value for 'domain' at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:3
Dec 8 02:05:09 master puppet-master[19808]: at /etc/puppetlabs/puppet/modules/motd/manifests/init.pp:20 on node agent01
Dec 8 02:05:09 master puppet-master[19808]: Failed to parse template motd/motd.erb:
Dec 8 02:05:09 master puppet-master[19808]: Filepath: /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/templatewrapper.rb
Dec 8 02:05:09 master puppet-master[19808]: Line: 81
Dec 8 02:05:09 master puppet-master[19808]: Detail: Could not find value for 'domain' at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:3
Dec 8 02:05:09 master puppet-master[19808]: at /etc/puppetlabs/puppet/modules/motd/manifests/init.pp:20 on node agent01
Dec 8 02:05:09 master puppet-master[19808]: Failed to parse template motd/motd.erb:
Dec 8 02:05:09 master puppet-master[19808]: Filepath: /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/templatewrapper.rb
Dec 8 02:05:09 master puppet-master[19808]: Line: 81
Dec 8 02:05:09 master puppet-master[19808]: Detail: Could not find value for 'domain' at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:3
Dec 8 02:05:09 master puppet-master[19808]: at /etc/puppetlabs/puppet/modules/motd/manifests/init.pp:20 on node agent01
|
Seen from the log, the problem seems to be caused by hostname or domain name configuration.
on the master
[root@master ~]# hostname
master.example.com
[root@master ~]# hostname --fqdn
master
[root@master ~]# hostname --domain
[root@master ~]# domainname
(none)
[root@master ~]# cat /etc/hosts
192.168.11.123 master master.example.com
192.168.11.124 agent01 agent01.example.com
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@master ~]#
[root@master ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=master.example.com
[root@master ~]#
[root@master ~]# cat /etc/host.conf
multi on
[root@master ~]#
[root@master ~]# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
[root@master ~]# cat /etc/puppetlabs/puppet/puppet.conf
[main]
certname = master
dns_alt_names = master,puppet
vardir = /var/opt/lib/pe-puppet
logdir = /var/log/pe-puppet
rundir = /var/run/pe-puppet
modulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
server = master
user = pe-puppet
group = pe-puppet
archive_files = true
archive_file_server = master
[master]
certname = master
ca_name = 'Puppet CA generated on master at 2013-12-05 01:59:42 +0900'
reports = http,puppetdb
reporturl = https://localhost:443/reports/upload
node_terminus = exec
external_nodes = /etc/puppetlabs/puppet-dashboard/external_node
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
storeconfigs_backend = puppetdb
storeconfigs = true
[agent]
report = true
classfile = $vardir/classes.txt
localconfig = $vardir/localconfig
graph = true
pluginsync = true
environment = production
[root@master ~]#
|
on the agent01
[root@agent01 ~]# hostname
agent01.example.com
[root@agent01 ~]# hostname --fqdn
agent01
[root@agent01 ~]# hostname --domain
[root@agent01 ~]#
[root@agent01 ~]# cat /etc/hosts
192.168.11.123 master master.example.com
192.168.11.124 agent01 agent01.example.com
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@agent01 ~]#
[root@agent01 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=agent01.example.com
[root@agent01 ~]#
[root@agent01 ~]# cat /etc/host.conf
multi on
[root@agent01 ~]# domainname
(none)
[root@agent01 ~]#
[root@agent01 ~]#
[root@agent01 ~]# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
[root@agent01 ~]# cat /etc/puppetlabs/puppet/puppet.conf
[main]
certname = agent01
vardir = /var/opt/lib/pe-puppet
logdir = /var/log/pe-puppet
rundir = /var/run/pe-puppet
modulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
server = master
user = pe-puppet
group = pe-puppet
archive_files = true
archive_file_server = master
[agent]
report = true
classfile = $vardir/classes.txt
localconfig = $vardir/localconfig
graph = true
pluginsync = true
environment = production
[root@agent01 ~]#
|
Googling this error, the following post could help solve this..
edit /etc/resolv.conf on both the master and agent01.
on the master
[root@master ~]# cat /etc/resolv.conf
domain example.com <- add this
nameserver 8.8.8.8
nameserver 8.8.4.4
|
on the agent01
[root@agent01 ~]# cat /etc/resolv.conf
domain example.com <- add this
nameserver 8.8.8.8
nameserver 8.8.4.4
|
do the following again.
trigger a puppet on both master and agent01.
PE console -> Live management -> control puppet -> runonce ( select both master and agent01 ) -> Run
logs on the master
Dec 11 23:14:06 master puppet-agent[1714]: Caught USR1; calling reload
Dec 11 23:14:15 master puppet-master[1764]: Variable access via 'domain' is deprecated. Use '@domain' instead. template[/etc/puppetlabs/puppet/modules/motd/templates/motd.erb]:3
Dec 11 23:14:15 master puppet-master[1764]: (at /etc/puppetlabs/puppet/modules/motd/templates/motd.erb:3:in `block in result')
Dec 11 23:14:15 master puppet-master[1764]: Compiled catalog for agent01 in environment production in 1.27 seconds
Dec 11 23:14:29 master puppet-master[1764]: Compiled catalog for master in environment production in 10.73 seconds
Dec 11 23:14:58 master puppet-agent[2872]: Finished catalog run in 18.58 secon
|
logs on the agent01
Dec 11 23:14:05 agent01 puppet-agent[1142]: Caught USR1; calling reload
Dec 11 23:14:16 agent01 puppet-agent[1462]: (/Stage[main]/Motd/File[/etc/motd]/content) content changed '{md5}d41d8cd98f00b204e9800998ecf8427e' to '{md5}02d261d753f3b3456738257139b5e469'
Dec 11 23:14:17 agent01 puppet-agent[1462]: Finished catalog run in 1.38 seconds
|
Events logs.
I was able to apply motd class to agent01 box.
on the agent node
You can see some messages in /etc/motd file, because motd class was applied to this agent.
[root@agent01 ~]# cat /etc/motd
The operating system is CentOS
The free memory is 322.03 MB
The domain is example.com
|
on the master, there are no messages in /etc/motd, because I have not applied motd class to this box.
[root@master ~]# cat /etc/motd
[root@master ~]#
|
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.