aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorne Mace <borne.mace@oracle.com>2016-10-18 16:22:02 -0700
committerJeffrey Zhang <jeffrey.zhang@99cloud.net>2016-11-23 11:45:23 +0000
commit2cfc069e215967ce081df1520be834982f9c64bb (patch)
tree2ec90febe736c6d6ca4dd90e9f02897aadc413d5
parentcf81e153cb419782974cd8f27efb277db716e4a6 (diff)
downloadkolla-ansible-2cfc069e215967ce081df1520be834982f9c64bb.tar.gz
kolla-ansible-2cfc069e215967ce081df1520be834982f9c64bb.zip
Added support for a stop playbook in kolla
Behavior of stop playbook is very similar to the destroy playbook. This is meant when you may just want to bring down the service for some sort of maintenance but not destroy all the associated data. Also added support for the new playbook into the kolla-ansible command. Change-Id: Icf0ca91de71dc8ead3a024de3e5b9e49116560d1 Implements: blueprint ansible-stop-host-playbook
-rw-r--r--ansible/roles/stop/tasks/copy_tools.yml17
-rw-r--r--ansible/roles/stop/tasks/main.yml4
-rw-r--r--ansible/roles/stop/tasks/stop_containers.yml4
-rw-r--r--ansible/stop.yml4
-rw-r--r--setup.cfg1
-rwxr-xr-xtools/kolla-ansible5
-rwxr-xr-xtools/stop-containers18
7 files changed, 53 insertions, 0 deletions
diff --git a/ansible/roles/stop/tasks/copy_tools.yml b/ansible/roles/stop/tasks/copy_tools.yml
new file mode 100644
index 000000000..e6a1ec62d
--- /dev/null
+++ b/ansible/roles/stop/tasks/copy_tools.yml
@@ -0,0 +1,17 @@
+---
+- name: Creating /kolla-stop/tools directory on node
+ file:
+ state: directory
+ path: /tmp/kolla-stop/tools
+
+- name: Copying validate-docker-execute.sh file
+ copy:
+ src: ../tools/validate-docker-execute.sh
+ dest: /tmp/kolla-stop/tools
+ mode: 0755
+
+- name: Copying stop-containers file
+ copy:
+ src: ../tools/stop-containers
+ dest: /tmp/kolla-stop/tools
+ mode: 0755
diff --git a/ansible/roles/stop/tasks/main.yml b/ansible/roles/stop/tasks/main.yml
new file mode 100644
index 000000000..ab994d374
--- /dev/null
+++ b/ansible/roles/stop/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- include: copy_tools.yml
+
+- include: stop_containers.yml
diff --git a/ansible/roles/stop/tasks/stop_containers.yml b/ansible/roles/stop/tasks/stop_containers.yml
new file mode 100644
index 000000000..7b679f8c4
--- /dev/null
+++ b/ansible/roles/stop/tasks/stop_containers.yml
@@ -0,0 +1,4 @@
+---
+- name: Stopping Kolla containers
+ command: /tmp/kolla-stop/tools/stop-containers
+
diff --git a/ansible/stop.yml b/ansible/stop.yml
new file mode 100644
index 000000000..0ff7bf494
--- /dev/null
+++ b/ansible/stop.yml
@@ -0,0 +1,4 @@
+---
+- hosts: all
+ roles:
+ - stop
diff --git a/setup.cfg b/setup.cfg
index bacc903c6..610126ac0 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -30,6 +30,7 @@ data_files =
share/kolla/tools = tools/cleanup-containers
share/kolla/tools = tools/cleanup-host
share/kolla/tools = tools/cleanup-images
+ share/kolla/tools = tools/stop-containers
share/kolla/doc = doc/*
share/kolla/etc_examples = etc/*
share/kolla = tools/init-runonce
diff --git a/tools/kolla-ansible b/tools/kolla-ansible
index 16891734b..fefd19521 100755
--- a/tools/kolla-ansible
+++ b/tools/kolla-ansible
@@ -50,6 +50,7 @@ Commands:
post-deploy Do post deploy on deploy node
pull Pull all images for containers (only pulls, no running container changes)
reconfigure Reconfigure OpenStack service
+ stop Stop Kolla containers
certificates Generate self-signed certificate for TLS *For Development Only*
upgrade Upgrades existing OpenStack Environment
genconfig Generate configuration files for enabled OpenStack services
@@ -206,6 +207,10 @@ EOF
ACTION="Reconfigure OpenStack service"
EXTRA_OPTS="$EXTRA_OPTS -e action=reconfigure -e serial=30%"
;;
+(stop)
+ ACTION="Stop Kolla containers"
+ PLAYBOOK="${BASEDIR}/ansible/stop.yml"
+ ;;
(certificates)
ACTION="Generate TLS Certificates"
PLAYBOOK="${BASEDIR}/ansible/certificates.yml"
diff --git a/tools/stop-containers b/tools/stop-containers
new file mode 100755
index 000000000..f12c50f44
--- /dev/null
+++ b/tools/stop-containers
@@ -0,0 +1,18 @@
+#!/bin/bash
+if [[ $(pgrep qemu) ]]; then
+ echo "Some qemu processes were detected."
+ echo "Docker will not be able to stop the nova_libvirt container with those running."
+ echo "Please clean them up before rerunning this script."
+ exit 1
+fi
+
+if [ -n "$1" ]; then
+ containers_to_stop=($(docker ps | grep -E "$1" | awk '{print $1}'))
+else
+ containers_to_stop=$(docker ps --filter "label=kolla_version" --format "{{.Names}}" -a)
+fi
+
+echo "Stopping containers..."
+(docker stop -t 30 ${containers_to_stop} 2>&1) > /dev/null
+
+echo "All containers stopped!"