tripleo-ansible/tripleo_ansible/roles/tripleo_multipathd/tasks/main.yml
Alan Bishop 1af2cde366 Add tripleo_multipathd role
A new tripleo_multipathd role is responsible for preparing and
configuring an overcloud node to run multipathd in a container.
- Host prep tasks ensure any existing multipathd service is disabled
  on the host.
- /etc/multipath.conf configuration is controlled via ansible variables
  supplied by tripleo's OS::TripleO::Services::Multipathd service.
- The multipathd container is restarted whenever the configuration
  changes.

Change-Id: Icf9faff31d83f0ea77d00a59a53d6ad36b06da4f
2020-10-19 07:59:52 -07:00

54 lines
2.0 KiB
YAML

---
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
- name: Note the previous multipath configuration
stat:
path: /etc/multipath.conf
register: stat_before
check_mode: false
- name: Configure multipath
include_tasks: configure.yml
- name: Check the new multipath configuration
stat:
path: /etc/multipath.conf
register: stat_after
check_mode: false
- name: Update containers when the multipath configuration changes
when:
- not stat_before.stat.exists or stat_after.stat.checksum != stat_before.stat.checksum
become: true
block:
- name: Identify containers using /etc/multipath.conf
command: "{{ tripleo_container_cli }} ps --filter volume=/etc/multipath.conf --format {{ '{{' }}.Names{{ '}}' }}"
register: multipath_conf_containers
changed_when: false
# Services that use os-brick (e.g. cinder-volume, nova-compute) only access
# /etc/multipath.conf sporadically, so it's sufficient to refresh the
# container's copy of the file. The services do not need to be restarted.
- name: Refresh their /etc/multipath.conf
command: "{{ tripleo_container_cli }} cp /etc/multipath.conf {{ item }}:/etc/"
loop: "{{ multipath_conf_containers.stdout_lines | default([]) }}"
# The multipathd service does need to be restarted.
- name: Restart multipathd
command: "{{ tripleo_container_cli }} restart multipathd"
when:
- "'multipathd' in multipath_conf_containers.stdout | default('')"