Browse Source

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
changes/17/749117/15
Alan Bishop 2 years ago
parent
commit
1af2cde366
  1. 6
      doc/source/roles/role-tripleo_multipathd.rst
  2. 26
      tripleo_ansible/roles/tripleo_multipathd/defaults/main.yml
  3. 93
      tripleo_ansible/roles/tripleo_multipathd/files/multipath.conf
  4. 44
      tripleo_ansible/roles/tripleo_multipathd/meta/main.yml
  5. 37
      tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/Dockerfile
  6. 21
      tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/converge.yml
  7. 9
      tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/custom_multipath.conf
  8. 49
      tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/molecule.yml
  9. 19
      tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/prepare.yml
  10. 27
      tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/verify.yml
  11. 37
      tripleo_ansible/roles/tripleo_multipathd/molecule/default/Dockerfile
  12. 23
      tripleo_ansible/roles/tripleo_multipathd/molecule/default/converge.yml
  13. 49
      tripleo_ansible/roles/tripleo_multipathd/molecule/default/molecule.yml
  14. 24
      tripleo_ansible/roles/tripleo_multipathd/molecule/default/prepare.yml
  15. 40
      tripleo_ansible/roles/tripleo_multipathd/molecule/default/verify.yml
  16. 37
      tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/Dockerfile
  17. 19
      tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/converge.yml
  18. 49
      tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/molecule.yml
  19. 35
      tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/prepare.yml
  20. 27
      tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/verify.yml
  21. 91
      tripleo_ansible/roles/tripleo_multipathd/tasks/configure.yml
  22. 52
      tripleo_ansible/roles/tripleo_multipathd/tasks/host_prep.yml
  23. 53
      tripleo_ansible/roles/tripleo_multipathd/tasks/main.yml
  24. 10
      zuul.d/molecule.yaml

6
doc/source/roles/role-tripleo_multipathd.rst

@ -0,0 +1,6 @@
=========================
Role - tripleo_multipathd
=========================
.. ansibleautoplugin::
:role: tripleo_ansible/roles/tripleo_multipathd

26
tripleo_ansible/roles/tripleo_multipathd/defaults/main.yml

@ -0,0 +1,26 @@
---
# 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.
# All variables intended for modification should be placed in this file.
tripleo_container_cli: "{{ container_cli | default('podman') }}"
tripleo_multipathd_custom_config_file: ''
tripleo_multipathd_enable: true
tripleo_multipathd_find_multipaths: true
tripleo_multipathd_skip_kpartx: true
tripleo_multipathd_user_friendly_names: false

93
tripleo_ansible/roles/tripleo_multipathd/files/multipath.conf

@ -0,0 +1,93 @@
# This is a basic configuration file with some examples, for device mapper
# multipath.
#
# For a complete list of the default configuration values, run either
# multipath -t
# or
# multipathd show config
#
# For a list of configuration options with descriptions, see the multipath.conf
# man page
## By default, devices with vendor = "IBM" and product = "S/390.*" are
## blacklisted. To enable mulitpathing on these devies, uncomment the
## following lines.
#blacklist_exceptions {
# device {
# vendor "IBM"
# product "S/390.*"
# }
#}
## Use user friendly names, instead of using WWIDs as names.
defaults {
user_friendly_names yes
find_multipaths yes
}
##
## Here is an example of how to configure some standard options.
##
#
#defaults {
# udev_dir /dev
# polling_interval 10
# selector "round-robin 0"
# path_grouping_policy multibus
# prio alua
# path_checker readsector0
# rr_min_io 100
# max_fds 8192
# rr_weight priorities
# failback immediate
# no_path_retry fail
# user_friendly_names yes
#}
##
## The wwid line in the following blacklist section is shown as an example
## of how to blacklist devices by wwid. The 2 devnode lines are the
## compiled in default blacklist. If you want to blacklist entire types
## of devices, such as all scsi devices, you should use a devnode line.
## However, if you want to blacklist specific devices, you should use
## a wwid line. Since there is no guarantee that a specific device will
## not change names on reboot (from /dev/sda to /dev/sdb for example)
## devnode lines are not recommended for blacklisting specific devices.
##
#blacklist {
# wwid 26353900f02796769
# devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
# devnode "^hd[a-z]"
#}
#multipaths {
# multipath {
# wwid 3600508b4000156d700012000000b0000
# alias yellow
# path_grouping_policy multibus
# path_checker readsector0
# path_selector "round-robin 0"
# failback manual
# rr_weight priorities
# no_path_retry 5
# }
# multipath {
# wwid 1DEC_____321816758474
# alias red
# }
#}
#devices {
# device {
# vendor "COMPAQ "
# product "HSV110 (C)COMPAQ"
# path_grouping_policy multibus
# path_checker readsector0
# path_selector "round-robin 0"
# hardware_handler "0"
# failback 15
# rr_weight priorities
# no_path_retry queue
# }
# device {
# vendor "COMPAQ "
# product "MSA1000 "
# path_grouping_policy multibus
# }
#}

