From 75561285cfe071ad0ff2ed5e3c76a8f71dec2c90 Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 2 Jun 2015 14:23:47 +0200 Subject: [PATCH] Working mariadb -> keystone -> haproxy connections --- resources/docker/actions/run.yml | 2 +- resources/docker/meta.yaml | 10 ++- .../actions/remove.yml | 0 .../actions/run.yml | 0 .../{haproxy => haproxy_config}/meta.yaml | 4 +- .../templates/haproxy.cfg | 0 resources/haproxy_keystone_config/meta.yaml | 4 +- resources/keystone_config/meta.yaml | 2 +- resources/keystone_service/meta.yaml | 4 +- .../actions/remove.yml | 0 .../actions/run.yml | 0 .../meta.yaml | 12 ++-- .../actions/remove.yml | 0 .../actions/run.yml | 0 .../meta.yaml | 8 +-- resources/mariadb_service/actions/run.yml | 6 ++ resources/mariadb_service/meta.yaml | 4 +- templates/profile.yml | 64 ++++++++++++------- 18 files changed, 74 insertions(+), 46 deletions(-) rename resources/{haproxy => haproxy_config}/actions/remove.yml (100%) rename resources/{haproxy => haproxy_config}/actions/run.yml (100%) rename resources/{haproxy => haproxy_config}/meta.yaml (88%) rename resources/{haproxy => haproxy_config}/templates/haproxy.cfg (100%) rename resources/{mariadb_db => mariadb_keystone_db}/actions/remove.yml (100%) rename resources/{mariadb_db => mariadb_keystone_db}/actions/run.yml (100%) rename resources/{mariadb_db => mariadb_keystone_db}/meta.yaml (75%) rename resources/{mariadb_user => mariadb_keystone_user}/actions/remove.yml (100%) rename resources/{mariadb_user => mariadb_keystone_user}/actions/run.yml (100%) rename resources/{mariadb_user => mariadb_keystone_user}/meta.yaml (79%) diff --git a/resources/docker/actions/run.yml b/resources/docker/actions/run.yml index 63187d9..549c73b 100644 --- a/resources/docker/actions/run.yml +++ b/resources/docker/actions/run.yml @@ -1,5 +1,5 @@ -- hosts: [resource/docker] +- hosts: [{{ ip }}] sudo: yes tasks: - shell: docker --version diff --git a/resources/docker/meta.yaml b/resources/docker/meta.yaml index 9845a36..1185cd2 100644 --- a/resources/docker/meta.yaml +++ b/resources/docker/meta.yaml @@ -4,9 +4,13 @@ version: 1.0.0 input: ip: + schema: str! + value: ssh_user: + schema: str! + value: ssh_key: + schema: str! + value: -input-types: - -tags: [resource/docker] +tags: [resources/docker] diff --git a/resources/haproxy/actions/remove.yml b/resources/haproxy_config/actions/remove.yml similarity index 100% rename from resources/haproxy/actions/remove.yml rename to resources/haproxy_config/actions/remove.yml diff --git a/resources/haproxy/actions/run.yml b/resources/haproxy_config/actions/run.yml similarity index 100% rename from resources/haproxy/actions/run.yml rename to resources/haproxy_config/actions/run.yml diff --git a/resources/haproxy/meta.yaml b/resources/haproxy_config/meta.yaml similarity index 88% rename from resources/haproxy/meta.yaml rename to resources/haproxy_config/meta.yaml index 7e3125c..46a4623 100644 --- a/resources/haproxy/meta.yaml +++ b/resources/haproxy_config/meta.yaml @@ -1,4 +1,4 @@ -id: haproxy +id: haproxy_config handler: ansible version: 1.0.0 input: @@ -27,4 +27,4 @@ input: schema: str! value: -tags: [resources/haproxy] +tags: [resources/haproxy, resource/haproxy_config] diff --git a/resources/haproxy/templates/haproxy.cfg b/resources/haproxy_config/templates/haproxy.cfg similarity index 100% rename from resources/haproxy/templates/haproxy.cfg rename to resources/haproxy_config/templates/haproxy.cfg diff --git a/resources/haproxy_keystone_config/meta.yaml b/resources/haproxy_keystone_config/meta.yaml index 15bf930..139c18f 100644 --- a/resources/haproxy_keystone_config/meta.yaml +++ b/resources/haproxy_keystone_config/meta.yaml @@ -10,9 +10,9 @@ input: value: 9999 ports: schema: [{value: int}] - value: + value: [] servers: schema: [{value: str}] - value: + value: [] tags: [resources/haproxy, resource/haproxy_keystone_config] diff --git a/resources/keystone_config/meta.yaml b/resources/keystone_config/meta.yaml index b9b177f..4d39737 100644 --- a/resources/keystone_config/meta.yaml +++ b/resources/keystone_config/meta.yaml @@ -8,7 +8,7 @@ input: value: /etc/solar/keystone admin_token: schema: str! - value: + value: admin db_password: schema: str! value: password diff --git a/resources/keystone_service/meta.yaml b/resources/keystone_service/meta.yaml index 746c2d6..e69f3e1 100644 --- a/resources/keystone_service/meta.yaml +++ b/resources/keystone_service/meta.yaml @@ -10,10 +10,10 @@ input: value: /etc/solar/keystone port: schema: int! - value: + value: 5000 admin_port: schema: int! - value: + value: 35357 ip: schema: str! value: diff --git a/resources/mariadb_db/actions/remove.yml b/resources/mariadb_keystone_db/actions/remove.yml similarity index 100% rename from resources/mariadb_db/actions/remove.yml rename to resources/mariadb_keystone_db/actions/remove.yml diff --git a/resources/mariadb_db/actions/run.yml b/resources/mariadb_keystone_db/actions/run.yml similarity index 100% rename from resources/mariadb_db/actions/run.yml rename to resources/mariadb_keystone_db/actions/run.yml diff --git a/resources/mariadb_db/meta.yaml b/resources/mariadb_keystone_db/meta.yaml similarity index 75% rename from resources/mariadb_db/meta.yaml rename to resources/mariadb_keystone_db/meta.yaml index f95ece6..a0ef1e7 100644 --- a/resources/mariadb_db/meta.yaml +++ b/resources/mariadb_keystone_db/meta.yaml @@ -1,4 +1,4 @@ -id: mariadb_table +id: mariadb_keystone_db handler: ansible version: 1.0.0 actions: @@ -7,16 +7,16 @@ actions: input: db_name: schema: str! - value: + value: keystone_db + login_user: + schema: str! + value: root login_password: schema: str! value: login_port: schema: int! value: - login_user: - schema: str! - value: ip: schema: str! value: @@ -27,4 +27,4 @@ input: schema: str! value: -tags: [resource/mariadb_table, resources/mariadb] +tags: [resource/mariadb_keystone_db, resources/mariadb] diff --git a/resources/mariadb_user/actions/remove.yml b/resources/mariadb_keystone_user/actions/remove.yml similarity index 100% rename from resources/mariadb_user/actions/remove.yml rename to resources/mariadb_keystone_user/actions/remove.yml diff --git a/resources/mariadb_user/actions/run.yml b/resources/mariadb_keystone_user/actions/run.yml similarity index 100% rename from resources/mariadb_user/actions/run.yml rename to resources/mariadb_keystone_user/actions/run.yml diff --git a/resources/mariadb_user/meta.yaml b/resources/mariadb_keystone_user/meta.yaml similarity index 79% rename from resources/mariadb_user/meta.yaml rename to resources/mariadb_keystone_user/meta.yaml index adae4d7..73617ca 100644 --- a/resources/mariadb_user/meta.yaml +++ b/resources/mariadb_keystone_user/meta.yaml @@ -1,4 +1,4 @@ -id: mariadb_user +id: mariadb_keystone_user handler: ansible version: 1.0.0 actions: @@ -7,10 +7,10 @@ actions: input: new_user_password: schema: str! - value: + value: keystone new_user_name: schema: str! - value: + value: keystone db_name: schema: str! value: @@ -33,5 +33,5 @@ input: schema: str! value: -tags: [resource/mariadb_user, resources/mariadb] +tags: [resource/mariadb_keystone_user, resources/mariadb] diff --git a/resources/mariadb_service/actions/run.yml b/resources/mariadb_service/actions/run.yml index b1e9d87..2d5950a 100644 --- a/resources/mariadb_service/actions/run.yml +++ b/resources/mariadb_service/actions/run.yml @@ -10,3 +10,9 @@ - {{ port }}:3306 env: MYSQL_ROOT_PASSWORD: {{ root_password }} + + - shell: docker exec -t {{ name }} mysql -p{{ root_password }} -uroot -e "SELECT 1" + register: result + until: result.rc == 0 + retries: 20 + delay: 0.5 diff --git a/resources/mariadb_service/meta.yaml b/resources/mariadb_service/meta.yaml index 1691da8..eb37d04 100644 --- a/resources/mariadb_service/meta.yaml +++ b/resources/mariadb_service/meta.yaml @@ -1,4 +1,4 @@ -id: mariadb +id: mariadb_service handler: ansible version: 1.0.0 input: @@ -21,4 +21,4 @@ input: schema: str! value: -tags: [resource/mariadb, resources/mariadb] +tags: [resource/mariadb_service, resources/mariadb] diff --git a/templates/profile.yml b/templates/profile.yml index 91b1343..453d908 100644 --- a/templates/profile.yml +++ b/templates/profile.yml @@ -10,33 +10,51 @@ extensions: tags: {{tags}} connections: - - for_resources: [resource/keystone_config] - filter_resources: [resource/mariadb] + - for_resources: [resource/mariadb_service] + filter_resources: [resource/mariadb_keystone_db, resource/mariadb_keystone_user] + mapping: + root_password: login_password + port: login_port + + - for_resources: [resource/mariadb_keystone_db] + filter_resources: [resource/mariadb_keystone_user] + mapping: + db_name: db_name + + - for_resources: [resource/mariadb_service] + filter_resources: [resource/keystone_config] mapping: ip: db_host - root_password: db_password port: db_port - - for_resources: [resource/keystone_service] - filter_resources: [resources/haproxy] + - for_resources: [resource/mariadb_keystone_user] + filter_resources: [resource/keystone_config] mapping: - servers: ip - ports: admin_port + db_name: db_name + new_user_name: db_user + new_user_password: db_password -# NOTE(dshulyak) it is mandatory for some profiles to user graph based -# api to provide order of execution for different events -run: - - containers.actions.clean_list - - docker.actions.run - - mariadb.actions.run - - mariadb.actions.wait - - mariadb.actions.users - - keystone.actions.run - - haproxy.actions.run - - containers.actions.ensure + - for_resources: [resource/keystone_config] + filter_resources: [resource/keystone_service] + mapping: + config_dir: config_dir -remove: - - haproxy.actions.remove - - keystone.actions.remove - - mariadb.actions.remove - - docker.actions.remove + - for_resources: [resource/keystone_service] + filter_resources: [resource/haproxy_keystone_config] + mapping: + ip: servers + port: ports + + - for_resources: [resource/haproxy_keystone_config] + filter_resources: [resource/haproxy_config] + mapping: + listen_port: listen_ports + name: configs_names + ports: configs_ports + servers: configs + + - for_resources: [resource/haproxy_config] + filter_resources: [resource/haproxy_service] + mapping: + listen_ports: ports + config_dir: host_binds