summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/open-contrail/tasks
diff options
context:
space:
mode:
authorchenshuai@huawei.com <chenshuai@huawei.com>2016-04-25 16:24:07 +0800
committerchenshuai@huawei.com <chenshuai@huawei.com>2016-04-25 16:24:07 +0800
commit1cead8ec9a849d243c3ee5c8acbbe3b6a754dd23 (patch)
treecd40ab2de40f2c47c0d8d2e81b7f83ee631fd8f2 /deploy/adapters/ansible/roles/open-contrail/tasks
parentaa16cb5bd58d314e05594ea591f236653455996b (diff)
ocl: use opencontrail rabbitmq replace compass default rabbitmq
JIRA: COMPASS-376 Change-Id: I1496d875cc47869e18fd4b2db5baabcd620675d7 Signed-off-by: chenshuai@huawei.com <chenshuai@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible/roles/open-contrail/tasks')
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/tasks/main.yml3
-rw-r--r--deploy/adapters/ansible/roles/open-contrail/tasks/provision/-rabbitmq-stop.yml30
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml16
-rw-r--r--deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-rabbitmq.yml87
4 files changed, 128 insertions, 8 deletions
diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml
index b1e9cbcd..16ca4e91 100755
--- a/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/open-contrail/tasks/main.yml
@@ -74,6 +74,9 @@
# when: groups['opencontrail_control']|length !=0
+- name: Provision RabbitMQ on OpenContrail config nodes
+ include: provision/provision-rabbitmq.yml
+ when: inventory_hostname in groups['opencontrail']
- name: Provision increase limits for Open Contrail
include: provision/provision-increase-limits.yml
diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/-rabbitmq-stop.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/-rabbitmq-stop.yml
new file mode 100644
index 00000000..ec6b2fe0
--- /dev/null
+++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/-rabbitmq-stop.yml
@@ -0,0 +1,30 @@
+---
+- name: 'stop rabbitmq server'
+ service:
+ name: 'rabbitmq-server'
+ state: 'stopped'
+
+- name: 'check beam process'
+ shell: 'ps ax | grep -v grep | grep beam'
+ register: beam_process
+ changed_when: no
+ ignore_errors: yes
+
+- name: 'kill beam processes'
+ shell: 'pkill -9 beam'
+ when: beam_process.stdout
+
+- name: 'check epmd process'
+ shell: 'ps ax | grep -v grep | grep epmd'
+ register: epmd_process
+ changed_when: no
+ ignore_errors: yes
+
+- name: 'kill epmd processes'
+ shell: 'pkill -9 epmd'
+ when: epmd_process.stdout
+
+- name: 'remove mnesia directory'
+ file:
+ name: '/var/lib/rabbitmq/mnesia'
+ state: 'absent'
diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml
index aea12c00..91517b3d 100755
--- a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml
+++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-add-nodes.yml
@@ -11,16 +11,16 @@
# sudo: yes
# tasks:
-- name: "recover rabbitmq-server service script"
- shell: cp /home/rabbitmq-server /etc/init.d/rabbitmq-server
+#- name: "recover rabbitmq-server service script"
+# shell: cp /home/rabbitmq-server /etc/init.d/rabbitmq-server
-- name: "restart rabbitmq-server"
- service:
- name: "rabbitmq-server"
- state: "restarted"
+#- name: "restart rabbitmq-server"
+# service:
+# name: "rabbitmq-server"
+# state: "restarted"
-- name: "wait rabbitmq-server start"
- shell: sleep 5
+#- name: "wait rabbitmq-server start"
+# shell: sleep 5
- name: "restart contrail-discovery"
service:
diff --git a/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-rabbitmq.yml b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-rabbitmq.yml
new file mode 100644
index 00000000..d3426590
--- /dev/null
+++ b/deploy/adapters/ansible/roles/open-contrail/tasks/provision/provision-rabbitmq.yml
@@ -0,0 +1,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