44
tripleo_ansible/roles/tripleo_multipathd/meta/main.yml

@ -0,0 +1,44 @@
---
# 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.
galaxy_info:
author: OpenStack
description: TripleO OpenStack Role -- tripleo_multipathd
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.7
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Fedora
versions:
- 28
- name: CentOS
versions:
- 7
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

37
tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/Dockerfile

@ -0,0 +1,37 @@
# Molecule managed
# Copyright 2019 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.
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

21
tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/converge.yml

@ -0,0 +1,21 @@
---
# 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: Run the default converge playbook
import_playbook: ../default/converge.yml
vars:
tripleo_multipathd_custom_config_file: ../custom_config/custom_multipath.conf

9
tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/custom_multipath.conf

@ -0,0 +1,9 @@
# This represents a custom configuration file the user wishes to deploy.
defaults {
user_friendly_names yes
find_multipaths yes
# Use custom_variable as a marker to ensure this custom config file
# gets deployed.
custom_variable custom_value
}

49
tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/molecule.yml

@ -0,0 +1,49 @@
---
driver:
name: podman
log: true
platforms:
- name: ubi8
hostname: ubi8
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
ulimits: &ulimit
- host
provisioner:
name: ansible
inventory:
hosts:
all:
hosts:
ubi8:
ansible_python_interpreter: /usr/bin/python3
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- check
- verify
- destroy
verifier:
name: ansible

19
tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/prepare.yml

@ -0,0 +1,19 @@
---
# 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: Run the default prepare playbook
import_playbook: ../default/prepare.yml

27
tripleo_ansible/roles/tripleo_multipathd/molecule/custom_config/verify.yml

@ -0,0 +1,27 @@
---
# 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: Run the default verify playbook
import_playbook: ../default/verify.yml
- name: Verify (custom)
hosts: all
gather_facts: false
tasks:
- name: Verify the custom setting is present
command: grep 'custom_variable custom_value' /etc/multipath.conf
changed_when: false

37
tripleo_ansible/roles/tripleo_multipathd/molecule/default/Dockerfile

@ -0,0 +1,37 @@
# Molecule managed
# Copyright 2019 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.
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

23
tripleo_ansible/roles/tripleo_multipathd/molecule/default/converge.yml

@ -0,0 +1,23 @@
---
# 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: Converge
hosts: all
roles:
- role: tripleo_multipathd
vars:
tripleo_container_cli: 'true'

49
tripleo_ansible/roles/tripleo_multipathd/molecule/default/molecule.yml

@ -0,0 +1,49 @@
---
driver:
name: podman
log: true
platforms:
- name: ubi8
hostname: ubi8
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
ulimits: &ulimit
- host
provisioner:
name: ansible
inventory:
hosts:
all:
hosts:
ubi8:
ansible_python_interpreter: /usr/bin/python3
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- check
- verify
- destroy
verifier:
name: ansible

24
tripleo_ansible/roles/tripleo_multipathd/molecule/default/prepare.yml

@ -0,0 +1,24 @@
---
# 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: Prepare
hosts: all
vars:
test_deps_extra_packages:
- device-mapper-multipath
roles:
- role: test_deps

40
tripleo_ansible/roles/tripleo_multipathd/molecule/default/verify.yml

