--- # Copyright 2015, 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. # ansible-lint fails on this task due to the detected use of 'dpkg', # so we skip this task in the ansible-lint check by using the # 'skip_ansible_lint' tag - name: Get version of installed RabbitMQ package (deb) command: "dpkg-query -f='${Version}' -W rabbitmq-server" changed_when: false check_mode: false failed_when: false register: installed_rabbitmq_deb when: - ansible_facts['pkg_mgr'] == 'apt' tags: - rabbitmq-package-deb - rabbitmq-apt-packages - skip_ansible_lint # ansible-lint fails on this task due to the detected use of 'rpm', # so we skip this task in the ansible-lint check by using the # 'skip_ansible_lint' tag - name: Get version of installed RabbitMQ package (rpm) command: "rpm --queryformat '%{VERSION}' -q rabbitmq-server" changed_when: false check_mode: false failed_when: false register: installed_rabbitmq_rpm when: - ansible_facts['pkg_mgr'] == 'dnf' tags: - rabbitmq-package-rpm - rabbitmq-dnf-packages - skip_ansible_lint - name: Register a fact for the installed RabbitMQ version set_fact: installed_rabbitmq: "{{ item }}" when: - item is not skipped with_items: - "{{ installed_rabbitmq_deb }}" - "{{ installed_rabbitmq_rpm }}" - name: Ensure installed RabbitMQ version is same as expected fail: msg: "To install a new major/minor version of RabbitMQ set '-e rabbitmq_upgrade=true'." when: - not rabbitmq_upgrade | bool - installed_rabbitmq.rc == 0 - not (installed_rabbitmq.stdout | split('-') | first) is version(rabbitmq_package_version | split('-') | first) - rabbitmq_install_method != 'distro' tags: - rabbitmq-package-deb - rabbitmq-package-rpm - rabbitmq-apt-packages - name: Ensure that RabbitMQ is running minimal required version for upgrade fail: msg: | Minimal required version for proceeding with RabbitMQ upgrade to {{ rabbitmq_package_version }} is {{ _minimal_required_version }}. Please, upgrade to the version {{ _minimal_required_version }} before proceeding with further upgrade. Current detected version is {{ installed_rabbitmq.stdout }}. vars: _minimal_required_version: >- {{ (_rabbitmq_upgrade_minimal_requirement_mapping | selectattr('target', 'in', rabbitmq_package_version) | first)['requirement'] }} when: - rabbitmq_upgrade | bool - installed_rabbitmq.rc == 0 - installed_rabbitmq.stdout is version(_minimal_required_version, '<') - rabbitmq_install_method != 'distro' tags: - rabbitmq-package-deb - rabbitmq-package-rpm - rabbitmq-apt-packages - name: Including rabbitmq_cluster_state tasks include_tasks: rabbitmq_cluster_state.yml args: apply: tags: - rabbitmq-upgrade when: - rabbitmq_upgrade | bool tags: - rabbitmq-upgrade - name: Prepare node for upgrade when: - rabbitmq_upgrade | bool - _cluster_state - (_cluster_state.get('running_nodes', []) | length) == (groups[rabbitmq_host_group] | length) - (_cluster_state.get('alarms', []) | length) == 0 - (_cluster_state.get('partitions', []) | length) == 0 block: - name: Including rabbitmq_feature_flags tasks include_tasks: rabbitmq_feature_flags.yml args: apply: tags: - rabbitmq-upgrade when: - _rabbitmq_is_first_play_host tags: - rabbitmq-upgrade - name: Including rabbitmq_upgrade_prep tasks include_tasks: rabbitmq_upgrade_prep.yml args: apply: tags: - rabbitmq-upgrade tags: - always