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 <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-06-26 00:54:40 -05:00 committed by Kevin Carter (cloudnull)
parent 7958d16c71
commit c6cd170fb7
3 changed files with 16 additions and 7 deletions

View File

@ -57,6 +57,8 @@
owner: "{{ item.owner|default(glance_system_user_name) }}" owner: "{{ item.owner|default(glance_system_user_name) }}"
group: "{{ item.group|default(glance_system_group_name) }}" group: "{{ item.group|default(glance_system_group_name) }}"
mode: "{{ item.mode|default(omit) }}" mode: "{{ item.mode|default(omit) }}"
when:
- item.path not in glance_mount_points
with_items: with_items:
- { path: "/openstack", mode: "0755", owner: "root", group: "root" } - { path: "/openstack", mode: "0755", owner: "root", group: "root" }
- { path: "/etc/glance", mode: "0750" } - { path: "/etc/glance", mode: "0750" }
@ -73,6 +75,8 @@
owner: "{{ glance_system_user_name }}" owner: "{{ glance_system_user_name }}"
group: "{{ glance_system_group_name }}" group: "{{ glance_system_group_name }}"
mode: "0755" mode: "0755"
when:
- glance_system_user_home + '/images' not in glance_mount_points
- name: Test for log directory or link - name: Test for log directory or link
shell: | shell: |
@ -93,7 +97,8 @@
owner: "{{ glance_system_user_name }}" owner: "{{ glance_system_user_name }}"
group: "{{ glance_system_group_name }}" group: "{{ glance_system_group_name }}"
mode: "0755" mode: "0755"
when: log_dir.rc != 0 when:
- log_dir.rc != 0
- name: Install distro packages - name: Install distro packages
package: package:

View File

@ -78,12 +78,6 @@
- Manage LB - Manage LB
- Restart glance services - 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) - name: Glance nfs mount(s)
config_template: config_template:
src: "glance-systemd-mount.j2" src: "glance-systemd-mount.j2"

View File

@ -29,3 +29,13 @@ filtered_glance_services: |-
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{{ services | sort(attribute='start_order') }} {{ 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 }}