@ -0,0 +1,40 @@
---
# 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: Verify
hosts: all
gather_facts: false
tasks:
- name: Check /etc/multipath.conf settings
lineinfile:
name: /etc/multipath.conf
regexp: "^\\s+{{ item.var }}"
line: " {{ item.var }} {{ item.value }}"
loop:
- {var: find_multipaths, value: 'yes'}
- {var: skip_kpartx, value: 'yes'}
- {var: user_friendly_names, value: 'no'}
loop_control:
index_var: multipath_var_index
register: multipath_result
- name: Fail if /etc/multipath.conf settings are not correct
debug:
msg: "/etc/multipath.conf settings are not correct."
when:
- multipath_result.changed
failed_when:
- true

37
tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/Dockerfile

@ -0,0 +1,37 @@
# Molecule managed
# Copyright 2019 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.
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

19
tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/converge.yml

@ -0,0 +1,19 @@
---
# 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: Run the default converge playbook
import_playbook: ../default/converge.yml

49
tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/molecule.yml

@ -0,0 +1,49 @@
---
driver:
name: podman
log: true
platforms:
- name: ubi8
hostname: ubi8
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
- /opt/yum.repos.d:/etc/yum.repos.d:rw
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
ulimits: &ulimit
- host
provisioner:
name: ansible
inventory:
hosts:
all:
hosts:
ubi8:
ansible_python_interpreter: /usr/bin/python3
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- check
- verify
- destroy
verifier:
name: ansible

35
tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/prepare.yml

@ -0,0 +1,35 @@
---
# 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: Prepare
hosts: all
become: true
pre_tasks:
- name: Precreate /etc/multipath.conf
copy:
src: ../../files/multipath.conf
dest: /etc/multipath.conf
- name: Add a preexisting setting
lineinfile:
path: /etc/multipath.conf
insertafter: '^defaults'
line: ' preexisting_variable preexisting_value'
- name: Run the default prepare playbook
import_playbook: ../default/prepare.yml

27
tripleo_ansible/roles/tripleo_multipathd/molecule/preexisting_config/verify.yml

@ -0,0 +1,27 @@
---
# 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: Run the default verify playbook
import_playbook: ../default/verify.yml
- name: Verify (preexisting)
hosts: all
gather_facts: false
tasks:
- name: Verify the preexisting setting is present
command: grep 'preexisting_variable preexisting_value' /etc/multipath.conf
changed_when: false

91
tripleo_ansible/roles/tripleo_multipathd/tasks/configure.yml

@ -0,0 +1,91 @@
---
# 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: Install custom multipath.conf if one is specified
copy:
src: "{{ tripleo_multipathd_custom_config_file }}"
dest: /etc/multipath.conf
mode: 0644
when:
- tripleo_multipathd_custom_config_file|length > 0
- name: Ensure /etc/multipath.conf exists
when:
- tripleo_multipathd_custom_config_file|length == 0
block:
- name: Check for existing /etc/multipath.conf
stat:
path: /etc/multipath.conf
register: result
check_mode: false
- name: Create /etc/multipath.conf if file is missing
copy:
src: "{{ role_path }}/files/multipath.conf"
dest: /etc/multipath.conf
mode: 0644
when:
- not result.stat.exists or result.stat.size == 0
- name: Set setype on /etc/multipath.conf
file:
path: /etc/multipath.conf
setype: container_file_t
- name: Ensure a blacklist section is present
lineinfile:
path: /etc/multipath.conf
regexp: '^blacklist'
line: 'blacklist {'
register: blacklist_section
- name: Terminate the blacklist section if one was added
replace:
path: /etc/multipath.conf
regexp: '^(blacklist {)'
replace: '\1\n}'
when:
- blacklist_section.changed
- name: Remove global blacklist if multipathd is enabled
replace:
path: /etc/multipath.conf
regexp: '^blacklist {\n[\s]+devnode \"\.\*\"'
replace: 'blacklist {'
when:
- tripleo_multipathd_enable | bool
- name: Add global blacklist if multipathd is disabled
lineinfile:
path: /etc/multipath.conf
insertafter: '^blacklist'
regexp: '^[\s]+devnode \"\.\*\"'
line: ' devnode ".*"'
when:
- not (tripleo_multipathd_enable|bool)
- name: Configure /etc/multipath.conf variables
lineinfile:
path: /etc/multipath.conf
insertafter: '^defaults'
firstmatch: true
regexp: "^\\s+{{ item.var }}"
line: " {{ item.var }} {{ (item.value|bool) | ternary('yes', 'no') }}"
loop:
- {var: find_multipaths, value: "{{tripleo_multipathd_find_multipaths}}"}
- {var: skip_kpartx, value: "{{tripleo_multipathd_skip_kpartx}}"}
- {var: user_friendly_names, value: "{{tripleo_multipathd_user_friendly_names}}"}
loop_control:
index_var: multipath_var_index

