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:
parent
0f0dd44989
commit
98bb9923a2
@ -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
|
||||
|
||||
|
13
examples/resources/containers.yml
Normal file
13
examples/resources/containers.yml
Normal 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]
|
@ -9,7 +9,7 @@ actions:
|
||||
remove: simple/haproxy/remove.yml
|
||||
|
||||
input:
|
||||
name: haproxy-test
|
||||
name: solar.haproxy-test
|
||||
image: 'haproxy:1.5'
|
||||
|
||||
services:
|
||||
|
@ -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]
|
||||
|
@ -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:
|
||||
|
6
examples/resources/simple/containers/clean_list.yml
Normal file
6
examples/resources/simple/containers/clean_list.yml
Normal 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
|
9
examples/resources/simple/containers/ensure.yml
Normal file
9
examples/resources/simple/containers/ensure.yml
Normal 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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user