From a2ccc43a1dc0c0f423b979bfa9a2eb849a9bdec4 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Tue, 28 Feb 2017 14:43:04 -0500 Subject: [PATCH] define non_root_group explicitly previously, we used set_fact to set the non_root_group variable but this is problematic: the libvirt/ playbooks are expected to be runnable *without* also running the provision/ playbooks, in which case non_root_group is not set, causing ansible to fail. this change makes non_root_group explicit and adds it to roles/common/defaults/main.yml. Change-Id: I5a174a303c980569fad31f7d7fa8e846105a2291 --- roles/common/defaults/main.yml | 1 + roles/provision/user/tasks/main.yml | 14 ++++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml index 6e338ae39..10933b5d5 100644 --- a/roles/common/defaults/main.yml +++ b/roles/common/defaults/main.yml @@ -170,6 +170,7 @@ tuned_profile: 'virtual-host' # This is the name of the user the `provision` role will create on the # remote host. non_root_user: stack +non_root_group: "{{ non_root_user }}" # Path for volume storage libvirt_volume_path: "{{ working_dir }}/pool" diff --git a/roles/provision/user/tasks/main.yml b/roles/provision/user/tasks/main.yml index 60c8222f7..121747a10 100644 --- a/roles/provision/user/tasks/main.yml +++ b/roles/provision/user/tasks/main.yml @@ -1,16 +1,14 @@ # Create a non-root user on the target host. This is the user that # will own the virtual infrastructure on which we deploy openstack. +- name: Create non-root group + group: + name: "{{ non_root_group }}" + state: present + - name: Create non-root user user: name: "{{ non_root_user }}" + group: "{{ non_root_group }}" state: present shell: /bin/bash become: true - -- name: Get current user group for virthost - command: "id -gn {{ non_root_user }}" - register: virthost_user_group - changed_when: false - -- name: Register fact for current user group - set_fact: non_root_group="{{ virthost_user_group.stdout }}"