So many times we are confused with class dependancies. Puppet Graphs can help us to see those dependencies.

On a Puppet node

This on is running CentOS 7.3 :

[root@centos73 ~]# facter os
{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "CentOS",
  release => {
    full => "7.3.1611",
    major => "7",
    minor => "3"
  },
  selinux => {
    config_mode => "enforcing",
    current_mode => "enforcing",
    enabled => true,
    enforced => true,
    policy_version => "28"
  }
}

On any server

Install “graphviz” utility (somewhere, here on the Puppet node) :

[root@centos73 ~]# yum -y install graphviz

Puppet node configuration

Create a directory to contain graph files :

[root@centos73 ~]# mkdir -p /var/log/puppetlabs/puppet/graphs

Add “graph” instruction in “puppet.conf” Puppet node configuration file :

[root@centos73 ~]# cat $(puppet config print config)
[agent]
server = puppetserver.argonay.wou
graph = true
graphdir = /var/log/puppetlabs/puppet/graphs

Launch “puppet agent” :

[root@centos73 ~]# puppet agent -tv

You will get ” *.dot” files in “/var/log/puppetlabs/puppet/graphs” directory :

[root@centos73 ~]# ls -1 /var/log/puppetlabs/puppet/graphs
expanded_relationships.dot
relationships.dot
resources.dot

Conversion to “png” files

Try to convert “*.dot” files to “*.png” files :

[root@centos73 ~]# dot -Tpng /var/log/puppetlabs/puppet/graphs/expanded_relationships.dot -o /tmp/resources.png
Warning: /var/log/puppetlabs/puppet/graphs/expanded_relationships.dot: syntax error in line 3 near ':'

You may experience this issue, the Puppet output file is not fully compatible !!!

Don’t panic, here what is wrong :

[root@centos73 ~]# sed -e "3p;d" /var/log/puppetlabs/puppet/graphs/expanded_relationships.dot
    "Notify[we are executing "easy::my_manifest" class]" [

Use your favorite editor (e.g. “vi”) to replace ” by \” :

[root@centos73 ~]# sed -e "3p;d" /var/log/puppetlabs/puppet/graphs/expanded_relationships.dot
    "Notify[we are executing \"easy::my_manifest\" class]" [

You can now play the conversion :

[root@centos73 ~]# dot -Tpng /var/log/puppetlabs/puppet/graphs/expanded_relationships.dot -o /tmp/resources.png

Here the image you get :

 

 

 

 

 

 

 

 

 

 

You don’t want to install “graphviz”, no problem, do it online :¬†graphviz online

 

PDF24    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *


*