I would like to apply certain configs to certain GCE instance tags

asked 2017-10-16 07:45:19 -0600

Hi,

I have just started with GCE. I noticed that you can specify certain tags to your instances. I would like that for example all instances that are tagged with the tag "webserver" will get the webserver.yaml file included with hiera. My hiera.yaml looks as follow.


:backends:
- yaml
:hierarchy:
- 'fqdn/%{fqdn}'
- 'hostname/%{hostname}'
- 'operatingsystem/%{operatingsystem}/tags/%{gce.instance.tags}'
- 'operatingsystem/%{operatingsystem}/role/%{role}'
- 'operatingsystem/%{operatingsystem}/common'
:yaml:
:datadir: '/path/to/hiera/datadir/'
:merge_behavior: :deeper


So if I put a yaml file in the operatingsystem/%{operatingsystem}/tags/%{gce.instance.tags}/ folder called webserver.yaml and I have added the tag webserver to that specific instance it will pick up that yaml file and apply the configuration.

Thanks in advance - Alexander

edit retag flag offensive close merge delete

Comments