tripleo-hieradata: add hieradata_files param

If hieradata_files is set (must be a list), Ansible will configure
/etc/puppet/hiera.yaml with the right configuration for Hiera.

Note: we now use hiera3 for backward compatibility but in the future we
will switch to hiera5.

Change-Id: Ia5f11ea1a2f16b736ed7053c5182c7f5a7eb1f4b
implements: blueprint reduce-deployment-resources
This commit is contained in:
Emilien Macchi 2019-05-31 11:30:34 -04:00
parent afcd089024
commit 94c0c09261
4 changed files with 21 additions and 0 deletions

View File

@ -12,6 +12,7 @@ Required:
* `hieradata_variable_start_string` -- string marking the beginning of a template print statement.
* `hieradata_variable_end_string` -- string marking the end of a template print statement.
* `hieradata_per_host` -- whether or not we configure hieradata per host.
* `hieradata_files` -- List of hieradata files (Order matters for Hierarchy).
Test playbook
-------------

View File

@ -1,4 +1,5 @@
hieradata_template: ""
hieradata_files: []
# jinja2 escape trick for simple {{ and }} strings:
hieradata_variable_start_string: "{{ '{{' }}"
hieradata_variable_end_string: "{{ '}}' }}"

View File

@ -4,6 +4,22 @@
state: directory
mode: 0700
- name: Write hiera config
when: hieradata_files != []
copy:
mode: 0600
dest: /etc/puppet/hiera.yaml
# TODO(emilien) Switch to Hiera5 format once we stop calling Hiera CLI
# which is deprecated and should be replaced by "puppet lookup" command.
content: |
---
:backends:
- json
:json:
:datadir: /etc/puppet/hieradata
:hierarchy:
{{ hieradata_files }}
- name: Template hieradata file
when: hieradata_template != ""
delegate_to: localhost

View File

@ -8,3 +8,6 @@
# jinja2 escape trick for simple {{ and }} strings:
variable_start_string: "{{ '{{' }}"
variable_end_string: "{{ '}}' }}"
hieradata_files:
- node
- common