diff --git a/defaults/main.yml b/defaults/main.yml index 647ff56d..c2666092 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,13 +26,11 @@ rabbitmq_upgrade: false # upgrade/version state can be ignored by setting `rabbitmq_ignore_version_state=true` rabbitmq_ignore_version_state: false -rabbitmq_package_url: "https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server_3.6.1-1_all.deb" -rabbitmq_package_version: "{{ rabbitmq_package_url.split('/')[-1].split('_')[1] }}" -rabbitmq_package_sha256: "0728fbdb14ec62712c6f931a7d91648cafbc6c30d8d4da790832e784b4d2e956" -rabbitmq_package_path: "/opt/rabbitmq-server.deb" - -rabbitmq_apt_packages: - - erlang-nox +rabbitmq_package_url: "{{ _rabbitmq_package_url }}" +rabbitmq_package_version: "{{ _rabbitmq_package_version }}" +rabbitmq_release_version: "{{ _rabbitmq_release_version }}" +rabbitmq_package_sha256: "{{ _rabbitmq_package_sha256 }}" +rabbitmq_package_path: "{{ _rabbitmq_package_path }}" rabbitmq_pip_packages: - pycrypto diff --git a/meta/main.yml b/meta/main.yml index 464906ce..dfa30df6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,11 +23,17 @@ galaxy_info: - name: Ubuntu versions: - trusty + - xenial + - name: EL + versions: + - 7 categories: - cloud - rabbitmq - development - openstack dependencies: - - apt_package_pinning - - pip_install \ No newline at end of file + - role: apt_package_pinning + when: + - ansible_pkg_mgr == 'apt' + - pip_install diff --git a/other-requirements.txt b/other-requirements.txt index 67cd643a..a145f8b4 100644 --- a/other-requirements.txt +++ b/other-requirements.txt @@ -14,7 +14,13 @@ # TODO(odyssey4me) remove this once https://review.openstack.org/288634 has merged # and the disk images are rebuilt and redeployed. curl +wget # Requirements for Paramiko 2.0 -libssl-dev -libffi-dev +libssl-dev [platform:dpkg] +libffi-dev [platform:dpkg] +libffi-devel [platform:rpm] +openssl-devel [platform:rpm] + +# For selinux +libselinux-python [platform:rpm] diff --git a/releasenotes/notes/deprecate-rabbitmq_apt_packages-b85ea1b449dc136e.yaml b/releasenotes/notes/deprecate-rabbitmq_apt_packages-b85ea1b449dc136e.yaml new file mode 100644 index 00000000..46caa819 --- /dev/null +++ b/releasenotes/notes/deprecate-rabbitmq_apt_packages-b85ea1b449dc136e.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - The ``rabbitmq_apt_packages`` variable has been deprecated. + ``rabbitmq_dependencies`` should be used instead to override + additional packages to install alongside rabbitmq-server. diff --git a/tasks/install_apt.yml b/tasks/install_apt.yml new file mode 100644 index 00000000..3a2ca818 --- /dev/null +++ b/tasks/install_apt.yml @@ -0,0 +1,50 @@ +--- +# 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. + +#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache +#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged +#in 1.9.x or we move to 2.0 (if tested working) +- name: Check apt last update file + stat: + path: /var/cache/apt + register: apt_cache_stat + tags: + - rabbitmq-apt-packages + +- name: Update apt if needed + apt: + update_cache: yes + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" + tags: + - rabbitmq-apt-packages + +- name: Install RabbitMQ package dependencies + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ rabbitmq_dependencies | deprecated(rabbitmq_apt_packages, 'rabbitmq_apt_packages', 'rabbitmq_dependencies', 'Ocata') }}" + tags: + - rabbitmq-apt-packages + +- name: Install the RabbitMQ package + apt: + deb: "{{ rabbitmq_package_path }}" + tags: + - rabbitmq-package-deb + - rabbitmq-apt-packages diff --git a/tasks/install_yum.yml b/tasks/install_yum.yml new file mode 100644 index 00000000..4b7f8f8b --- /dev/null +++ b/tasks/install_yum.yml @@ -0,0 +1,42 @@ +--- +# Copyright 2016, Walmart Stores, 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: Install epel-release package + yum: + name: epel-release + state: present + update_cache: yes + tags: + - rabbitmq-yum-packages + +- name: Install RabbitMQ package dependencies + yum: + pkg: "{{ item }}" + state: latest + update_cache: yes + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: rabbitmq_dependencies + tags: + - rabbitmq-yum-packages + +- name: Install the RabbitMQ package + yum: + name: "{{ rabbitmq_package_path }}" + tags: + - rabbitmq-package-rpm + - rabbitmq-yum-packages diff --git a/tasks/main.yml b/tasks/main.yml index 3f477bb5..2d8ef2cc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_release | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always - include: rabbitmq_pre_install.yml diff --git a/tasks/rabbitmq_install.yml b/tasks/rabbitmq_install.yml index 26d7cdcb..872fd1a0 100644 --- a/tasks/rabbitmq_install.yml +++ b/tasks/rabbitmq_install.yml @@ -15,41 +15,17 @@ - include: rabbitmq_upgrade_check.yml -#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache -#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged -#in 1.9.x or we move to 2.0 (if tested working) -- name: Check apt last update file - stat: - path: /var/cache/apt - register: apt_cache_stat +- include: install_apt.yml + when: + - ansible_pkg_mgr == 'apt' tags: - rabbitmq-apt-packages -- name: Update apt if needed - apt: - update_cache: yes - when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" +- include: install_yum.yml + when: + - ansible_pkg_mgr == 'yum' tags: - - rabbitmq-apt-packages - -- name: Install apt packages - apt: - pkg: "{{ item }}" - state: latest - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: rabbitmq_apt_packages - tags: - - rabbitmq-apt-packages - -- name: Install the RabbitMQ package - apt: - deb: "{{ rabbitmq_package_path }}" - tags: - - rabbitmq-package-deb - - rabbitmq-apt-packages + - rabbitmq-yum-packages - name: Install pip packages pip: diff --git a/tasks/rabbitmq_pre_install.yml b/tasks/rabbitmq_pre_install.yml index 4ad6fe4b..dc75f679 100644 --- a/tasks/rabbitmq_pre_install.yml +++ b/tasks/rabbitmq_pre_install.yml @@ -21,6 +21,8 @@ - rabbitmq-upgrade - rabbitmq-package-deb - rabbitmq-package-deb-get + - rabbitmq-package-rpm + - rabbitmq-package-rpm-get - name: Download the RabbitMQ package get_url: @@ -35,6 +37,8 @@ tags: - rabbitmq-package-deb - rabbitmq-package-deb-get + - rabbitmq-package-rpm + - rabbitmq-package-rpm-get - name: Fix /etc/hosts lineinfile: diff --git a/tasks/rabbitmq_started.yml b/tasks/rabbitmq_started.yml index f76369fc..dcf1574b 100644 --- a/tasks/rabbitmq_started.yml +++ b/tasks/rabbitmq_started.yml @@ -17,6 +17,7 @@ service: name: rabbitmq-server state: started + enabled: yes failed_when: false when: > ansible_hostname == rabbitmq_primary_cluster_node @@ -29,6 +30,7 @@ service: name: rabbitmq-server state: started + enabled: yes failed_when: false when: > ansible_hostname != rabbitmq_primary_cluster_node diff --git a/tasks/rabbitmq_upgrade_check.yml b/tasks/rabbitmq_upgrade_check.yml index 8513adfa..e744324e 100644 --- a/tasks/rabbitmq_upgrade_check.yml +++ b/tasks/rabbitmq_upgrade_check.yml @@ -13,26 +13,48 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Get version of installed RabbitMQ package +- name: Get version of installed RabbitMQ package (deb) shell: | dpkg -l | grep rabbitmq-server failed_when: false - register: installed_rabbitmq + register: installed_rabbitmq_deb when: - not rabbitmq_upgrade | bool + - ansible_pkg_mgr == 'apt' tags: - rabbitmq-package-deb - rabbitmq-apt-packages +- name: Get version of installed RabbitMQ package (rpm) + shell: | + rpm -qa | grep rabbitmq-server + failed_when: false + register: installed_rabbitmq_rpm + when: + - not rabbitmq_upgrade | bool + - ansible_pkg_mgr == 'yum' + tags: + - rabbitmq-package-rpm + - rabbitmq-apt-packages + +- name: Register a fact for the installed RabbitMQ version + set_fact: + installed_rabbitmq: "{{ item }}" + when: not item | skipped and item | changed + with_items: + - "{{ installed_rabbitmq_deb }}" + - "{{ installed_rabbitmq_rpm }}" + - name: Compare installed version of RabbitMQ with new version variable fail: msg: "To install a new major/minor version of RabbitMQ set '-e rabbitmq_upgrade=true'." - when: > - not rabbitmq_upgrade | bool and - installed_rabbitmq.rc == 0 and - installed_rabbitmq.stdout.split()[2] != rabbitmq_package_version + when: + - not rabbitmq_upgrade | bool + - installed_rabbitmq.rc == 0 + - not installed_rabbitmq.stdout | search(rabbitmq_package_version) tags: - rabbitmq-package-deb + - rabbitmq-package-rpm - rabbitmq-apt-packages - include: rabbitmq_upgrade_prep.yml diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml index fcff2f98..83ce0212 100644 --- a/tests/group_vars/all_containers.yml +++ b/tests/group_vars/all_containers.yml @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - container_name: "{{ inventory_hostname }}" container_networks: management_address: diff --git a/tests/test-prepare-containers.yml b/tests/test-prepare-containers.yml index efca943a..ce0e5d29 100644 --- a/tests/test-prepare-containers.yml +++ b/tests/test-prepare-containers.yml @@ -15,7 +15,6 @@ - name: Create test containers hosts: all_containers - connection: local gather_facts: false pre_tasks: - name: Destroy test containers @@ -40,7 +39,6 @@ - container-directories roles: - role: "lxc_container_create" - lxc_container_release: trusty lxc_container_backing_store: dir global_environment_variables: PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml index 21ee39ee..cfe8841b 100644 --- a/tests/test-prepare-host.yml +++ b/tests/test-prepare-host.yml @@ -20,6 +20,13 @@ - name: Ensure apt cache is always refreshed apt: update_cache: yes + when: ansible_pkg_mgr == 'apt' + - name: Ensure yum packages are up to date + yum: + name: '*' + state: latest + update_cache: yes + when: ansible_pkg_mgr == 'yum' - name: Ensure root's new public ssh key is in authorized_keys authorized_key: user: root @@ -31,20 +38,31 @@ stat: path: /etc/nodepool/provider register: nodepool - - name: Set the files to copy into the container cache for OpenStack-CI instances + - name: Set the files to copy into the container cache for OpenStack-CI instances (deb) set_fact: lxc_container_cache_files: - { src: '/etc/pip.conf', dest: '/etc/pip.conf' } - { src: '/etc/apt/apt.conf.d/99unauthenticated', dest: '/etc/apt/apt.conf.d/99unauthenticated' } - when: nodepool.stat.exists | bool + when: + - nodepool.stat.exists | bool + - ansible_pkg_mgr == 'apt' + - name: Set the files to copy into the container cache for OpenStack-CI instances (rhel) + set_fact: + lxc_container_cache_files: + - { src: '/etc/pip.conf', dest: '/etc/pip.conf' } + when: + - nodepool.stat.exists | bool + - ansible_pkg_mgr == 'yum' - name: Determine the existing Ubuntu repo configuration shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list' register: ubuntu_repo changed_when: false + when: ansible_pkg_mgr == 'apt' - name: Set apt repo facts based on discovered information set_fact: lxc_container_template_main_apt_repo: "{{ ubuntu_repo.stdout }}" lxc_container_template_security_apt_rep: "{{ ubuntu_repo.stdout }}" + when: ansible_pkg_mgr == 'apt' roles: - role: "lxc_hosts" lxc_net_address: 10.100.100.1 @@ -52,8 +70,3 @@ lxc_net_bridge: lxcbr0 lxc_kernel_options: - { key: 'fs.inotify.max_user_instances', value: 1024 } - lxc_container_caches: - - url: "https://rpc-repo.rackspace.com/container_images/rpc-trusty-container.tgz" - name: "trusty.tgz" - sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c" - chroot_path: trusty/rootfs-amd64 diff --git a/tests/test-functional.yml b/tests/test-rabbitmq-server-functional.yml similarity index 96% rename from tests/test-functional.yml rename to tests/test-rabbitmq-server-functional.yml index f19c6df4..9d48c5d0 100644 --- a/tests/test-functional.yml +++ b/tests/test-rabbitmq-server-functional.yml @@ -1,5 +1,5 @@ --- -# Copyright 2015, Rackspace US, Inc. +# 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. @@ -64,4 +64,4 @@ - hostvars['container1']['rabbitmq_ssl_key_checksum'] == hostvars['container2']['rabbitmq_ssl_key_checksum'] == hostvars['container3']['rabbitmq_ssl_key_checksum'] - name: Ensure expected version of rabbitmq is running assert: - that: rabbitmqctl_status.stdout | search ("rabbit,\"RabbitMQ\",\"{{ rabbitmq_package_version.split('-')[0] }}\"") + that: rabbitmqctl_status.stdout | search ("rabbit,\"RabbitMQ\",\"{{ rabbitmq_release_version }}\"") diff --git a/tests/test-vars.yml b/tests/test-vars.yml index 8d29d89a..8ada58ed 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -1,3 +1,11 @@ rabbitmq_cookie_token: secrete rabbitmq_ssl_cert: /etc/rabbitmq/rabbitmq.pem rabbitmq_ssl_key: /etc/rabbitmq/rabbitmq.key + +rabbitmq_old_package: + debian: + rabbitmq_package_url: "https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.7/rabbitmq-server_3.5.7-1_all.deb" + rabbitmq_package_sha256: "b8a42321c2f2689dc579911fbb583bd9c4d2ce2f20003d7050d5a324a6d2de42" + redhat: + rabbitmq_package_url: "http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.7/rabbitmq-server-3.5.7-1.noarch.rpm" + rabbitmq_package_sha256: "5469b049d6444d95d917634da1e167cb678060920faec606788804a63356ba40" diff --git a/tests/test.yml b/tests/test.yml index aa01a4fb..5341b263 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -26,9 +26,9 @@ - include: test-install-rabbitmq-server.yml # Run tests -- include: test-functional.yml +- include: test-rabbitmq-server-functional.yml vars: - rabbitmq_package_version: "3.6.1-1" + rabbitmq_release_version: "3.6.1" ############################# UPGRADE TESTING ############################# @@ -38,14 +38,13 @@ # Install previous version of RabbitMQ server - include: test-install-rabbitmq-server.yml vars: - rabbitmq_package_url: "https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.7/rabbitmq-server_3.5.7-1_all.deb" - rabbitmq_package_version: "{{ rabbitmq_package_url.split('/')[-1].split('_')[1] }}" - rabbitmq_package_sha256: "b8a42321c2f2689dc579911fbb583bd9c4d2ce2f20003d7050d5a324a6d2de42" + rabbitmq_package_url: "{{ rabbitmq_old_package[ansible_os_family | lower]['rabbitmq_package_url'] }}" + rabbitmq_package_sha256: "{{ rabbitmq_old_package[ansible_os_family | lower]['rabbitmq_package_sha256'] }}" # Run tests -- include: test-functional.yml +- include: test-rabbitmq-server-functional.yml vars: - rabbitmq_package_version: "3.5.7-1" + rabbitmq_release_version: "3.5.7" # Perform upgrade of RabbitMQ server (package_version will come # from role defaults) @@ -54,6 +53,6 @@ rabbitmq_upgrade: true # Run tests -- include: test-functional.yml +- include: test-rabbitmq-server-functional.yml vars: - rabbitmq_package_version: "3.6.1-1" + rabbitmq_release_version: "3.6.1" diff --git a/tests/vars/debian.yml b/tests/vars/debian.yml new file mode 100644 index 00000000..3e12b04a --- /dev/null +++ b/tests/vars/debian.yml @@ -0,0 +1,17 @@ +--- +# Copyright 2016, Walmart Stores, 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_package_url: "https://www.rabbitmq.com/releases/rabbitmq-server/v3.5.7/rabbitmq-server_3.5.7-1_all.deb" +rabbitmq_package_sha256: "b8a42321c2f2689dc579911fbb583bd9c4d2ce2f20003d7050d5a324a6d2de42" diff --git a/tests/vars/redhat.yml b/tests/vars/redhat.yml new file mode 100644 index 00000000..1a006358 --- /dev/null +++ b/tests/vars/redhat.yml @@ -0,0 +1,17 @@ +--- +# Copyright 2016, Walmart Stores, 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_package_url: "http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.7/rabbitmq-server-3.5.7-1.noarch.rpm" +rabbitmq_package_sha256: "5469b049d6444d95d917634da1e167cb678060920faec606788804a63356ba40" diff --git a/vars/debian.yml b/vars/debian.yml new file mode 100644 index 00000000..b75892fd --- /dev/null +++ b/vars/debian.yml @@ -0,0 +1,25 @@ +--- +# Copyright 2016, Walmart Stores, 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_package_url: "https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server_3.6.1-1_all.deb" +_rabbitmq_package_version: "{{ rabbitmq_package_url.split('/')[-1].split('_')[1] }}" +_rabbitmq_release_version: "{{ rabbitmq_package_version.split('-')[0] }}" +_rabbitmq_package_sha256: "0728fbdb14ec62712c6f931a7d91648cafbc6c30d8d4da790832e784b4d2e956" +_rabbitmq_package_path: "/opt/rabbitmq-server.deb" + +rabbitmq_dependencies: + - erlang-nox + - gcc + - python-dev diff --git a/vars/redhat.yml b/vars/redhat.yml new file mode 100644 index 00000000..40e72c42 --- /dev/null +++ b/vars/redhat.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2016, Walmart Stores, 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_package_url: "https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-3.6.1-1.noarch.rpm" +_rabbitmq_package_version: "{{ rabbitmq_package_url.split('/')[-1].rsplit('.', 1)[0] }}" +_rabbitmq_release_version: "{{ rabbitmq_package_version.split('-')[2] }}" +_rabbitmq_package_sha256: "b688950915289a8596bdce35086b00ad08ee0e32567396c5bda850854642fac7" +_rabbitmq_package_path: "/opt/rabbitmq-server.rpm" + +rabbitmq_dependencies: + - erlang + - gcc + - openssl + - python-devel