tripleo-ansible/tripleo_ansible/roles/tripleo_ceph_client/tasks/effective_clients_limit.yml

61 lines
2.4 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.
# sanitize limit to always use ':'
# external_deploy_steps_tasks with limit must always include undercloud
# but we do not want undercloud given how we will delegate from it
- name: set limit list
set_fact:
tripleo_ceph_client_limit_list: "{{ ( ansible_limit |
regex_replace(':|,', ':') |
regex_replace('undercloud:', '') ).split(':') }}"
# 'a:!b:c' --> only 'b' (without '!')
- name: set exclude hosts
set_fact:
tripleo_ceph_client_exclude: "{{ tripleo_ceph_client_exclude|default([])
+ [ item | regex_replace('!') ] }}"
when: item is regex('^\!')
loop: "{{ tripleo_ceph_client_limit_list }}"
# 'a:!b:c' --> only 'a:c'
- name: set include hosts
set_fact:
tripleo_ceph_client_include: "{{ tripleo_ceph_client_include|default([])
+ [item] }}"
when: item is not regex('^\!')
loop: "{{ tripleo_ceph_client_limit_list }}"
- name: set effective deny list with exclude
set_fact:
tripleo_ceph_client_effective_clients: "{{ client_group |
symmetric_difference(tripleo_ceph_client_exclude) |
list }}"
when:
- tripleo_ceph_client_exclude is defined
- tripleo_ceph_client_exclude | length > 0
# if include list is used, then exclude list does not matter, so then
# reset the effective clients fact; this task must be after exclude task
- name: set effective allow list with include
set_fact:
tripleo_ceph_client_effective_clients: "{{ client_group |
intersect(tripleo_ceph_client_include) |
list }}"
when:
- tripleo_ceph_client_include is defined
- tripleo_ceph_client_include | length > 0