Made rabbitmq use host variables.
This commit is contained in:
parent
ef2360f814
commit
19a9d1d75e
@ -3,3 +3,5 @@
|
|||||||
become: True
|
become: True
|
||||||
roles:
|
roles:
|
||||||
- rabbitmq
|
- rabbitmq
|
||||||
|
vars:
|
||||||
|
hostname_node0: "{{ hostvars[groups['rabbitmq'][0]]['ansible_hostname'] }}"
|
||||||
|
@ -10,14 +10,14 @@ ExecStartPre=-/usr/bin/docker stop %n
|
|||||||
ExecStartPre=-/usr/bin/docker rm %n
|
ExecStartPre=-/usr/bin/docker rm %n
|
||||||
ExecStartPre=/usr/bin/docker pull rabbitmq:latest
|
ExecStartPre=/usr/bin/docker pull rabbitmq:latest
|
||||||
ExecStart=/usr/bin/docker run \
|
ExecStart=/usr/bin/docker run \
|
||||||
--add-host {{ hostvars[groups['rabbitmq'][0]]['ansible_hostname'] }}:{{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }} \
|
--add-host "{{ hostvars[groups['rabbitmq'][0]]['ansible_hostname'] }}:{{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}" \
|
||||||
--add-host {{ hostvars[groups['rabbitmq'][1]]['ansible_hostname'] }}:{{ hostvars[groups['rabbitmq'][1]]['ansible_default_ipv4']['address'] }} \
|
--add-host "{{ hostvars[groups['rabbitmq'][1]]['ansible_hostname'] }}:{{ hostvars[groups['rabbitmq'][1]]['ansible_default_ipv4']['address'] }}" \
|
||||||
--add-host {{ hostvars[groups['rabbitmq'][2]]['ansible_hostname'] }}:{{ hostvars[groups['rabbitmq'][2]]['ansible_default_ipv4']['address'] }} \
|
--add-host "{{ hostvars[groups['rabbitmq'][2]]['ansible_hostname'] }}:{{ hostvars[groups['rabbitmq'][2]]['ansible_default_ipv4']['address'] }}" \
|
||||||
-p 4369:4369 -p 25679:25679 -p 25672:25672 -p 5671-5672:5671-5672 -p 8080:15672 \
|
-p 4369:4369 -p 25679:25679 -p 25672:25672 -p 5671-5672:5671-5672 -p 8080:15672 \
|
||||||
-e "RABBITMQ_DEFAULT_USER=user" -e "RABBITMQ_DEFAULT_PASS=password" \
|
-e "RABBITMQ_DEFAULT_USER=user" -e "RABBITMQ_DEFAULT_PASS=password" \
|
||||||
-e "RABBITMQ_ERLANG_COOKIE=IHyW9HpfbXRL+pZkhGd8pA==" \
|
-e "RABBITMQ_ERLANG_COOKIE=IHyW9HpfbXRL+pZkhGd8pA==" \
|
||||||
-e "RABBITMQ_NODENAME=rabbit_{{ ansible_nodename }}" \
|
-e "RABBITMQ_NODENAME=rabbit_{{ ansible_nodename }}" \
|
||||||
--hostname "{{ansible_nodename}}" --name %n rabbitmq:3-management
|
--hostname "{{ ansible_nodename }}" --name %n rabbitmq:3-management
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@ -8,9 +8,18 @@
|
|||||||
mode: 644
|
mode: 644
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
|
|
||||||
- name: install service file
|
- name: install service file
|
||||||
command: systemctl daemon-reload
|
command: systemctl daemon-reload
|
||||||
|
|
||||||
- name: make sure service is started
|
- name: make sure service is started
|
||||||
systemd:
|
systemd:
|
||||||
name: rabbitmq.service
|
name: rabbitmq.service
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
|
#- name: setup the cluster
|
||||||
|
# command: "docker exec -i rabbitmq.service {{ item }}"
|
||||||
|
# with_items:
|
||||||
|
# - rabbitmqctl stop_app
|
||||||
|
# - "rabbitmqctl join_cluster rabbit_openstack01@{{ hostname_node0 }}"
|
||||||
|
# - rabbitmqctl start_app
|
||||||
|
Loading…
Reference in New Issue
Block a user