summaryrefslogtreecommitdiffstats
path: root/deploy/adapters
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
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')
-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
-rw-r--r--deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf-single.j26
-rw-r--r--deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf.j225
-rw-r--r--deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-cookie.j21
-rw-r--r--deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-env-conf.j22
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/vars/main.yml2
9 files changed, 163 insertions, 9 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
diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf-single.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf-single.j2
new file mode 100644
index 00000000..cce01c77
--- /dev/null
+++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf-single.j2
@@ -0,0 +1,6 @@
+[
+ {rabbit, [ {tcp_listeners, [{"{{ internal_ip }}", 5672}]},
+ {loopback_users, []},
+ {log_levels,[{connection, info},{mirroring, info}]} ]
+ }
+].
diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf.j2
new file mode 100644
index 00000000..f0d09c4f
--- /dev/null
+++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-conf.j2
@@ -0,0 +1,25 @@
+[
+ {rabbit, [ {tcp_listeners, [{"{{ contrail_address }}", 5672}]}, {cluster_partition_handling, autoheal},{loopback_users, []},
+ {cluster_nodes, {[{% for cur_host in groups['opencontrail'] %}'rabbit@{{ cur_host }}'{% if not loop.last %}, {% endif %}{% endfor %}], disc}},
+ {vm_memory_high_watermark, 0.4},
+ {disk_free_limit,50000000},
+ {log_levels,[{connection, info},{mirroring, info}]},
+ {heartbeat,10},
+ {delegate_count,20},
+ {channel_max,5000},
+ {tcp_listen_options,
+ [binary,
+ {packet, raw},
+ {reuseaddr, true},
+ {backlog, 128},
+ {nodelay, true},
+ {exit_on_close, false},
+ {keepalive, true}
+ ]
+ },
+ {collect_statistics_interval, 60000}
+ ]
+ },
+ {rabbitmq_management_agent, [ {force_fine_statistics, true} ] },
+ {kernel, [{net_ticktime, 30}]}
+].
diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-cookie.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-cookie.j2
new file mode 100644
index 00000000..838d0332
--- /dev/null
+++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-cookie.j2
@@ -0,0 +1 @@
+{{ ansible_date_time.iso8601_micro | to_uuid }}
diff --git a/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-env-conf.j2 b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-env-conf.j2
new file mode 100644
index 00000000..6a3b4760
--- /dev/null
+++ b/deploy/adapters/ansible/roles/open-contrail/templates/provision/rabbitmq-env-conf.j2
@@ -0,0 +1,2 @@
+NODE_IP_ADDRESS={{ internal_ip }}
+NODENAME=rabbit@{{ ansible_hostname }}-ctrl
diff --git a/deploy/adapters/ansible/roles/open-contrail/vars/main.yml b/deploy/adapters/ansible/roles/open-contrail/vars/main.yml
index 17b78849..6facb475 100755
--- a/deploy/adapters/ansible/roles/open-contrail/vars/main.yml
+++ b/deploy/adapters/ansible/roles/open-contrail/vars/main.yml
@@ -20,7 +20,7 @@ contrail_admin_password: "console"
# network infor adapter for compass
# contrail_address: "{{ internal_ip }}"
-contrail_address: " {{ ip_settings[inventory_hostname]['br-prv']['ip'] }} "
+contrail_address: "{{ ip_settings[inventory_hostname]['br-prv']['ip'] }}"
#contrail_device: # compass openstack device
contrail_netmask: "255.255.255.0"
#contrail_gateway: "10.84.50.254"