Forge Home

xmlsimple

Functions to convert back and forth between XML and Hashes

10,096 downloads

10,096 latest version

3.9 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.0.1 (latest)
released Nov 25th 2013

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'glarizza-xmlsimple', '0.0.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add glarizza-xmlsimple
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install glarizza-xmlsimple --version 0.0.1

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

glarizza/xmlsimple — version 0.0.1 Nov 25th 2013

XmlSimple Puppet Functions

These Puppet functions will convert a hash into an XML string that can be saved as the contents of a file. There is also a function that will accept an argument of a path to an XML document and return a native Hash. Hopefully these are useful to some people out there. Check out the tests/ directory for Puppet manifests demonstrating their usage:

Converting an XML document to a Hash

$xml = '/tmp/sample.xml'
$hash_data = xml_to_hash($xml)

Converting a Hash to an XML document

$hash = {
  'logdir'        => '/var/log/foo/',
    'debugfile'     => '/tmp/foo.debug',
    'server'        => {
      'sahara'        => {
        'osversion'     => '2.6',
        'osname'        => 'solaris',
        'address'       => [ '10.0.0.101', '10.0.1.101' ]
      },
      'gobi'          => {
        'osversion'     => '6.5',
        'osname'        => 'irix',
        'address'       => [ '10.0.0.102' ]
      },
      'kalahari'      => {
        'osversion'     => '2.0.34',
        'osname'        => 'linux',
        'address'       => [ '10.0.0.103', '10.0.1.103' ]
      }
    }
}

$xml_data = hash_to_xml($hash)

file { '/tmp/sample.xml':
  ensure  => file,
  content => $xml_data
}