From bc1cc939d298eb075b4839f9467f107cd36bce46 Mon Sep 17 00:00:00 2001
From: SamYaple <sam@yaple.net>
Date: Fri, 25 Dec 2015 22:25:34 +0000
Subject: [PATCH] Convert Keystone to kolla_docker

Change-Id: Ia1beaf8205317f8c628fa1efcb65be90a9ad8237
Partially-Implements: blueprint kolla-docker-module
---
 ansible/roles/keystone/tasks/bootstrap.yml | 41 +++++-----------------
 ansible/roles/keystone/tasks/start.yml     | 20 +++--------
 2 files changed, 14 insertions(+), 47 deletions(-)

diff --git a/ansible/roles/keystone/tasks/bootstrap.yml b/ansible/roles/keystone/tasks/bootstrap.yml
index 16502957b9..5d66451eee 100644
--- a/ansible/roles/keystone/tasks/bootstrap.yml
+++ b/ansible/roles/keystone/tasks/bootstrap.yml
@@ -37,41 +37,18 @@
   run_once: True
   delegate_to: "{{ groups['keystone'][0] }}"
 
-- name: Starting Keystone bootstrap container
-  docker:
-    tty: True
+- name: Running Keystone bootstrap container
+  kolla_docker:
+    action: "start_container"
+    common_options: "{{ docker_common_options }}"
     detach: False
-    net: host
-    pull: "{{ docker_pull_policy }}"
-    restart_policy: "no"
-    state: reloaded
-    registry: "{{ docker_registry }}"
-    username: "{{ docker_registry_username }}"
-    password: "{{ docker_registry_password }}"
-    insecure_registry: "{{ docker_insecure_registry }}"
-    name: bootstrap_keystone
-    image: "{{ keystone_image_full }}"
-    volumes: "{{ node_config_directory }}/keystone/:{{ container_config_directory }}/:ro"
-    env:
+    environment:
       KOLLA_BOOTSTRAP:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
-  run_once: True
-  delegate_to: "{{ groups['keystone'][0] }}"
-  when: database_created
-
-# https://github.com/ansible/ansible-modules-core/pull/1031
-- name: Waiting for Keystone bootstrap container to exit
-  command: docker wait bootstrap_keystone
-  register: bootstrap_result
-  run_once: True
-  failed_when: bootstrap_result.stdout != "0"
-  delegate_to: "{{ groups['keystone'][0] }}"
-  when: database_created
-
-- name: Cleaning up Keystone bootstrap container
-  docker:
-    name: bootstrap_keystone
     image: "{{ keystone_image_full }}"
-    state: absent
+    name: "bootstrap_keystone"
+    restart_policy: "never"
+    volumes: "{{ node_config_directory }}/keystone/:{{ container_config_directory }}/:ro"
+  run_once: True
   delegate_to: "{{ groups['keystone'][0] }}"
   when: database_created
diff --git a/ansible/roles/keystone/tasks/start.yml b/ansible/roles/keystone/tasks/start.yml
index 2e395398e1..c70f8e7231 100644
--- a/ansible/roles/keystone/tasks/start.yml
+++ b/ansible/roles/keystone/tasks/start.yml
@@ -1,23 +1,13 @@
 ---
-- name: Starting Keystone container
-  docker:
-    tty: True
-    net: host
-    pull: "{{ docker_pull_policy }}"
-    restart_policy: "{{ docker_restart_policy }}"
-    restart_policy_retry: "{{ docker_restart_policy_retry }}"
-    state: reloaded
-    registry: "{{ docker_registry }}"
-    username: "{{ docker_registry_username }}"
-    password: "{{ docker_registry_password }}"
-    insecure_registry: "{{ docker_insecure_registry }}"
-    name: keystone
+- name: Starting keystone container
+  kolla_docker:
+    action: "start_container"
+    common_options: "{{ docker_common_options }}"
     image: "{{ keystone_image_full }}"
+    name: "keystone"
     volumes:
       - "{{ node_config_directory }}/keystone/:{{ container_config_directory }}/:ro"
       - "/var/lib/kolla/dev/log:/dev/log"
-    env:
-      KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
 
 - name: Wait for keystone startup
   wait_for: host={{ keystone_admin_address }} port={{ keystone_admin_port }}