From fbbf5ffe09f64436a0444ce89bdad10720e46293 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 1 Sep 2023 15:42:23 -0400 Subject: [PATCH] Use cluster_group variable for paths Instead of trying to automagic this group out of the Ansible hostvars, just make it explicitly defined in the group_vars to avoid any confusion. --- group_vars/default/base.yml | 4 ++++ roles/base/templates/etc/ntp.conf.j2 | 2 +- roles/pvc/tasks/ceph/bootstrap.yml | 2 +- roles/pvc/tasks/ceph/main.yml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/group_vars/default/base.yml b/group_vars/default/base.yml index e72a9d7..27d3f0f 100644 --- a/group_vars/default/base.yml +++ b/group_vars/default/base.yml @@ -1,4 +1,8 @@ --- +# The name of the Ansible cluster group, used to set file paths and determine hosts in the cluster +# This should match the lowest-level group in the Ansible `hosts` file that defines this cluster +cluster_group: default + # Local timezone for the cluster timezone_location: Canada/Eastern diff --git a/roles/base/templates/etc/ntp.conf.j2 b/roles/base/templates/etc/ntp.conf.j2 index bf1df9c..ba9e235 100644 --- a/roles/base/templates/etc/ntp.conf.j2 +++ b/roles/base/templates/etc/ntp.conf.j2 @@ -16,7 +16,7 @@ server time.nrc.ca iburst server time.chu.nrc.ca iburst # Local PVC cluster -{% for host in groups[hostvars[inventory_hostname].group_names[0]] %} +{% for host in groups[cluster_group] %} server {{ host }} iburst {% endfor %} diff --git a/roles/pvc/tasks/ceph/bootstrap.yml b/roles/pvc/tasks/ceph/bootstrap.yml index c3b7434..c3f053b 100644 --- a/roles/pvc/tasks/ceph/bootstrap.yml +++ b/roles/pvc/tasks/ceph/bootstrap.yml @@ -75,7 +75,7 @@ - name: collect bootstrapped Ceph files into the role fetch: src: /tmp/ceph-bootstrap/{{ item }} - dest: roles/pvc/files/ceph/{{ hostvars[inventory_hostname].group_names[0] }}/ceph/ + dest: roles/pvc/files/ceph/{{ cluster_group }}/ceph/ flat: yes with_items: - ceph.conf diff --git a/roles/pvc/tasks/ceph/main.yml b/roles/pvc/tasks/ceph/main.yml index 518933c..d934515 100644 --- a/roles/pvc/tasks/ceph/main.yml +++ b/roles/pvc/tasks/ceph/main.yml @@ -39,7 +39,7 @@ - name: install configurations copy: - src: ceph/{{ hostvars[inventory_hostname].group_names[0] }}/ceph/{{ item }} + src: ceph/{{ cluster_group }}/ceph/{{ item }} dest: /etc/ceph/{{ item }} owner: ceph group: ceph