Make rabbitmq inventory group configurable

The default value of "rabbitmq_all" remains, but this
change should allow deployers to target the role to multiple
groups now.

Change-Id: Idc1bc44b005f09f9dc7eb9778719a8ba92756c06
Implements: blueprint multi-rabbitmq-clusters
This commit is contained in:
Travis Truman 2016-07-12 11:21:33 -04:00
parent eb495e4d80
commit e4644a19fc
10 changed files with 24 additions and 13 deletions

View File

@ -16,7 +16,10 @@
## APT Cache Options ## APT Cache Options
cache_timeout: 600 cache_timeout: 600
rabbitmq_primary_cluster_node: "{{ hostvars[groups['rabbitmq_all'][0]]['ansible_hostname'] }}" # Inventory group containing the hosts for the cluster
rabbitmq_host_group: "rabbitmq_all"
rabbitmq_primary_cluster_node: "{{ hostvars[groups[rabbitmq_host_group][0]]['ansible_hostname'] }}"
# Upgrading the RabbitMQ package requires shutting down the cluster. This variable makes upgrading # Upgrading the RabbitMQ package requires shutting down the cluster. This variable makes upgrading
# the version an explicit action. # the version an explicit action.

View File

@ -0,0 +1,7 @@
---
features:
- The ``rabbitmq_server`` now supports a configurable inventory
host group. Deployers can override the ``rabbitmq_host_group`` variable
if they wish to use the role to create additional RabbitMQ clusters
on a custom host group.

View File

@ -56,7 +56,7 @@
rabbitmq_user: rabbitmq_user:
user: guest user: guest
state: absent state: absent
when: inventory_hostname == groups['rabbitmq_all'][0] when: inventory_hostname == groups[rabbitmq_host_group][0]
tags: tags:
- rabbitmq-user - rabbitmq-user
@ -64,6 +64,6 @@
rabbitmq_user: rabbitmq_user:
user: guest user: guest
state: absent state: absent
when: inventory_hostname != groups['rabbitmq_all'][0] when: inventory_hostname != groups[rabbitmq_host_group][0]
tags: tags:
- rabbitmq-user - rabbitmq-user

View File

@ -45,7 +45,7 @@
dest: /etc/hosts dest: /etc/hosts
state: present state: present
line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}" line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'].split('.')[0] }}"
with_items: "{{ groups['rabbitmq_all'] }}" with_items: "{{ groups[rabbitmq_host_group] }}"
tags: tags:
- rabbitmq-config - rabbitmq-config

View File

@ -16,7 +16,7 @@
- name: Distribute self signed ssl key - name: Distribute self signed ssl key
copy: copy:
dest: "{{ rabbitmq_ssl_key }}" dest: "{{ rabbitmq_ssl_key }}"
content: "{{ hostvars[groups['rabbitmq_all'][0]]['rabbitmq_ssl_key_fact'] | b64decode }}" content: "{{ hostvars[groups[rabbitmq_host_group][0]]['rabbitmq_ssl_key_fact'] | b64decode }}"
owner: "rabbitmq" owner: "rabbitmq"
group: "rabbitmq" group: "rabbitmq"
mode: "0640" mode: "0640"
@ -26,7 +26,7 @@
- name: Distribute self signed ssl cert - name: Distribute self signed ssl cert
copy: copy:
dest: "{{ rabbitmq_ssl_cert }}" dest: "{{ rabbitmq_ssl_cert }}"
content: "{{ hostvars[groups['rabbitmq_all'][0]]['rabbitmq_ssl_cert_fact'] | b64decode }}" content: "{{ hostvars[groups[rabbitmq_host_group][0]]['rabbitmq_ssl_cert_fact'] | b64decode }}"
owner: "rabbitmq" owner: "rabbitmq"
group: "rabbitmq" group: "rabbitmq"
mode: "0640" mode: "0640"

View File

@ -17,12 +17,12 @@
# RabbitMQ container. # RabbitMQ container.
- include: rabbitmq_ssl_key_create.yml - include: rabbitmq_ssl_key_create.yml
when: > when: >
inventory_hostname == groups['rabbitmq_all'][0] inventory_hostname == groups[rabbitmq_host_group][0]
- include: rabbitmq_ssl_key_store.yml - include: rabbitmq_ssl_key_store.yml
when: > when: >
inventory_hostname == groups['rabbitmq_all'][0] inventory_hostname == groups[rabbitmq_host_group][0]
- include: rabbitmq_ssl_key_distribute.yml - include: rabbitmq_ssl_key_distribute.yml
when: > when: >
inventory_hostname != groups['rabbitmq_all'][0] inventory_hostname != groups[rabbitmq_host_group][0]

View File

@ -4,10 +4,10 @@ container1 ansible_ssh_host=10.100.100.101 ansible_host=10.100.100.101 ansible_b
container2 ansible_ssh_host=10.100.100.102 ansible_host=10.100.100.102 ansible_become=True ansible_user=root container2 ansible_ssh_host=10.100.100.102 ansible_host=10.100.100.102 ansible_become=True ansible_user=root
container3 ansible_ssh_host=10.100.100.103 ansible_host=10.100.100.103 ansible_become=True ansible_user=root container3 ansible_ssh_host=10.100.100.103 ansible_host=10.100.100.103 ansible_become=True ansible_user=root
[rabbitmq_all] [rabbitmq_all_other]
container1 container1
container2 container2
container3 container3
[all_containers:children] [all_containers:children]
rabbitmq_all rabbitmq_all_other

View File

@ -16,7 +16,7 @@
# NOTE(mancdaz): rabbitmq cannot be upgraded in serial, so when # NOTE(mancdaz): rabbitmq cannot be upgraded in serial, so when
# rabbitmq_upgrade=True, serial is set to 0, else it is 1 for installs # rabbitmq_upgrade=True, serial is set to 0, else it is 1 for installs
- name: Install RabbitMQ server - name: Install RabbitMQ server
hosts: rabbitmq_all hosts: "{{ rabbitmq_host_group }}"
serial: "{{ rabbitmq_upgrade|default(false) | bool | ternary(0, 1)}}" serial: "{{ rabbitmq_upgrade|default(false) | bool | ternary(0, 1)}}"
user: root user: root
gather_facts: true gather_facts: true

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
- name: Run functional tests - name: Run functional tests
hosts: rabbitmq_all hosts: "{{ rabbitmq_host_group }}"
user: root user: root
gather_facts: true gather_facts: true
vars_files: vars_files:

View File

@ -1,3 +1,4 @@
rabbitmq_host_group: "rabbitmq_all_other"
rabbitmq_cookie_token: secrete rabbitmq_cookie_token: secrete
rabbitmq_ssl_cert: /etc/rabbitmq/rabbitmq.pem rabbitmq_ssl_cert: /etc/rabbitmq/rabbitmq.pem
rabbitmq_ssl_key: /etc/rabbitmq/rabbitmq.key rabbitmq_ssl_key: /etc/rabbitmq/rabbitmq.key