--- # 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. # # This role is used to simplify the management of HA containers within TripleO # Specifically it does the following: # 1) It runs the so-called init bundles on the host which are in charge of creating the pcmk resources # via puppet (or to tweak them in case they changed on a redeploy) # 2) They trigger calling the pacemaker_restart.sh script when the config for the HA service has changed # This script will restart the HA resource globally from the bootstrap node in case the config changed there # and it will only restart the service on the single node when the configuration changed and we are doing # a minor update. # The following variables are required: # - tripleo_ha_wrapper_service_name: The name of the tripleo_service being used (e.g. mysql) # - tripleo_ha_wrapper_resource_name: The name of the ocf resource being used (e.g. galera) # - tripleo_ha_wrapper_bundle_name: The name of the pacemaker bundle being used (e.g. galera-bundle) # - tripleo_ha_wrapper_resource_state: The desired state of the resource (e.g. Master) # - tripleo_ha_wrapper_puppet_execute: 'include ::tripleo::....' # - tripleo_ha_wrapper_puppet_tags: 'pacemaker::resource::bundle,...' # - tripleo_ha_wrapper_puppet_config_volume: the folder name to lookd for md5 hashes # - tripleo_ha_wrapper_puppet_debug: Should puppet be run in debug mode (defaults to false) # - tripleo_ha_wrapper_minor_update: (true|'') is this a minor update workflow or not - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: - skip: true files: - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}.yml" - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" - "{{ ansible_facts['os_family'] | lower }}.yml" tags: - always - name: "Run init bundle puppet on the host for {{ tripleo_ha_wrapper_service_name }}" shell: | puppet apply {{ (tripleo_ha_wrapper_puppet_debug | default(false) | bool) | ternary('--debug --verbose', '') }} --detailed-exitcodes \ --summarize --color=false --modulepath '{{ tripleo_ha_wrapper_puppet_modulepath }}' --tags '{{ tripleo_ha_wrapper_puppet_tags }}' \ -e '{{ tripleo_ha_wrapper_puppet_execute }}' register: puppet_run changed_when: puppet_run.rc == 2 failed_when: puppet_run.rc != 2 and puppet_run.rc != 0 - name: Run pacemaker restart if the config file for the service changed tripleo_diff_exec: command: >- {{ tripleo_ha_wrapper_pcmk_restart_script }} {{ tripleo_ha_wrapper_service_name }} {{ tripleo_ha_wrapper_resource_name }} {{ tripleo_ha_wrapper_bundle_name }} {{ tripleo_ha_wrapper_resource_state }} state_file: "{{ tripleo_ha_wrapper_config_basedir }}/{{ tripleo_ha_wrapper_puppet_config_volume }}.md5sum" state_file_suffix: "{{ tripleo_ha_wrapper_config_suffix }}" environment: TRIPLEO_MINOR_UPDATE: "{{ tripleo_ha_wrapper_minor_update|default('') }}"