![Evgeniy L](/assets/img/avatar_default.png)
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.
23 lines
917 B
YAML
23 lines
917 B
YAML
|
|
- 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
|
|
# NOTE(eli): specify restart policy (--restart parameter) for
|
|
# keystone conatiner if there are more than 2 keystone containers
|
|
# to be deployed, they both will perform db migration and will fail,
|
|
# the container which is first should create database, the rest of
|
|
# the containers should be just restarted
|
|
- shell: docker run -d --net="host" --privileged \
|
|
-e "DB_ROOT_PASSWORD={{db_root_password}}" \
|
|
-e "KEYSTONE_PUBLIC_SERVICE_PORT={{public_port}}" \
|
|
-e "KEYSTONE_ADMIN_SERVICE_PORT={{admin_port}}" \
|
|
-e "MARIADB_SERVICE_HOST={{db_host}}" \
|
|
--restart="on-failure:10" \
|
|
--name {{name}} {{image}}
|
|
when: is_running|failed
|