From c6cd170fb730f0d357137a65e4792d6e7c3d56d9 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 26 Jun 2018 00:54:40 -0500 Subject: [PATCH] Correct role rerun when using glance with NFS When using glance + NFS the role deploys everything perfectly the first time however if the role is executed again it will result in failure due to some base directories being a mount. This change adds a new variable which will create a list of all NFS mount points. This list is then used in the required tasks to ensure we're not attempting to recreate directories that should already exist and are being used as mount-points. Change-Id: Id28176833c0b783c20ee1d2ce71fa0654ccf683e Signed-off-by: Kevin Carter --- tasks/glance_install.yml | 7 ++++++- tasks/glance_post_install.yml | 6 ------ vars/main.yml | 10 ++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tasks/glance_install.yml b/tasks/glance_install.yml index 23b96d3f..1f1f1afe 100644 --- a/tasks/glance_install.yml +++ b/tasks/glance_install.yml @@ -57,6 +57,8 @@ owner: "{{ item.owner|default(glance_system_user_name) }}" group: "{{ item.group|default(glance_system_group_name) }}" mode: "{{ item.mode|default(omit) }}" + when: + - item.path not in glance_mount_points with_items: - { path: "/openstack", mode: "0755", owner: "root", group: "root" } - { path: "/etc/glance", mode: "0750" } @@ -73,6 +75,8 @@ owner: "{{ glance_system_user_name }}" group: "{{ glance_system_group_name }}" mode: "0755" + when: + - glance_system_user_home + '/images' not in glance_mount_points - name: Test for log directory or link shell: | @@ -93,7 +97,8 @@ owner: "{{ glance_system_user_name }}" group: "{{ glance_system_group_name }}" mode: "0755" - when: log_dir.rc != 0 + when: + - log_dir.rc != 0 - name: Install distro packages package: diff --git a/tasks/glance_post_install.yml b/tasks/glance_post_install.yml index 9fe12a5a..44436cc7 100644 --- a/tasks/glance_post_install.yml +++ b/tasks/glance_post_install.yml @@ -78,12 +78,6 @@ - Manage LB - Restart glance services -- name: Create nfs shares local path - file: - path: "{{ item.local_path }}" - state: directory - with_items: "{{ glance_nfs_client }}" - - name: Glance nfs mount(s) config_template: src: "glance-systemd-mount.j2" diff --git a/vars/main.yml b/vars/main.yml index 6b666883..8bf3c9d0 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -29,3 +29,13 @@ filtered_glance_services: |- {% endif %} {% endfor %} {{ services | sort(attribute='start_order') }} + +# Define all glance mountpoints when using NFS. If defined +# the corresponding directory will only be created by the +# mount point task. +glance_mount_points: |- + {% set mps = [] %} + {% for mp in glance_nfs_client %} + {% set _ = mps.append(mp.local_path) %} + {% endfor %} + {{ mps }}