Changed resources to use templating language and tags, without hardcoded values
This commit is contained in:
parent
cbdb4e1014
commit
a4153da9b6
@ -1,3 +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
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
id: docker_1
|
||||
id: docker
|
||||
class: docker
|
||||
type: resource
|
||||
handler: ansible
|
||||
|
@ -11,6 +11,4 @@ input:
|
||||
node:
|
||||
link: node_2
|
||||
tags:
|
||||
- service/docker
|
||||
- env/test_env
|
||||
|
||||
- service/docker2
|
||||
|
@ -1,4 +1,5 @@
|
||||
id: haproxy
|
||||
class: haproxy
|
||||
type: resource
|
||||
handler: ansible
|
||||
version: v1
|
||||
@ -8,20 +9,24 @@ actions:
|
||||
remove: simple/haproxy/remove.yml
|
||||
|
||||
input:
|
||||
name: haproxy
|
||||
image: haproxy:1.5
|
||||
name: haproxy-test
|
||||
image: 'haproxy:1.5'
|
||||
|
||||
services:
|
||||
# TODO Here we should be able to remove hardcoded data,
|
||||
# we can have sveral keystone backaends, and other different
|
||||
# services. Without hardcoding of specific node we should
|
||||
# get the nodes with specific tag.
|
||||
# * get all nodes which use all tags with 'service/keystone'
|
||||
# * iterate over this list here
|
||||
# * pass correct port and ip address
|
||||
- service_name: keystone
|
||||
bind: "*:8080"
|
||||
- service_name: keystone-admin
|
||||
bind: '*:8080'
|
||||
backends:
|
||||
- remote_name: keystone-test
|
||||
remote_addr: 10.0.0.3:35357
|
||||
'with_items': '{{ with_tags("service/keystone") }}'
|
||||
'item':
|
||||
'remote_name': '{{ item.name }}'
|
||||
'remote_addr': '{{ item.node.ip }}:{{ item.admin_port }}'
|
||||
|
||||
- service_name: keystone-pub
|
||||
bind: '*:8081'
|
||||
backends:
|
||||
with_items: '{{ with_tags("service/keystone") }}'
|
||||
item:
|
||||
remote_name: '{{ item.name }}'
|
||||
remote_addr: '{{ item.node.ip }}:{{ item.public_port }}'
|
||||
|
||||
tags: [service/haproxy]
|
||||
|
@ -1,4 +1,5 @@
|
||||
id: keystone
|
||||
class: keystone
|
||||
type: resource
|
||||
handler: ansible
|
||||
version: v1
|
||||
@ -8,8 +9,10 @@ actions:
|
||||
remove: simple/keystone/remove.yml
|
||||
|
||||
input:
|
||||
db_root_password: '{{ first_with_tags("entrypoint/mariadb").root_password }}'
|
||||
db_host: '{{ first_with_tags("entrypoint/mariadb").node.ip }}'
|
||||
admin_port: 35357
|
||||
public_port: 5000
|
||||
public_port: 5000
|
||||
name: keystone-test
|
||||
image: kollaglue/centos-rdo-keystone
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
id: mariadb
|
||||
class: mariadb
|
||||
type: resource
|
||||
handler: ansible
|
||||
version: v1
|
||||
@ -10,10 +11,13 @@ actions:
|
||||
users: simple/mariadb/users.yml
|
||||
|
||||
input:
|
||||
bind_ip: "{{ this.node.ip }}"
|
||||
name: mariadb-test
|
||||
image: kollaglue/fedora-rdo-mariadb-app
|
||||
root_password: test1
|
||||
users:
|
||||
- name: test1
|
||||
password: test1
|
||||
tags: [service/mariadb]
|
||||
tags:
|
||||
- service/mariadb
|
||||
- entrypoint/mariadb
|
||||
|
@ -1,12 +1,13 @@
|
||||
|
||||
- hosts: [haproxy]
|
||||
- hosts: [service/haproxy]
|
||||
sudo: yes
|
||||
tasks:
|
||||
- file: state=directory path=/etc/solar/{{haproxy.name}}
|
||||
- file: state=directory path=/etc/solar/{{name}}
|
||||
# TODO Remove hardcoded path
|
||||
- template: src=/vagrant/examples/resources/templates/haproxy.cfg.j2 dest=/etc/solar/{{haproxy.name}}/haproxy.cfg backup=yes
|
||||
- template: src=/vagrant/examples/resources/templates/haproxy.cfg.j2 dest=/etc/solar/{{name}}/haproxy.cfg backup=yes
|
||||
- shell: docker rm -f {{name}} || true
|
||||
- shell: docker run -d \
|
||||
--net="host" \
|
||||
--privileged \
|
||||
-v /etc/solar/{{haproxy.name}}/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \
|
||||
--name {{haproxy.name}} {{haproxy.image}}
|
||||
-v /etc/solar/{{name}}/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \
|
||||
--name {{name}} {{image}}
|
||||
|
@ -1,9 +1,17 @@
|
||||
|
||||
- hosts: [keystone]
|
||||
- hosts: [service/keystone]
|
||||
sudo: yes
|
||||
tasks:
|
||||
- shell: docker rm -f {{name}} || true
|
||||
# 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={{mariadb.root_password}}" \
|
||||
-e "KEYSTONE_PUBLIC_SERVICE_PORT={{keystone.public_port}}" \
|
||||
-e "KEYSTONE_ADMIN_SERVICE_PORT={{keystone.admin_port}}" \
|
||||
--name {{keystone.name}} {{keystone.image}}
|
||||
-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}}
|
||||
|
@ -1,11 +1,13 @@
|
||||
|
||||
- hosts: [mariadb]
|
||||
- hosts: [service/mariadb]
|
||||
sudo: yes
|
||||
tasks:
|
||||
- shell: docker rm -f {{name}} || true
|
||||
- shell: docker run \
|
||||
-d \
|
||||
--net="host" \
|
||||
--privileged \
|
||||
--name {{mariadb.name}} \
|
||||
-e "MARIADB_ROOT_PASSWORD={{mariadb.root_password}}" \
|
||||
{{mariadb.image}}
|
||||
--name {{name}} \
|
||||
-e "MARIADB_ROOT_PASSWORD={{root_password}}" \
|
||||
-e "BIND_ADDRESS={{bind_ip}}" \
|
||||
{{image}}
|
||||
|
@ -1,12 +1,12 @@
|
||||
|
||||
- hosts: [mariadb]
|
||||
- hosts: [service/mariadb]
|
||||
sudo: yes
|
||||
tasks:
|
||||
- command: docker exec -t {{mariadb.name}} \
|
||||
mysql -uroot -p{{mariadb.root_password}} \
|
||||
- command: docker exec -t {{name}} \
|
||||
mysql -uroot -p{{root_password}} \
|
||||
-e "CREATE USER '{{item.name}}'@'%' IDENTIFIED BY '{{item.password}}'"
|
||||
with_items: mariadb.users
|
||||
with_items: users
|
||||
|
||||
- command: docker exec -t {{mariadb.name}} \
|
||||
mysql -uroot -p{{mariadb.root_password}} -e "GRANT ALL PRIVILEGES ON *.* TO '{{item.name}}'@'%' WITH GRANT OPTION"
|
||||
with_items: mariadb.users
|
||||
- command: docker exec -t {{name}} \
|
||||
mysql -uroot -p{{root_password}} -e "GRANT ALL PRIVILEGES ON *.* TO '{{item.name}}'@'%' WITH GRANT OPTION"
|
||||
with_items: users
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
- hosts: [mariadb]
|
||||
- hosts: [service/mariadb]
|
||||
sudo: yes
|
||||
tasks:
|
||||
- shell: docker exec -t {{mariadb.name}} mysql -p{{mariadb.root_password}} -uroot -e "select 1"
|
||||
- shell: docker exec -t {{name}} mysql -p{{root_password}} -uroot -e "select 1"
|
||||
register: result
|
||||
until: result.rc == 0
|
||||
retries: 10
|
||||
|
@ -17,7 +17,7 @@ listen stats :1936
|
||||
stats uri /
|
||||
#stats auth Username:Password
|
||||
|
||||
{% for service in haproxy.services %}
|
||||
{% for service in services %}
|
||||
listen {{ service.service_name }}
|
||||
bind {{service.bind}}
|
||||
{% for backend in service.backends %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user