Puppet allows you to generate .dot files that show the resources and relationships present in the manifest files that you have. To generate these .dot files without actually applying the manifest files, perform the following command:

puppet apply /path/to/manifest.pp --noop --graph

This will place three .dot files in the output directory for graphs, by default this is /var/lib/puppet/state/graphs on CentOS and Ubuntu. You can use the GraphViz suite to convert these .dot files into e.g. .png files. First, install the GraphViz suite:

#CentOS:
yum -y install graphviz

#Ubuntu:
sudo apt-get -y install graphviz

Now we can generate the .png files:

dot -Tpng /var/lib/puppet/state/graphs/resources.dot -o /tmp/resources.png
dot -Tpng /var/lib/puppet/state/graphs/relationships.dot -o /tmp/relationships.png
dot -Tpng /var/lib/puppet/state/graphs/expanded_relationships.dot -o /tmp/expanded_relationships.png

Now open the .png files with your favorite image viewer. You may also want to take a look at the Gephi program to display the .dot files directly.

As an example, we may have a module that installs the NTP daemon:

class ntp {

  package { 'ntp':
    ensure => installed,
  }

  service { 'ntp':
    ensure  => running,
    enable  => true,
    require => Package['ntp'],
  }

  file { '/etc/ntp.conf':
    source => 'puppet:///modules/ntp/ntp.conf',
    notify => Service['ntp'],
  }
}

And a site.pp file which says that by default servers should use this module:

node default {
  include ntp
}

Then the resulting graphs would look like this (figures edited to make them smaller):


Resources
puppet_resources


Relationships
puppet_relationships


Expanded relationships
puppet_expanded_relationships


Visualizing Puppet manifest resources and relationships
Tagged on:     

2 thoughts on “Visualizing Puppet manifest resources and relationships

Leave a Reply

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