Ask Your Question

puppet apply and hiera data?

asked 2015-10-27 12:32:56 -0600

Red Cricket gravatar image

I want to test out my puppet code and hiera data. Specifically, I need to see what would the contents of my ceilometer.conf be given a certain set of data in my hiera data.

So I have:

[root@vm-red modules]# tree
├── ceilometer
│   ├── manifests
│   │   └── controller.pp
│   └── templates
│       ├── ceilometer_conf.erb
│       ├── pipeline_yaml.erb
│       ├── policy_json.erb
│       └── sources_json.erb
└── controller
    └── manifests
        └── init.pp

5 directories, 7 files

I copied my hiera data to the /var/lib/hiera/defaults.yaml file. Here's the pertinent parameters used by my controller class:

    [root@vm-red modules]# grep "^ceilometer" /var/lib/hiera/defaults.yaml
    ceilometer_admin_password: "fakepass"
    ceilometer_admin_user: "ceilometer"
    ceilometer_db_host: ""
    ceilometer_db_name: "my_os_ceilo"
    ceilometer_db_pass: "fakepass"
    ceilometer_db_user: "my_os_ceilo"
    ceilometer_os_password: "fakepass"
    ceilometer_os_tenant_name: "services"
    ceilometer_os_username: "ceilometer"
    ceilometer_mongodb_dbname: "%{hiera('ceilometer_db_name')}"
    ceilometer_mongodb_pass: "%{hiera('ceilometer_db_pass')}"
    ceilometer_mongodb_user: "%{hiera('ceilometer_db_user')}"

    [root@vm-red modules]# grep controller::ceilometer /var/lib/hiera/defaults.yaml
    controller::ceilometer_admin_password: "%{hiera('ceilometer_admin_password')}"
    controller::ceilometer_admin_user: "%{hiera('ceilometer_admin_user')}"
    controller::ceilometer_db_host: "%{hiera('ceilometer_db_host')}"
    controller::ceilometer_db_name: "%{hiera('ceilometer_db_name')}"
    controller::ceilometer_db_pass: "%{hiera('ceilometer_db_pass')}"
    controller::ceilometer_db_user: "%{hiera('ceilometer_db_user')}"
    controller::ceilometer_os_auth_url: "https://%{hiera('controller_vip_name')}:35357/v2.0"
    controller::ceilometer_os_password: "%{hiera('ceilometer_os_password')}"
    controller::ceilometer_os_tenant_name: services
    controller::ceilometer_os_username: "%{hiera('ceilometer_mongodb_user')}"

My hiera.yaml is just the default one:

# cat /etc/puppetlabs/puppet/hiera.yaml 
  - yaml
  - defaults
  - "%{clientcert}"
  - "%{environment}"
  - global

# datadir is empty here, so hiera uses its defaults:
# - /var/lib/hiera on *nix
# - %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.

But when I run my puppet apply like so ...

# puppet apply --hiera_config=/etc/puppetlabs/puppet/hiera.yaml --modulepath=`pwd`/modules -e 'include controller'
Notice: Compiled catalog for in environment production in 0.14 seconds
Notice: /Stage[main]/Ceilometer::Controller/File[/tmp/ceilometer.conf]/ensure: defined content as '{md5}eee090956a2ac49c98d49fca222779bd'
Notice: Finished catalog run in 0.24 seconds

the file /tmp/ceilometer.conf does not have any of the hiera data in it!

# head /tmp/ceilometer.conf 
connection = mongodb://:@:27017/

Here's part of the template file I am using:

# cat modules/ceilometer/templates/ceilometer_conf.erb 
connection = mongodb://<%= @ceilometer_db_user %>:<%= @ceilometer_db_pass %>@<%= @mongo_db_host %>:27017/<%= @ceilometer_db_name %>

Could someone point out what I am doing wrong? Is it that puppet apply just does work with hiera?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2015-10-27 12:40:08 -0600

lupin gravatar image

In your manifest how did you retrieve the value of that particular parameters that you interpolate on template?

Did you do a $ceilometer_db_user = hiera('ceilometer_db_user')?

edit flag offensive delete link more


Doh! I took a look at my `controller` class's `init.pp` file and I see I neglected to add the list of parameters. You know all the stuff between `class controller (` and `) {`. Thanks for getting me to the solution. :)

Red Cricket gravatar imageRed Cricket ( 2015-10-27 12:43:47 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-10-27 12:32:56 -0600

Seen: 3,355 times

Last updated: Oct 27 '15