diff --git a/examples/resources/simple/haproxy/run.yml b/examples/resources/simple/haproxy/run.yml index d2604c4..fa09fc6 100644 --- a/examples/resources/simple/haproxy/run.yml +++ b/examples/resources/simple/haproxy/run.yml @@ -2,6 +2,10 @@ - hosts: [service/haproxy] sudo: yes tasks: + - shell: docker ps | grep -q {{name}} + ignore_errors: true + register: is_running + - file: state=directory path=/etc/solar/{{name}} # TODO Remove hardcoded path - template: src=/vagrant/examples/resources/templates/haproxy.cfg.j2 dest=/etc/solar/{{name}}/haproxy.cfg backup=yes @@ -10,3 +14,4 @@ --privileged \ -v /etc/solar/{{name}}/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \ --name {{name}} {{image}} + when: is_running|failed diff --git a/examples/resources/simple/keystone/run.yml b/examples/resources/simple/keystone/run.yml index 1dff980..b221da7 100644 --- a/examples/resources/simple/keystone/run.yml +++ b/examples/resources/simple/keystone/run.yml @@ -2,6 +2,9 @@ - hosts: [service/keystone] sudo: yes tasks: + - 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, @@ -14,3 +17,4 @@ -e "MARIADB_SERVICE_HOST={{db_host}}" \ --restart="on-failure:10" \ --name {{name}} {{image}} + when: is_running|failed diff --git a/examples/resources/simple/mariadb/run.yml b/examples/resources/simple/mariadb/run.yml index a76e7e5..650b0f5 100644 --- a/examples/resources/simple/mariadb/run.yml +++ b/examples/resources/simple/mariadb/run.yml @@ -2,6 +2,9 @@ - hosts: [service/mariadb] sudo: yes tasks: + - shell: docker ps | grep -q {{name}} + ignore_errors: true + register: is_running - shell: docker run \ -d \ --net="host" \ @@ -10,3 +13,4 @@ -e "MARIADB_ROOT_PASSWORD={{root_password}}" \ -e "BIND_ADDRESS={{bind_ip}}" \ {{image}} + when: is_running|failed diff --git a/examples/resources/simple/mariadb/users.yml b/examples/resources/simple/mariadb/users.yml index 4d20ed8..17c69b7 100644 --- a/examples/resources/simple/mariadb/users.yml +++ b/examples/resources/simple/mariadb/users.yml @@ -2,11 +2,7 @@ - hosts: [service/mariadb] sudo: yes tasks: - - command: docker exec -t {{name}} \ - mysql -uroot -p{{root_password}} \ - -e "CREATE USER '{{item.name}}'@'%' IDENTIFIED BY '{{item.password}}'" - with_items: users - + # NOTE(eli): it will automatically create user if it does not exist - command: docker exec -t {{name}} \ mysql -uroot -p{{root_password}} -e "GRANT ALL PRIVILEGES ON *.* TO '{{item.name}}'@'%' WITH GRANT OPTION" with_items: users