Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppet - Pass hash as class argument(s)

Tags:

puppet

Trying to do something like this:

# nodes.pp
node 'dev-a-1.sn1.vpc1.example.com' inherits project_j1n_sn1_vpc1_dev {

    class { 'custom::core':
        overrides => {
            'openssh' => {'settings' => {'external_access' => 'true'}}, # Allow direct mounting for dev
            'rsyslog' => {'settings' => {'role' => 'node', 'filters' => {'php' => {'target' => 'remote'}, 'mail' => {'target' => 'remote'}}}}
        }
    }
}

# custom::core
class custom::core($overrides = {}) {

    if (has_key($overrides, 'openssh')) {

        $settings = $overrides['openssh']['settings']

        # Doesn't work
        create_resources('openssh', $settings)

        # Doesn't work
        class { 'openssh': $settings }
    }
}

Is it possible to call a class and pass a hash as the arguments?

Puppet/Puppetmaster v2.7.26-1 (Centos 6.7)

like image 628
Mike Purcell Avatar asked Oct 30 '15 18:10

Mike Purcell


1 Answers

There is a way in Puppet 4+.

class { 'ssh':
  * => $settings
}

Learn all about it on roidelapluie's blog.

like image 197
Felix Frank Avatar answered Nov 15 '22 11:11

Felix Frank