Fix _manila_backends fact

Previously _manila_backends was set only in case manila-share and
manila-api are the same host, which is the case only for aio deployments
Now fact will be set in an appropriate way.

This also drops facts refresh task since it's not need since queens and
uses tempfile for creating temporary directory

Change-Id: Ie5f95b7e80cd7fd26ee1f25aedf938abff131623
This commit is contained in:
Dmitriy Rabotyagov 2020-01-31 16:01:19 +02:00
parent 67c4bc8316
commit d09f038ac7
9 changed files with 41 additions and 68 deletions

View File

@ -83,7 +83,7 @@
- common-db
- manila-config
- include_tasks: mq_setup.yml
- import_tasks: mq_setup.yml
when:
- "manila_services['manila-api']['group'] in group_names"
- "inventory_hostname == ((groups[manila_services['manila-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
@ -110,22 +110,11 @@
tags:
- manila-install
- name: refresh local facts
setup:
filter: ansible_local
gather_subset: "!all"
tags:
- manila-config
- import_tasks: manila_cleanup_old_facts.yml
tags:
- manila-config
- import_tasks: manila_post_install.yml
tags:
- manila-config
- include_tasks: manila_db_sync.yml
- import_tasks: manila_db_sync.yml
when:
- groups['manila_api'] | length > 0
- manila_services['manila-api']['group'] in group_names
@ -138,7 +127,7 @@
- manila-config
- name: import_tasks ceph_client role
include_role:
import_role:
name: ceph_client
vars:
openstack_service_system_user: "{{ manila_system_user_name }}"
@ -149,14 +138,6 @@
tags:
- ceph
- include_tasks: manila_backend_cephfs.yml
when:
- (manila_enabled_share_protocols | join('\n')) | regex_search('^ceph.*', multiline=True, ignorecase=True)
- manila_services['manila-share']['group'] in group_names
with_dict: "{{ _manila_backends | default({}) }}"
tags:
- manila-config
- import_tasks: service_setup.yml
vars:
_service_adminuri_insecure: "{{ keystone_service_adminuri_insecure }}"
@ -187,10 +168,25 @@
- name: Flush handlers
meta: flush_handlers
- include_tasks: manila_backends.yml
- name: Create singular manila_backends variable for all hosts
set_fact:
_manila_backends: "{{ (_manila_backends | default(manila_backends | default({}))) | combine(hostvars[item]['manila_backends'] | default({})) }}"
with_items: "{{ groups[manila_services['manila-share']['group']] }}"
tags:
- manila-config
- import_tasks: manila_backends.yml
when:
- groups[manila_services['manila-share']['group']] | length > 0
- manila_services['manila-api']['group'] in group_names
- inventory_hostname == ((groups[manila_services['manila-api']['group']] | intersect(ansible_play_hosts)) | list)[-1]
tags:
- manila-config
- import_tasks: manila_backend_cephfs.yml
when:
- manila_backend_rbd_inuse
- manila_services['manila-share']['group'] in group_names
- inventory_hostname == ((groups[manila_services['manila-share']['group']] | intersect(ansible_play_hosts)) | list)[-1]
tags:
- manila-config

View File

@ -13,33 +13,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Set _cephfs_mount_dir fact
set_fact:
_cephfs_mount_dir: /mnt/cephfs-ansible-mount
_cephfs_auth_id: "{{ item.value.cephfs_auth_id|default('manila') }}"
- name: Create temporary mount dir
file:
name: "{{ _cephfs_mount_dir }}"
tempfile:
state: directory
suffix: manila_cephfs
register: _cephfs_mount_dir
- name: Mount CephFS
command: |
ceph-fuse --id "{{ _cephfs_auth_id }}" "{{ _cephfs_mount_dir }}"
ceph-fuse --id "{{ item.value.cephfs_auth_id|default('manila') }}" "{{ _cephfs_mount_dir.path }}"
changed_when: false
- name: Ensure CephFS volumes dir permissions
file:
name: "{{ _cephfs_mount_dir }}/volumes"
name: "{{ _cephfs_mount_dir.path }}/volumes"
state: directory
owner: "{{ manila_system_user_name }}"
- name: Unmount CephFS
mount:
path: "{{ _cephfs_mount_dir }}"
path: "{{ _cephfs_mount_dir.path }}"
state: unmounted
- name: Remove temporary mount dir
file:
name: "{{ _cephfs_mount_dir }}"
name: "{{ _cephfs_mount_dir.path }}"
state: absent

View File

@ -31,11 +31,6 @@
include_role:
name: "openstack_openrc"
- name: Create singular manila_backends variable for all hosts
set_fact:
_manila_backends: "{{ (_manila_backends | default(manila_backends | default({}))) | combine(hostvars[item]['manila_backends'] | default({})) }}"
with_items: "{{ groups[manila_services['manila-share']['group']] }}"
- name: Add in manila devices types
shell: |
. {{ ansible_env.HOME }}/openrc

View File

@ -1,29 +0,0 @@
---
# Copyright 2019, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# TODO(odyssey4me):
# This file and the task calling it may be removed in Queens.
- name: Remove the old db_sync fact
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: manila
option: "need_db_sync"
state: absent
- name: refresh local facts
setup:
filter: ansible_local
gather_subset: "!all"

View File

@ -65,6 +65,9 @@ manila_lvm_share_distro_packages:
- thin-provisioning-tools
- nfs-kernel-server
manila_rbd_share_distro_packages:
- ceph-fuse
manila_oslomsg_amqp1_distro_packages:
- libsasl2-modules
- sasl2-bin

View File

@ -25,6 +25,9 @@ manila_package_list: |-
{% if manila_backend_lvm_inuse | bool %}
{% set _ = packages.extend(manila_lvm_share_distro_packages) %}
{% endif %}
{% if manila_backend_rbd_inuse | bool %}
{% set _ = packages.extend(manila_rbd_share_distro_packages) %}
{% endif %}
{% endif %}
{% if manila_services['manila-api']['group'] in group_names %}
{% set _ = packages.extend(manila_api_distro_packages) %}

View File

@ -50,6 +50,9 @@ manila_lvm_share_distro_packages:
- lvm2
- parted
manila_rbd_share_distro_packages:
- ceph-fuse
manila_oslomsg_amqp1_distro_packages:
- cyrus-sasl-lib
- cyrus-sasl-plain

View File

@ -25,6 +25,9 @@ manila_package_list: |-
{% if manila_backend_lvm_inuse | bool %}
{% set _ = packages.extend(manila_lvm_share_distro_packages) %}
{% endif %}
{% if manila_backend_rbd_inuse | bool %}
{% set _ = packages.extend(manila_rbd_share_distro_packages) %}
{% endif %}
{% endif %}
{% if manila_oslomsg_amqp1_enabled | bool %}
{% set _ = packages.extend(manila_oslomsg_amqp1_distro_packages) %}

View File

@ -50,6 +50,9 @@ manila_lvm_share_distro_packages:
- lvm2
- parted
manila_rbd_share_distro_packages:
- ceph-fuse
manila_oslomsg_amqp1_distro_packages:
- cyrus-sasl
- cyrus-sasl-plain