aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-rabbitmq.yml
blob: d34265907a1366085398bab3a3085084e5f3de58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
#- hosts: config
#  sudo: yes
#  tasks:
- name: turn off rabbitmq server on control node
  shell: sed -i '/rabbitmq-server/d' /opt/service ;

- name: "start supervisor support service"
  service:
    name: "supervisor-support-service"
    state: "started"

- name: "stop rabbitmq server via supervisor"
  supervisorctl:
    name: "rabbitmq-server"
    state: "stopped"
    server_url: "unix:///tmp/supervisord_support_service.sock"

- include: -rabbitmq-stop.yml

- name: "update hosts"
  lineinfile:
    dest: "/etc/hosts"
    line: "{{ ip_settings[item]['br-prv']['ip'] }}\t{{ hostvars[item]['ansible_hostname'] }} {{ hostvars[item]['ansible_hostname'] }}-ctrl"
  with_items: groups['opencontrail']

- name: "fix up rabbitmq env"
  template:
    src: "../../templates/provision/rabbitmq-env-conf.j2"
    dest: "/etc/rabbitmq/rabbitmq-env.conf"

- name: "fix up rabbitmq config for single node"
  template:
    src: "../../templates/provision/rabbitmq-conf-single.j2"
    dest: "/etc/rabbitmq/rabbitmq.config"
  when: groups['opencontrail'][1] is not defined

- name: fix up rabbitmq config for multi nodes
  template:
    src: "../../templates/provision/rabbitmq-conf.j2"
    dest: "/etc/rabbitmq/rabbitmq.config"
  when: groups['opencontrail'][1] is defined

- include: -rabbitmq-stop.yml

#- name: "create cookie uuid temporary"
#  local_action:
#    module: "template"
#    src: "templates/rabbitmq-cookie.j2"
#    dest: "/tmp/tmp-rabbitmq-cookie"
#  run_once: yes
#
#- name: "update cookie uuid"
#  copy:
#    src: "/tmp/tmp-rabbitmq-cookie"
#    dest: "/var/lib/rabbitmq/.erlang.cookie"
#    owner: "rabbitmq"
#    group: "rabbitmq"
#    mode: 0400
#
#- name: "delete temporary cookie uuid"
#  local_action:
#    module: "file"
#    dest: "/tmp/tmp-rabbitmq-cookie"
#    state: "absent"
#  run_once: yes

- name: "start rabbitmq server"
  service:
    name: "rabbitmq-server"
    state: "started"

- name: add rabbitmq user
  shell: >
    rabbitmqctl add_user {{ RABBIT_USER }} {{ RABBIT_PASS }} ;
    rabbitmqctl set_permissions {{ RABBIT_USER }} ".*" ".*" ".*" ;

- name: "check rabbitmq server"
  shell: netstat -lpen --tcp | grep beam |  grep 5672; while [ $? -ne 0 ]; do sleep 10; netstat -lpen --tcp | grep beam | grep 5672; done