using hiera for node classification

312 views
Skip to first unread message

jon

unread,
Jun 18, 2012, 3:18:51 PM6/18/12
to puppet...@googlegroups.com
Hi All,

I've been trying to use Hiera for node classification, my sit.pp is simple:

node default {
  hiera_include("classes")
}

 which has been working well with simple class definitions like:

user@host$ cat testagent.yaml        2012-06-18 14:55:48 jon pts/13
---
classes:
- motd

Is anyone doing this in production?  I've seen a little about this on line but it seems to be mostly toy cases like the above.  If so, is it possible to pass in parameterized classes this way, like:

user@host$ cat openstackall.yaml     2012-06-18 14:56:01 jon pts/13
---
classes:
- openstack::all: { 
  public_address: %{ipaddress_eth0},
  public_interface: eth0,
  private_interface: eth1,
  admin_email: nob...@csail.mit.edu,
  admin_password: admin_password,
  keystone_admin_token: keystone_admin_token,
  nova_user_password: nova_user_password,
  glance_user_password: glance_user_password,
  rabbit_password: rabbit_password,
  rabbit_user: rabbit_user,
  libvirt_type: kvm,
  fixed_range: 10.0.0.0/24 }

The above doesn't work, probably because I'm simply using the wrong structure...

Thanks,
-Jon

ps if you saw this on the -dev list, mea culpa, auto complete misfire reposting here where it belongs....

Nick Fagerlund

unread,
Jun 18, 2012, 4:23:21 PM6/18/12
to puppet...@googlegroups.com


On Monday, June 18, 2012 12:18:51 PM UTC-7, jon wrote:
  If so, is it possible to pass in parameterized classes this way, like:

user@host$ cat openstackall.yaml     2012-06-18 14:56:01 jon pts/13
---
classes:
- openstack::all: { 
  public_address: %{ipaddress_eth0},
  public_interface: eth0,
  private_interface: eth1,
  admin_email: nob...@csail.mit.edu,
  admin_password: admin_password,
  keystone_admin_token: keystone_admin_token,
  nova_user_password: nova_user_password,
  glance_user_password: glance_user_password,
  rabbit_password: rabbit_password,
  rabbit_user: rabbit_user,
  libvirt_type: kvm,
  fixed_range: 10.0.0.0/24 }



Alas, no -- it really is just calling the "include" function, which doesn't handle class parameters.

YOUR OPTIONS:

In puppet 3.0, "include" will automatically do a heira lookup of any class parameters you omit, which means you can give the list of classes to hiera_include and then specify class parameters right below. (like class::parameter1: "value" class::parameter2: "value")

OR

You could use the "create_resources" function to do what you want today. Just have to modify the yaml slightly, because you want a hash of hashes:

---
classes:
  example::test:
    parameter1: value1

  openstack::all:
    public_address: %{ipaddress_eth0}
    public_interface: eth0
    private_interface: eth1
    admin_email: nob...@csail.mit.edu
    admin_password: admin_password
    keystone_admin_token: keystone_admin_token
    nova_user_password: nova_user_password
    glance_user_password: glance_user_password
    rabbit_password: rabbit_password
    rabbit_user: rabbit_user
    libvirt_type: kvm
    fixed_range: 10.0.0.0/24

Then, in your manifest:

create_resources( 'class', hiera('classes') )

See here: http://docs.puppetlabs.com/references/latest/function.html#createresources
Reply all
Reply to author
Forward
0 new messages