From a0b0733be04355f253274b40e7d65845321a222b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 21 May 2018 15:41:30 -0400 Subject: [PATCH] install through most of config setup --- defaults/main.yml | 43 +++++++++++++++++++++++++++++++- tasks/qdrouterd_post_install.yml | 20 +++++++++++++++ tasks/qdrouterd_pre_install.yml | 22 ++-------------- templates/qdrouterd.conf.j2 | 32 ++++++++++++++++-------- vars/main.yml | 1 - vars/redhat.yml | 7 +++--- 6 files changed, 88 insertions(+), 37 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index b177844..85645e2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,43 @@ --- -# defaults 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. +# defaults file for ansible-qdrouterd + +# Package install state, options are 'present' and 'latest' +qdrouterd_package_state: "latest" + +# Inventory group containg the hosts for the mesh +qdrouterd_host_group: "qdrouterd_all" + +# Qdrouterd Service config +qdrouterd_service_name: "{{ _qdrouterd_service_name }}" +qdrouterd_etc_conf_path: "{{ _qdrouterd_etc_conf_path }}" +qdrouterd_etc_conf_file: "{{ _qdrouterd_etc_conf_file }}" +qdrouterd_log_file: "/var/log/qdrouterd/qdrouterd.log" + +# Qdrouterd router config +qdrouterd_host_count: "{{ groups['qdrouterd_all'] | length}}" +qdrouterd_mode: "{% if qdrouterd_host_count == '1' %}standalone{% else %}interior{% endif %}" +qdrouterd_listener_addr: 0.0.0.0 +qdrouterd_listener_port: 31459 +qdrouterd_listener_auth_peer: "no" +qdrouterd_listener_sasl_mech: "ANONYMOUS" +qdrouterd_irl_addr: 0.0.0.0 +qdrouterd_irl_port: 31460 +qdrouterd_mode: "standalone" +qdrouterd_worker_threads: 4 +qdrouterd_sasl_conf_path: "/etc/sasl2/" +qdrouterd_sasl_conf_file: "/etc/sasl2/qdrouterd.conf" +qdrouterd_log_module: "DEFAULT" +qdrouterd_log_enable: "info+" diff --git a/tasks/qdrouterd_post_install.yml b/tasks/qdrouterd_post_install.yml index 60c5064..107f022 100644 --- a/tasks/qdrouterd_post_install.yml +++ b/tasks/qdrouterd_post_install.yml @@ -26,6 +26,26 @@ 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 + - 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 index 8c5c145..e6ac27c 100644 --- a/tasks/qdrouterd_pre_install.yml +++ b/tasks/qdrouterd_pre_install.yml @@ -12,10 +12,10 @@ # 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/" + path: "{{ qdrouterd_etc_conf_path }}" state: "directory" group: "root" owner: "root" @@ -23,22 +23,4 @@ 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/templates/qdrouterd.conf.j2 b/templates/qdrouterd.conf.j2 index 4df7fa7..504b935 100644 --- a/templates/qdrouterd.conf.j2 +++ b/templates/qdrouterd.conf.j2 @@ -1,19 +1,28 @@ router { - mode: standalone - id: Router.A - workerThreads: 4 - saslConfigPath: /etc/sasl2 - saslConfigName: qdrouterd + mode: {{ qdrouterd_mode }} + id: {{ ansible_hostname }} + workerThreads: {{ qdrouterd_host_count }} + saslConfigPath: {{ qdrouterd_sasl_conf_path }} + saslConfigName: {{ qdrouterd_service_name }} } listener { - host: {{ ansible_hostname }} - port: {{ qdrouterd_port }} + host: {{ qdrouterd_listener_addr }} + port: {{ qdrouterd_listener_port }} role: normal - authenticatePeer: no + authenticatePeer: {{ qdrouterd_listener_auth_peer }} + saslMechanisms: {{ qdrouterd_listener_sasl_mech }} } +{% if qdrouterd_host_count > '1' %} +listener { + host: {{ qdrouterd_irl_addr }} + port: {{ qdrouterd_irl_port }} + role: inter-router +} +{% endif %} + address { prefix: unicast distribution: closest @@ -52,7 +61,8 @@ address { } log { - module: DEFAULT - enable: info+ - output: /var/log/qdrouterd/qdrouterd.log + module: {{ qdrouterd_log_module }} + enable: {{ qdrouterd_log_enable }} + timestamp: true + output: {{ qdrouterd_log_file }} } diff --git a/vars/main.yml b/vars/main.yml index 78588b1..0293fe0 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,2 @@ --- # vars file for ansible-qdrouterd -qdrouterd_port: 5672 diff --git a/vars/redhat.yml b/vars/redhat.yml index f2d869c..b8b8075 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -20,10 +20,9 @@ qdrouterd_distro_packages: - 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" +_qdrouterd_etc_conf_path: "/etc/qpid-dispatch/" +_qdrouterd_etc_conf_file: "/etc/qpid-dispatch/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 }}"