Merge pull request #45 from xarses/keystone-db-deployment

Configured keystone, haproxy, mariadb
This commit is contained in:
Dmitry Shulyak 2015-04-20 10:40:30 +03:00
commit 361ddc95b4
13 changed files with 119 additions and 16 deletions

3
examples/check_deployment.sh Executable file
View File

@ -0,0 +1,3 @@
#!/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

View File

@ -2,10 +2,12 @@ id: docker
type: resource
handler: ansible
version: v1
actions:
run: simple/docker/run.yml
remove: simple/docker/remove.yml
input:
base_image: ubuntu
tags: [service/docker]
tags: [service/docker]

View File

@ -0,0 +1,27 @@
id: haproxy
type: resource
handler: ansible
version: v1
actions:
run: simple/haproxy/run.yml
remove: simple/haproxy/remove.yml
input:
name: haproxy
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"
backends:
- remote_name: keystone-test
remote_addr: 10.0.0.3:35357
tags: [service/haproxy]

View File

@ -0,0 +1,16 @@
id: keystone
type: resource
handler: ansible
version: v1
actions:
run: simple/keystone/run.yml
remove: simple/keystone/remove.yml
input:
admin_port: 35357
public_port: 5000
name: keystone-test
image: kollaglue/centos-rdo-keystone
tags: [service/keystone]

View File

@ -8,8 +8,9 @@ actions:
wait: simple/mariadb/wait.yml
users: simple/mariadb/users.yml
input:
name: maria-test
image: tutum/mariadb
name: mariadb-test
image: kollaglue/fedora-rdo-mariadb-app
root_password: test1
users:
- name: test1
password: test1

View File

@ -7,4 +7,3 @@
register: docker_version
- shell: curl -sSL https://get.docker.com/ | sudo sh
when: docker_version|failed
- shell: docker pull {{ docker.base_image }}

View File

@ -0,0 +1,12 @@
- hosts: [haproxy]
sudo: yes
tasks:
- file: state=directory path=/etc/solar/{{haproxy.name}}
# TODO Remove hardcoded path
- template: src=/vagrant/examples/resources/templates/haproxy.cfg.j2 dest=/etc/solar/{{haproxy.name}}/haproxy.cfg backup=yes
- 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}}

View File

@ -0,0 +1,9 @@
- hosts: [keystone]
sudo: yes
tasks:
- 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}}

View File

@ -2,5 +2,10 @@
- hosts: [mariadb]
sudo: yes
tasks:
- shell: docker run -d --net="host" --privileged \
--name {{mariadb.name}} {{mariadb.image}}
- shell: docker run \
-d \
--net="host" \
--privileged \
--name {{mariadb.name}} \
-e "MARIADB_ROOT_PASSWORD={{mariadb.root_password}}" \
{{mariadb.image}}

View File

@ -3,9 +3,10 @@
sudo: yes
tasks:
- command: docker exec -t {{mariadb.name}} \
mysql -uroot \
mysql -uroot -p{{mariadb.root_password}} \
-e "CREATE USER '{{item.name}}'@'%' IDENTIFIED BY '{{item.password}}'"
with_items: mariadb.users
- command: docker exec -t {{mariadb.name}} \
mysql -uroot -e "GRANT ALL PRIVILEGES ON *.* TO '{{item.name}}'@'%' WITH GRANT OPTION"
mysql -uroot -p{{mariadb.root_password}} -e "GRANT ALL PRIVILEGES ON *.* TO '{{item.name}}'@'%' WITH GRANT OPTION"
with_items: mariadb.users

View File

@ -2,7 +2,7 @@
- hosts: [mariadb]
sudo: yes
tasks:
- shell: docker exec -t {{mariadb.name}} mysql -uroot -e "select 1"
- shell: docker exec -t {{mariadb.name}} mysql -p{{mariadb.root_password}} -uroot -e "select 1"
register: result
until: result.rc == 0
retries: 10

View File

@ -0,0 +1,26 @@
global
maxconn 4096
pidfile /var/run/haproxy.pidfile
defaults
mode tcp
timeout connect 5s
timeout client 1m
timeout server 1m
option redispatch
balance roundrobin
listen stats :1936
mode http
stats enable
stats hide-version
#stats realm Haproxy\ Statistics
stats uri /
#stats auth Username:Password
{% for service in haproxy.services %}
listen {{ service.service_name }}
bind {{service.bind}}
{% for backend in service.backends %}
server {{ backend.remote_name }} {{ backend.remote_addr }} check inter 2s rise 3 fall 2
{% endfor %}
{% endfor %}

View File

@ -16,6 +16,8 @@ run:
- mariadb.actions.run
- mariadb.actions.wait
- mariadb.actions.users
- keystone.actions.run
- haproxy.actions.run
remove:
- mariadb.actions.remove