From 7cfe3675f26f6188211b94dce4de83cf040c1471 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 14 May 2018 15:58:18 -0400 Subject: [PATCH] added tasks --- meta/main.yml | 84 +++++++------------- tasks/main.yml | 34 +++++++- tasks/qdrouterd_install.yml | 34 ++++++++ tasks/qdrouterd_install_apt.yml | 22 +++++ tasks/qdrouterd_install_yum.yml | 48 +++++++++++ tasks/qdrouterd_post_install.yml | 31 ++++++++ tasks/qdrouterd_pre_install.yml | 44 ++++++++++ tasks/qdrouterd_restart.yml | 19 +++++ tasks/qdrouterd_started.yml | 24 ++++++ tasks/qdrouterd_stopped.yml | 24 ++++++ templates/qdrouterd-sasl.conf.j2 | 4 + templates/qdrouterd.conf.j2 | 58 ++++++++++++++ templates/qdrouterd.json.j2 | 29 +++++++ templates/systemd-restart-on-failure.conf.j2 | 4 + vars/main.yml | 3 +- vars/redhat.yml | 30 +++++++ vars/ubuntu.yml | 29 +++++++ 17 files changed, 465 insertions(+), 56 deletions(-) create mode 100644 tasks/qdrouterd_install.yml create mode 100644 tasks/qdrouterd_install_apt.yml create mode 100644 tasks/qdrouterd_install_yum.yml create mode 100644 tasks/qdrouterd_post_install.yml create mode 100644 tasks/qdrouterd_pre_install.yml create mode 100644 tasks/qdrouterd_restart.yml create mode 100644 tasks/qdrouterd_started.yml create mode 100644 tasks/qdrouterd_stopped.yml create mode 100644 templates/qdrouterd-sasl.conf.j2 create mode 100644 templates/qdrouterd.conf.j2 create mode 100644 templates/qdrouterd.json.j2 create mode 100644 templates/systemd-restart-on-failure.conf.j2 create mode 100644 vars/redhat.yml create mode 100644 vars/ubuntu.yml diff --git a/meta/main.yml b/meta/main.yml index 7223799..dd11f94 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,57 +1,33 @@ +--- +# Copyright 2018, Red Hat, 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. galaxy_info: - author: your name - description: your description - company: your company (optional) - - # If the issue tracker for your role is not on github, uncomment the - # next line and provide a value - # issue_tracker_url: http://example.com/issue/tracker - - # Some suggested licenses: - # - BSD (default) - # - MIT - # - GPLv2 - # - GPLv3 - # - Apache - # - CC-BY - license: license (GPLv2, CC-BY, etc) - - min_ansible_version: 1.2 - - # If this a Container Enabled role, provide the minimum Ansible Container version. - # min_ansible_container_version: - - # Optionally specify the branch Galaxy will use when accessing the GitHub - # repo for this role. During role install, if no tags are available, - # Galaxy will use this branch. During import Galaxy will access files on - # this branch. If Travis integration is configured, only notifications for this - # branch will be accepted. Otherwise, in all cases, the repo's default branch - # (usually master) will be used. - #github_branch: - - # - # platforms is a list of platforms, and each platform has a name and a list of versions. - # - # platforms: - # - name: Fedora - # versions: - # - all - # - 25 - # - name: SomePlatform - # versions: - # - all - # - 1.0 - # - 7 - # - 99.99 - - galaxy_tags: [] - # List tags for your role here, one per line. A tag is a keyword that describes - # and categorizes the role. Users find roles by searching for tags. Be sure to - # remove the '[]' above, if you add tags to this list. - # - # NOTE: A tag is limited to a single word comprised of alphanumeric characters. - # Maximum 20 tags per role. + author: Andy Smith + description: This role installs and configures the qpid-dispatch-router + license: Apache + min_ansible_version: 2.3 + platforms: + - name: EL + versions: + - 7 + - name: Ubuntu + versions: + - trusty + - xenial + categories: + - messaging + - cloud + - openstack dependencies: [] - # List your role dependencies here, one per line. Be sure to remove the '[]' above, - # if you add dependencies to this list. \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index aa4bfd2..c1ea6e7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,34 @@ --- -# tasks file for ansible-qdrouterd \ No newline at end of file +# Copyright 2018, Red Hat, 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: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + +- include: qdrouterd_pre_install.yml + +- include: qdrouterd_install.yml + static: no + +- include: qdrouterd_post_install.yml + + diff --git a/tasks/qdrouterd_install.yml b/tasks/qdrouterd_install.yml new file mode 100644 index 0000000..92aa2a7 --- /dev/null +++ b/tasks/qdrouterd_install.yml @@ -0,0 +1,34 @@ +--- +# Copyright 2018, Red Hat, 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. + +- include: "qdrouterd_install_{{ ansible_pkg_mgr }}.yml" + tags: + - qdrouterd-apt-packages + - qdrouterd-yum-packages + - qdrouterd_server-install + +- name: Reload the systemd daemon + systemd: + daemon_reload: yes + when: + - install_qdrouterd | changed + tags: + - qdrouterd-apt-packages + - qdrouterd-yum-packages + - qdrouterd_server-install + +- include: qdrouterd_started.yml + tags: + - qdrouterd_server-config diff --git a/tasks/qdrouterd_install_apt.yml b/tasks/qdrouterd_install_apt.yml new file mode 100644 index 0000000..6a44471 --- /dev/null +++ b/tasks/qdrouterd_install_apt.yml @@ -0,0 +1,22 @@ +--- +# Copyright 2018, Red Hat, 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 Qpid Dispatch Router (qdrouterd) packages + apt: + name: "{{ qdrouterd_distro_packages }}" + state: "{{ qdrouterd_server_package_state }}" + register: install_qdrouterd + tags: + - qdrouterd-apt-packages diff --git a/tasks/qdrouterd_install_yum.yml b/tasks/qdrouterd_install_yum.yml new file mode 100644 index 0000000..5bbb4eb --- /dev/null +++ b/tasks/qdrouterd_install_yum.yml @@ -0,0 +1,48 @@ +--- +# Copyright 2018, Red Hat, 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: Check if EPEL repo is already configured. + stat: path={{ epel_repofile_path }} + register: epel_repofile_result + +- name: Install EPEL repo. + yum: + name: "{{ epel_repo_url }}" + state: present + register: result + when: not epel_repofile_result.stat.exists + +- name: Import EPEL GPG key + rpm_key: + key: "{{ epel_repo_gpg_key_url }}" + state: present + when: not epel_repofile_result.stat.exists + +- name: Ensure yum-config-manager is installed + package: + name: yum-utils + state: present + +- name: Ensure that EPEL is enabled + shell: yum-config-manager --enable epel + +- name: Install Qpid Dispatch Router (qdrouterd) packages + yum: + name: "{{ qdrouterd_distro_packages }}" + state: "{{ qdrouterd_package_state }}" + enablerepo: epel + register: install_qdrouterd + tags: + - qdrouterd-yum-packages diff --git a/tasks/qdrouterd_post_install.yml b/tasks/qdrouterd_post_install.yml new file mode 100644 index 0000000..60c5064 --- /dev/null +++ b/tasks/qdrouterd_post_install.yml @@ -0,0 +1,31 @@ +--- +# Copyright 2018, Red Hat, 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: Create qdrouterd config + register: qdrouterd_config_changed + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: "{{ qdrouterd_service_name }}" + mode: "0600" + with_items: + - { src: "qdrouterd.conf.j2", dest: "{{ qdrouterd_etc_conf_file }}" } + - { src: "qdrouterd-sasl.conf.j2", dest: "{{ qdrouterd_sasl_conf_file }}" } + tags: + - qdrouterd-config + +- include: qdrouterd_restart.yml + static: no + when: qdrouterd_config_changed|changed diff --git a/tasks/qdrouterd_pre_install.yml b/tasks/qdrouterd_pre_install.yml new file mode 100644 index 0000000..8c5c145 --- /dev/null +++ b/tasks/qdrouterd_pre_install.yml @@ -0,0 +1,44 @@ +--- +# Copyright 2018, Red Hat, 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: Create the local directories + file: + path: "/etc/qpid-dispatch/" + state: "directory" + group: "root" + owner: "root" + mode: "0755" + tags: + - qdrouterd-config + +- name: Create the log directory + file: + path: "/var/lib/qdrouterd/" + state: "directory" + group: "qdrouterd" + owner: "qdrouterd" + recurse: true + tags: + - qdrouterd-config + +- name: Create the log directory + file: + path: "/var/log/qdrouterd/" + state: "directory" + group: "qdrouterd" + owner: "qdrouterd" + recurse: true + tags: + - qdrouterd-config diff --git a/tasks/qdrouterd_restart.yml b/tasks/qdrouterd_restart.yml new file mode 100644 index 0000000..a14733b --- /dev/null +++ b/tasks/qdrouterd_restart.yml @@ -0,0 +1,19 @@ +--- +# Copyright 2018, Red Hat, 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. + +- include: qdrouterd_stopped.yml +- include: qdrouterd_started.yml + + diff --git a/tasks/qdrouterd_started.yml b/tasks/qdrouterd_started.yml new file mode 100644 index 0000000..851fb2a --- /dev/null +++ b/tasks/qdrouterd_started.yml @@ -0,0 +1,24 @@ +--- +# Copyright 2018, Red Hat, 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: Ensure Qpid Dispatch Router is started + service: + name: "{{ qdrouterd_service_name }}" + state: started + enabled: yes + tags: + - qdrouterd-server-started + - qdrouterd-upgrade + - qdrouterd-start diff --git a/tasks/qdrouterd_stopped.yml b/tasks/qdrouterd_stopped.yml new file mode 100644 index 0000000..269f184 --- /dev/null +++ b/tasks/qdrouterd_stopped.yml @@ -0,0 +1,24 @@ +--- +# Copyright 2018, Red Hat, 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: Ensure Qpid Dispatch Router is stopped + service: + name: "{{ qdrouterd_service_name }}" + state: stopped + failed_when: false + tags: + - qdrouterd-server-stopped + - qdrouterd-upgrade + - qdrouterd-stop diff --git a/templates/qdrouterd-sasl.conf.j2 b/templates/qdrouterd-sasl.conf.j2 new file mode 100644 index 0000000..bf21363 --- /dev/null +++ b/templates/qdrouterd-sasl.conf.j2 @@ -0,0 +1,4 @@ +pwcheck_method: auxprop +auxprop_plugin: sasldb +sasldb_path: /var/lib/qdrouterd/qdrouterd.sasldb +mech_list: ANONYMOUS PLAIN diff --git a/templates/qdrouterd.conf.j2 b/templates/qdrouterd.conf.j2 new file mode 100644 index 0000000..4df7fa7 --- /dev/null +++ b/templates/qdrouterd.conf.j2 @@ -0,0 +1,58 @@ + +router { + mode: standalone + id: Router.A + workerThreads: 4 + saslConfigPath: /etc/sasl2 + saslConfigName: qdrouterd +} + +listener { + host: {{ ansible_hostname }} + port: {{ qdrouterd_port }} + role: normal + authenticatePeer: no +} + +address { + prefix: unicast + distribution: closest +} +address { + prefix: exclusive + distribution: closest +} +address { + prefix: broadcast + distribution: multicast +} +address { + prefix: openstack.org/om/rpc/multicast + distribution: multicast +} +address { + prefix: openstack.org/om/rpc/unicast + distribution: closest +} +address { + prefix: openstack.org/om/rpc/anycast + distribution: balanced +} +address { + prefix: openstack.org/om/notify/multicast + distribution: multicast +} +address { + prefix: openstack.org/om/notify/unicast + distribution: closest +} +address { + prefix: openstack.org/om/notify/anycast + distribution: balanced +} + +log { + module: DEFAULT + enable: info+ + output: /var/log/qdrouterd/qdrouterd.log +} diff --git a/templates/qdrouterd.json.j2 b/templates/qdrouterd.json.j2 new file mode 100644 index 0000000..193ec19 --- /dev/null +++ b/templates/qdrouterd.json.j2 @@ -0,0 +1,29 @@ +{ + "command": "/usr/sbin/qdrouterd", + "config_files": [ + { + "source": "{{ container_config_directory }}/qdrouterd.conf", + "dest": "/etc/qpid-dispatch/qdrouterd.conf", + "owner": "qdrouterd", + "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/qdrouterd-sasl.conf", + "dest": "/etc/sasl2/qdrouterd.conf", + "owner": "qdrouterd", + "perm": "0600" + } + ], + "permissions": [ + { + "path": "/var/lib/qdrouterd", + "owner": "qdrouterd:qdrouterd", + "recurse": true + }, + { + "path": "/var/log/kolla/qdrouterd", + "owner": "qdrouterd:qdrouterd", + "recurse": true + } + ] +} diff --git a/templates/systemd-restart-on-failure.conf.j2 b/templates/systemd-restart-on-failure.conf.j2 new file mode 100644 index 0000000..8acdc0f --- /dev/null +++ b/templates/systemd-restart-on-failure.conf.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} +[Service] +Restart=on-failure +RestartSec=2 diff --git a/vars/main.yml b/vars/main.yml index f178b0b..78588b1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,3 @@ --- -# vars file for ansible-qdrouterd \ No newline at end of file +# vars file for ansible-qdrouterd +qdrouterd_port: 5672 diff --git a/vars/redhat.yml b/vars/redhat.yml new file mode 100644 index 0000000..f2d869c --- /dev/null +++ b/vars/redhat.yml @@ -0,0 +1,30 @@ +--- +# Copyright 2018, Red Hat, 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. + +qdrouterd_distro_packages: + - python-qpid-proton + - cyrus-sasl-lib + - cyrus-sasl-plain + - qpid-dispatch-router + - qpid-dispatch-tools + +qdrouterd_package_state: "latest" +qdrouterd_etc_conf_file: "/etc/qpid-dispatch/qdrouterd.conf" +qdrouterd_sasl_conf_file: "/etc/sasl2/qdrouterd.conf" +qdrouterd_service_name: "qdrouterd" + +epel_repo_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" +epel_repo_gpg_key_url: "https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}" +epel_repofile_path: "/etc/yum.repos.d/epel.repo" diff --git a/vars/ubuntu.yml b/vars/ubuntu.yml new file mode 100644 index 0000000..0201aed --- /dev/null +++ b/vars/ubuntu.yml @@ -0,0 +1,29 @@ +--- +# Copyright 2018, Red Hat, 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. + +qdrouterd_distro_packages: + - python-qpid-proton + - sasl2-bin + - libpython-2.2 + - qdrouterd + +qdrouterd_package_name: "qdrouterd" +qdrouterd_service_name: "qdrouterd" +qdrouterd_etc_conf_file: "/etc/qpid-dispatch/qdrouterd.conf" + +# repo details for qpid ppa +qdrouterd_ppa_repo: "ppa:qpid/released" +qdrouterd_ppa_keyid: 4096R/4D8EB5FDA37AB55F41A135203BF88A0C6A770882 +qdrouterd_ppa_keyserver: "keyserver.ubuntu.com"