From 24eb60b34df542d58aaab8bcb5b2bcbfd8964bcc Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 2 Aug 2018 09:16:22 -0500 Subject: [PATCH] Reorganize hieradata to match ansible variables We are already organizing our hiera content basically the same way as ansible needs for variables to be provided. If we reorganize the directories slightly (to be coordinated with dirs on puppetmaster) then we can have a single directory do double-duty. Change-Id: I6ac90a7439ed8a5d9433d9526f37e44668b360ff --- library/puppet_get_hiera_file_list | 6 +++--- tasks/main.yml | 4 ++-- templates/hiera.yaml.j2 | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/library/puppet_get_hiera_file_list b/library/puppet_get_hiera_file_list index 79dbe54..c30ce91 100644 --- a/library/puppet_get_hiera_file_list +++ b/library/puppet_get_hiera_file_list @@ -51,9 +51,9 @@ def main(): ) p = module.params - paths = ['group/%s.yaml' % f for f in p['groups'] ] - paths.append('common.yaml') - paths.append('fqdn/%s.yaml' % p['fqdn']) + paths = ['group_vars/%s.yaml' % f for f in p['groups'] ] + paths.append('group_vars/all.yaml') + paths.append('host_vars/%s.yaml' % p['fqdn']) good_paths = [] for path in paths: diff --git a/tasks/main.yml b/tasks/main.yml index 699013c..2c82b5d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -44,8 +44,8 @@ group: root mode: 0700 with_items: - - fqdn - - group + - group_vars + - host_vars - name: make file list puppet_get_hiera_file_list: diff --git a/templates/hiera.yaml.j2 b/templates/hiera.yaml.j2 index 23395a2..496fb5a 100644 --- a/templates/hiera.yaml.j2 +++ b/templates/hiera.yaml.j2 @@ -1,15 +1,18 @@ --- :hierarchy: - # Use private hieradata first + # Use private hieradata first. Align naming with ansible so that the private + # data can exist in a single copy for both ansible and puppet # Puppet3 paths - - "hieradata/%{::environment}/fqdn/%{::fqdn}" - - "hieradata/%{::environment}/group/%{group}" # no :: because group is set at nodescope - - "hieradata/%{::environment}/common" + - "hieradata/%{::environment}/host_vars/%{::fqdn}" + - "hieradata/%{::environment}/group_vars/%{group}" # no :: because group is set at nodescope + - "hieradata/%{::environment}/group_vars/all" # Puppet4 paths - - "%{::environment}/hieradata/fqdn/%{::fqdn}" - - "%{::environment}/hieradata/group/%{group}" # no :: because group is set at nodescope - - "%{::environment}/hieradata/common" - # Use public hieradata second, also be environmentally aware + - "%{::environment}/hieradata/host_vars/%{::fqdn}" + - "%{::environment}/hieradata/group_vars/%{group}" # no :: because group is set at nodescope + - "%{::environment}/hieradata/group_vars/all" + # Use public hieradata second, also be environmentally aware. Keep this + # in the old structure so that we don't have to do a dance. There isn't much + # here, and it can be transferred piecemeal. - "%{::environment}/hiera/fqdn/%{::fqdn}" - "%{::environment}/hiera/group/%{group}" # no :: because group is set at nodescope - "%{::environment}/hiera/common"