From 13e493c77a6283be28a45445fe3102929bd95832 Mon Sep 17 00:00:00 2001 From: Matthew Thode Date: Fri, 25 Jan 2019 01:26:10 -0600 Subject: [PATCH] add gentoo support to rabbitmq role Depends-On: https://review.openstack.org/633272 Change-Id: If5e248566911f7545d6f230fb67d98af08e336f8 --- tasks/install_portage.yml | 32 ++++++++++++++++++++++++++++++++ tasks/rabbitmq_post_install.yml | 10 ++++++++++ tasks/rabbitmq_started.yml | 4 ++-- tasks/rabbitmq_upgrade_check.yml | 12 ++++++++++++ vars/gentoo.yml | 22 ++++++++++++++++++++++ vars/main.yml | 16 ++++++++++++++++ 6 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 tasks/install_portage.yml create mode 100644 vars/gentoo.yml create mode 100644 vars/main.yml diff --git a/tasks/install_portage.yml b/tasks/install_portage.yml new file mode 100644 index 00000000..3bc1306e --- /dev/null +++ b/tasks/install_portage.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2019, Matthew Thode +# +# 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: Fail if installation method is not 'distro' + fail: + msg: "The only supported rabbitmq_install_method for openSUSE is 'distro'." + when: rabbitmq_install_method != 'distro' + +- name: Install the RabbitMQ package + portage: + name: "{{ rabbitmq_distro_packages }}" + state: "{{ rabbitmq_package_state }}" + newuse: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}" + changed_use: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}" + noreplace: "{{ (ansible_pkg_mgr == 'portage') | ternary('yes', omit) }}" + jobs: "{{ (ansible_pkg_mgr == 'portage') | ternary('4', omit) }}" + register: install_rabbitmq + tags: + - rabbitmq-package-portage + - rabbitmq-portage-packages diff --git a/tasks/rabbitmq_post_install.yml b/tasks/rabbitmq_post_install.yml index b1e3d0e4..b4182fb3 100644 --- a/tasks/rabbitmq_post_install.yml +++ b/tasks/rabbitmq_post_install.yml @@ -23,6 +23,16 @@ tags: - rabbitmq-config +- name: Create rabbitmq config directory + file: + path: "/etc/rabbitmq" + state: directory + group: "rabbitmq" + owner: "rabbitmq" + mode: 0755 + tags: + - rabbitmq-config + - name: Create rabbitmq config register: rabbit_config template: diff --git a/tasks/rabbitmq_started.yml b/tasks/rabbitmq_started.yml index ac23a7e4..62541fc8 100644 --- a/tasks/rabbitmq_started.yml +++ b/tasks/rabbitmq_started.yml @@ -15,7 +15,7 @@ - name: "Ensure RabbitMQ node [0] is started" service: - name: rabbitmq-server + name: "{{ rabbitmq_service_name }}" state: started enabled: yes when: @@ -27,7 +27,7 @@ - name: "Ensure RabbitMQ nodes [1:] are started" service: - name: rabbitmq-server + name: "{{ rabbitmq_service_name }}" state: started enabled: yes when: diff --git a/tasks/rabbitmq_upgrade_check.yml b/tasks/rabbitmq_upgrade_check.yml index 9a227683..cf2f70f3 100644 --- a/tasks/rabbitmq_upgrade_check.yml +++ b/tasks/rabbitmq_upgrade_check.yml @@ -46,6 +46,17 @@ - rabbitmq-zypper-packages - skip_ansible_lint +- name: Get version of installed RabbitMQ package (portage) + shell: "equery l net-misc/rabbitmq-server --format '$version' | tail -n 1" + failed_when: false + register: installed_rabbitmq_portage + when: + - not rabbitmq_upgrade | bool + - ansible_pkg_mgr == 'portage' + tags: + - rabbitmq-package-portage + - rabbitmq-portage-packages + - name: Register a fact for the installed RabbitMQ version set_fact: installed_rabbitmq: "{{ item }}" @@ -55,6 +66,7 @@ with_items: - "{{ installed_rabbitmq_deb }}" - "{{ installed_rabbitmq_rpm }}" + - "{{ installed_rabbitmq_portage }}" - name: Compare installed version of RabbitMQ with new version variable fail: diff --git a/vars/gentoo.yml b/vars/gentoo.yml new file mode 100644 index 00000000..b2716079 --- /dev/null +++ b/vars/gentoo.yml @@ -0,0 +1,22 @@ +--- +# Copyright 2019, Matthew Thode +# +# 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. + +_rabbitmq_install_method: distro +_rabbitmq_package_version: '' + +rabbitmq_service_name: "rabbitmq" + +rabbitmq_distro_packages: + - net-misc/rabbitmq-server diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 00000000..cf960a89 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2016, 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. + +rabbitmq_service_name: "rabbitmq-server"