Implement ensure mechanism for containers

Added workaround to stop containers which should
not be on the node, accouding to a file with list
of services which is filled in by ansible's tasks.

It allows to implement scale-down and resource
migration.
This commit is contained in:
Evgeniy L 2015-04-23 16:07:31 +03:00
parent 0f0dd44989
commit 98bb9923a2
10 changed files with 37 additions and 4 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash
docker exec -it keystone-test keystone --debug --os-username admin --os-password password --os-tenant-name admin --os-auth-url http://10.0.0.3:8080/v2.0 role-list
docker exec -it solar.keystone-test keystone --debug --os-username admin --os-password password --os-tenant-name admin --os-auth-url http://10.0.0.3:8080/v2.0 role-list

View File

@ -0,0 +1,13 @@
id: containers
class: containers
type: resource
handler: ansible
version: v1
actions:
ensure: simple/containers/ensure.yml
clean_list: simple/containers/clean_list.yml
input: {}
tags: [service/containers]

View File

@ -9,7 +9,7 @@ actions:
remove: simple/haproxy/remove.yml
input:
name: haproxy-test
name: solar.haproxy-test
image: 'haproxy:1.5'
services:

View File

@ -17,7 +17,7 @@ input:
item: '{{ item.node.ip }}'
admin_port: 35357
public_port: 5000
name: keystone-test
name: solar.keystone-test
image: kollaglue/centos-rdo-keystone
tags: [service/keystone]

View File

@ -12,7 +12,7 @@ actions:
input:
bind_ip: "{{ this.node.ip }}"
name: mariadb-test
name: solar.mariadb-test
image: kollaglue/fedora-rdo-mariadb-app
root_password: test1
users:

View File

@ -0,0 +1,6 @@
- hosts: [service/containers]
sudo: yes
tasks:
- file: state=directory path=/var/lib/solar/
- shell: echo -n "" > /var/lib/solar/containers_list

View File

@ -0,0 +1,9 @@
- hosts: [service/containers]
sudo: yes
tasks:
- shell: docker ps -a | egrep -v "CONTAINER ID|$(cat /var/lib/solar/containers_list | tr '\n' '|' | sed 's/|$//')" | egrep 'solar\.' | awk '{print $1}'
register: containers
- shell: docker rm -f {{item}}
with_items: containers.stdout_lines

View File

@ -2,6 +2,8 @@
- hosts: [service/haproxy]
sudo: yes
tasks:
- shell: echo {{name}} >> /var/lib/solar/containers_list
- shell: docker ps | grep -q {{name}}
ignore_errors: true
register: is_running

View File

@ -2,6 +2,8 @@
- hosts: [service/keystone]
sudo: yes
tasks:
- shell: echo {{name}} >> /var/lib/solar/containers_list
- shell: docker ps | grep -q {{name}}
ignore_errors: true
register: is_running

View File

@ -2,6 +2,7 @@
- hosts: [service/mariadb]
sudo: yes
tasks:
- shell: echo {{name}} >> /var/lib/solar/containers_list
- shell: docker ps | grep -q {{name}}
ignore_errors: true
register: is_running