Adding debug messages in puppet
Add some debug messages to puppet so we can see what's happening in our manifests.
class debugging {
# for debug output on the puppet master
notice("Running with \$mysql_server_id ${::mysql_server_id} ID defined")
# for debug output on the puppet client
notify {"Running with \$mysql_server_id ${::mysql_server_id} ID defined":}
# for debug output on the puppet client - with full source information
notify {"Running with \$mysql_server_id ${::mysql_server_id} ID defined":
withpath => true,
}
}
Sometimes we need to double-check the value of a fact or variable at a given point or even just output a short message to show what the puppet is doing.
Puppet provides a number of ways to do this and the simplest is by using the notice function if we want the message to appear on the puppet master or the notify type if we want the message displayed on the client. These messages are written to the log when the puppet runs and can also be seen in the output of a debug run.
The addition of the withpath attribute to a notify resource causes it to print the full resource path with the message.
notify { 'Hello': }
#Notice: Hello
notify { 'Hello': withpath => true }
#Notice: /Stage[main]/Main/Notify[Hello World]/message: Hello
The last common variant is using a separate title and message:
class debug_with_path {
notify { 'FqdnTest':
withpath => true,
name => "my fqdn is ${::fqdn}",
}
}
#Notice: /Stage[main]/Not::Base/Notify[FqdnTest]/message: my fqdn is pcbtest.udlabs.private
Relevant Blogs:
Installing package using choco in puppet
Zabbix adding Linux and windows templates
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post