Ask Your Question

Sharing hiera across multiple environments

asked 2016-10-07 01:30:38 -0600

Tomasz Olszewski gravatar image

updated 2016-10-07 01:35:53 -0600


How do you share common hiera values across multiple environments (e.g. staging, production, testing) using puppet with r10k? And how do you deploy those defaults automatically?

I've got multiple projects defined in r10k, and each project have at least 3 environments - staging, production, testing. I would like to move common values (a lot of them) to separate file so I don't need to duplicate them.

At this moment I plan to create custom fact that returns same value for each environments, e.g. projname, add to hiera.yaml:

- "%{::environment}/hieradata/%{::fqdn}"
- "%{::environment}/hieradata/%{::hostname}"
- "%{::environment}/hieradata/role-%{::cluster_role}"
- "%{::environment}/hieradata/virtual-%{::is_virtual}"
- "%{::environment}/hieradata/common"
- "%{::projname}/hieradata/common"

And simply add projname as another branch in project git repository with hieradata.

I'm not very satisfied with this solution, could you suggest anything better?

Any help appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-07 06:04:00 -0600

Emerson Prado gravatar image

Hiera is designed exactly for that. You can define different levels of hierarchyy, like:

  • hosts/%{::fqdn}
  • roles/%{::role}
  • projects/%{::projname}/%{::environment}
  • projects/%{::projname}
  • (Whatever)
  • common

So any paramters you include in Project level will be applied to all environments of such project.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools



Asked: 2016-10-07 01:30:38 -0600

Seen: 198 times

Last updated: Oct 07 '16