78fbffd20c
Due to historical reasons RabbitMQ operations, like start/stop/restart were perfromed in tasks and triggered on changes. As of today there seems to be no need in such approach and we can use handlers instead. It will also move some tasks, which intend to run when service is running, to their own file. This also allows to run them once on cluster rather then for each host. We also merge set_cookie with post_install as there is no reason to maintain the task in it's own file. Change-Id: I222b9de3ca531724b05c7fa2cf032a3271055d64
129 lines
4.3 KiB
YAML
129 lines
4.3 KiB
YAML
---
|
|
# Copyright 2014, 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.
|
|
|
|
- name: Validate repo config is deb822 format
|
|
vars:
|
|
_repo_check: "{{ (rabbitmq_repo + rabbitmq_erlang_repo) | selectattr('repo', 'defined') | map(attribute='repo') }}"
|
|
ansible.builtin.assert:
|
|
that: _repo_check | length == 0
|
|
fail_msg: "The following repository definitions must be updated to deb822 format {{ _repo_check }}"
|
|
|
|
- name: Run the apt package pinning role
|
|
include_role:
|
|
name: apt_package_pinning
|
|
vars:
|
|
apt_package_pinning_file_name: "rabbitmq.pref"
|
|
apt_package_pinning_priority: 999
|
|
apt_package_pinning_state: "{{ (rabbitmq_install_method == 'external_repo') | ternary('present', 'absent') }}"
|
|
apt_pinned_packages:
|
|
- package: "*"
|
|
release: "cloudsmith/rabbitmq/rabbitmq-erlang"
|
|
- package: "erlang*"
|
|
version: "1:{{ rabbitmq_erlang_package_version }}"
|
|
priority: 1000
|
|
- package: "rabbitmq-server"
|
|
version: "{{ rabbitmq_package_version }}"
|
|
priority: 1000
|
|
|
|
# NOTE(jrosser) remove this task for the 2025.2 release
|
|
- name: Clean up legacy repository config not in deb822 format
|
|
vars:
|
|
rabbitmq_apt_repo_cleanup:
|
|
- RabbitMQ.list
|
|
- els_erlang.list
|
|
file:
|
|
path: "/etc/apt/sources.list.d/{{ item }}"
|
|
state: absent
|
|
with_items: "{{ rabbitmq_apt_repo_cleanup }}"
|
|
register: apt_repo_removed
|
|
|
|
- name: Ensure python3-debian package is available
|
|
apt:
|
|
name: python3-debian
|
|
|
|
- name: Manage apt repositories
|
|
ansible.builtin.deb822_repository:
|
|
allow_downgrade_to_insecure: "{{ item.allow_downgrade_to_insecure | default(omit) }}"
|
|
allow_insecure: "{{ item.allow_insecure | default(omit) }}"
|
|
allow_weak: "{{ item.allow_weak | default(omit) }}"
|
|
architectures: "{{ item.architectures | default(omit) }}"
|
|
by_hash: "{{ item.by_hash | default(omit) }}"
|
|
check_date: "{{ item.check_date | default(omit) }}"
|
|
check_valid_until: "{{ item.check_valid_until | default(omit) }}"
|
|
components: "{{ item.components | default(omit) }}"
|
|
date_max_future: "{{ item.date_max_future | default(omit) }}"
|
|
enabled: "{{ item.enabled | default(omit) }}"
|
|
inrelease_path: "{{ item.inrelease_path | default(omit) }}"
|
|
languages: "{{ item.languages | default(omit) }}"
|
|
mode: "{{ item.mode | default(omit) }}"
|
|
name: "{{ item.name }}"
|
|
pdiffs: "{{ item.pdiffs | default(omit) }}"
|
|
signed_by: "{{ item.signed_by | default(omit) }}"
|
|
state: "{{ item.state | default(omit) }}"
|
|
suites: "{{ item.suites | default(omit) }}"
|
|
targets: "{{ item.targets | default(omit) }}"
|
|
trusted: "{{ item.trusted | default(omit) }}"
|
|
types: "{{ item.types | default(omit) }}"
|
|
uris: "{{ item.uris | default(omit) }}"
|
|
with_items: "{{ rabbitmq_repo + rabbitmq_erlang_repo }}"
|
|
register: deb822_repos
|
|
|
|
- name: Update apt repositories when config is changed
|
|
apt:
|
|
update_cache: yes
|
|
when: (apt_repo_removed is changed) or (deb822_repos is changed)
|
|
|
|
- name: Install RabbitMQ package dependencies
|
|
apt:
|
|
pkg: "{{ rabbitmq_dependencies }}"
|
|
state: "{{ rabbitmq_package_state }}"
|
|
update_cache: yes
|
|
cache_valid_time: "{{ cache_timeout }}"
|
|
register: install_packages
|
|
until: install_packages is success
|
|
retries: 5
|
|
delay: 2
|
|
notify:
|
|
- RabbitMQ restart
|
|
tags:
|
|
- rabbitmq-apt-packages
|
|
|
|
- name: Install the RabbitMQ package deb
|
|
apt:
|
|
deb: "{{ rabbitmq_package_path }}"
|
|
register: install_rabbitmq
|
|
notify:
|
|
- RabbitMQ restart
|
|
when:
|
|
- rabbitmq_install_method == 'file'
|
|
tags:
|
|
- rabbitmq-package-deb
|
|
- rabbitmq-apt-packages
|
|
|
|
- name: Install RabbitMQ packages
|
|
package:
|
|
name: "{{ rabbitmq_distro_packages }}"
|
|
state: "{{ rabbitmq_package_state }}"
|
|
register: install_packages
|
|
until: install_packages is success
|
|
retries: 5
|
|
delay: 2
|
|
notify:
|
|
- RabbitMQ restart
|
|
when:
|
|
- rabbitmq_install_method != 'file'
|
|
tags:
|
|
- rabbitmq-apt-packages
|