52
tripleo_ansible/roles/tripleo_multipathd/tasks/host_prep.yml

@ -0,0 +1,52 @@
---
# 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: Check if multipathd is deployed on the host
command: systemctl is-enabled --quiet multipathd
failed_when: false
register: multipathd_enabled_result
check_mode: false
- name: Set fact multipathd_enabled
set_fact:
multipathd_enabled: "{{ multipathd_enabled_result.rc == 0 }}"
- name: Stop multipathd service on the host
service:
name: "{{ item }}"
state: stopped
enabled: false
when:
- multipathd_enabled|bool
ignore_errors: true
loop:
- multipathd.service
- multipathd.socket
loop_control:
index_var: multipath_service_index
- name: Load dm-multipath
import_role:
name: tripleo_module_load
vars:
modules:
- name: dm-multipath
- name: Prepare /etc/multipath directory
file:
path: /etc/multipath
state: directory
setype: container_file_t

53
tripleo_ansible/roles/tripleo_multipathd/tasks/main.yml

@ -0,0 +1,53 @@
---
# 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('')"

10
zuul.d/molecule.yaml

@ -31,6 +31,7 @@
- tripleo-ansible-centos-8-molecule-tripleo_kernel
- tripleo-ansible-centos-8-molecule-tripleo_keystone_resources
- tripleo-ansible-centos-8-molecule-tripleo_module_load
- tripleo-ansible-centos-8-molecule-tripleo_multipathd
- tripleo-ansible-centos-8-molecule-tripleo_network_config
- tripleo-ansible-centos-8-molecule-tripleo_nodes_validation
- tripleo-ansible-centos-8-molecule-tripleo_nova_image_cache
@ -82,6 +83,7 @@
- tripleo-ansible-centos-8-molecule-tripleo_kernel
- tripleo-ansible-centos-8-molecule-tripleo_keystone_resources
- tripleo-ansible-centos-8-molecule-tripleo_module_load
- tripleo-ansible-centos-8-molecule-tripleo_multipathd
- tripleo-ansible-centos-8-molecule-tripleo_network_config
- tripleo-ansible-centos-8-molecule-tripleo_nodes_validation
- tripleo-ansible-centos-8-molecule-tripleo_nova_image_cache
@ -133,6 +135,7 @@
- tripleo-ansible-centos-8-molecule-tripleo_kernel
- tripleo-ansible-centos-8-molecule-tripleo_keystone_resources
- tripleo-ansible-centos-8-molecule-tripleo_module_load
- tripleo-ansible-centos-8-molecule-tripleo_multipathd
- tripleo-ansible-centos-8-molecule-tripleo_network_config
- tripleo-ansible-centos-8-molecule-tripleo_nodes_validation
- tripleo-ansible-centos-8-molecule-tripleo_nova_image_cache
@ -357,6 +360,13 @@
parent: tripleo-ansible-centos-8-base
vars:
tripleo_role_name: tripleo_module_load
- job:
files:
- ^tripleo_ansible/roles/tripleo_multipathd/.*
name: tripleo-ansible-centos-8-molecule-tripleo_multipathd
parent: tripleo-ansible-centos-8-base
vars:
tripleo_role_name: tripleo_multipathd
- job:
files:
- ^tripleo_ansible/roles/tripleo_network_config/.*

Loading…
Cancel
Save