Working mariadb -> keystone -> haproxy connections
This commit is contained in:
parent
2a4bfaa421
commit
08a0c0a177
2
Vagrantfile
vendored
2
Vagrantfile
vendored
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
||||||
VAGRANTFILE_API_VERSION = "2"
|
VAGRANTFILE_API_VERSION = "2"
|
||||||
SLAVES_COUNT = 2
|
SLAVES_COUNT = 3
|
||||||
|
|
||||||
init_script = <<SCRIPT
|
init_script = <<SCRIPT
|
||||||
apt-get update
|
apt-get update
|
||||||
|
30
example.sh
Executable file
30
example.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
rm /vagrant/tmp/storage/* || true
|
||||||
|
rm /vagrant/tmp/connections.yaml || true
|
||||||
|
find /vagrant/solar/solar -name '*.pyc' -delete || true
|
||||||
|
|
||||||
|
sudo docker stop $(sudo docker ps -q) || true
|
||||||
|
|
||||||
|
solar profile -c -t env/test_env -i prf1
|
||||||
|
solar discover
|
||||||
|
|
||||||
|
solar assign -n 'node/node_2 | node/node_1' -r 'resources/docker'
|
||||||
|
solar assign -n 'node/node_1' -r 'resources/mariadb'
|
||||||
|
solar assign -n 'node/node_1' -r 'resources/keystone'
|
||||||
|
solar assign -n 'node/node_1' -r 'resources/haproxy'
|
||||||
|
|
||||||
|
solar connect --profile prf1
|
||||||
|
|
||||||
|
solar run -a run -t 'resources/docker'
|
||||||
|
|
||||||
|
solar run -a run -t 'resource/mariadb_service'
|
||||||
|
solar run -a run -t 'resource/mariadb_keystone_db'
|
||||||
|
solar run -a run -t 'resource/mariadb_keystone_user'
|
||||||
|
|
||||||
|
solar run -a run -t 'resource/keystone_config'
|
||||||
|
solar run -a run -t 'resource/keystone_service'
|
||||||
|
|
||||||
|
solar run -a run -t 'resource/haproxy_config'
|
||||||
|
solar run -a run -t 'resources/haproxy'
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
- hosts: [resource/docker]
|
- hosts: [{{ ip }}]
|
||||||
sudo: yes
|
sudo: yes
|
||||||
tasks:
|
tasks:
|
||||||
- shell: docker --version
|
- shell: docker --version
|
||||||
|
@ -4,9 +4,13 @@ version: 1.0.0
|
|||||||
|
|
||||||
input:
|
input:
|
||||||
ip:
|
ip:
|
||||||
|
schema: str!
|
||||||
|
value:
|
||||||
ssh_user:
|
ssh_user:
|
||||||
|
schema: str!
|
||||||
|
value:
|
||||||
ssh_key:
|
ssh_key:
|
||||||
|
schema: str!
|
||||||
|
value:
|
||||||
|
|
||||||
input-types:
|
tags: [resources/docker]
|
||||||
|
|
||||||
tags: [resource/docker]
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
id: haproxy
|
id: haproxy_config
|
||||||
handler: ansible
|
handler: ansible
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
input:
|
input:
|
||||||
@ -27,4 +27,4 @@ input:
|
|||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
|
|
||||||
tags: [resources/haproxy]
|
tags: [resources/haproxy, resource/haproxy_config]
|
@ -10,9 +10,9 @@ input:
|
|||||||
value: 9999
|
value: 9999
|
||||||
ports:
|
ports:
|
||||||
schema: [{value: int}]
|
schema: [{value: int}]
|
||||||
value:
|
value: []
|
||||||
servers:
|
servers:
|
||||||
schema: [{value: str}]
|
schema: [{value: str}]
|
||||||
value:
|
value: []
|
||||||
|
|
||||||
tags: [resources/haproxy, resource/haproxy_keystone_config]
|
tags: [resources/haproxy, resource/haproxy_keystone_config]
|
||||||
|
@ -8,7 +8,7 @@ input:
|
|||||||
value: /etc/solar/keystone
|
value: /etc/solar/keystone
|
||||||
admin_token:
|
admin_token:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value: admin
|
||||||
db_password:
|
db_password:
|
||||||
schema: str!
|
schema: str!
|
||||||
value: password
|
value: password
|
||||||
|
@ -10,10 +10,10 @@ input:
|
|||||||
value: /etc/solar/keystone
|
value: /etc/solar/keystone
|
||||||
port:
|
port:
|
||||||
schema: int!
|
schema: int!
|
||||||
value:
|
value: 5000
|
||||||
admin_port:
|
admin_port:
|
||||||
schema: int!
|
schema: int!
|
||||||
value:
|
value: 35357
|
||||||
ip:
|
ip:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
id: mariadb_table
|
id: mariadb_keystone_db
|
||||||
handler: ansible
|
handler: ansible
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
actions:
|
actions:
|
||||||
@ -7,16 +7,16 @@ actions:
|
|||||||
input:
|
input:
|
||||||
db_name:
|
db_name:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value: keystone_db
|
||||||
|
login_user:
|
||||||
|
schema: str!
|
||||||
|
value: root
|
||||||
login_password:
|
login_password:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
login_port:
|
login_port:
|
||||||
schema: int!
|
schema: int!
|
||||||
value:
|
value:
|
||||||
login_user:
|
|
||||||
schema: str!
|
|
||||||
value:
|
|
||||||
ip:
|
ip:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
@ -27,4 +27,4 @@ input:
|
|||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
|
|
||||||
tags: [resource/mariadb_table, resources/mariadb]
|
tags: [resource/mariadb_keystone_db, resources/mariadb]
|
@ -1,4 +1,4 @@
|
|||||||
id: mariadb_user
|
id: mariadb_keystone_user
|
||||||
handler: ansible
|
handler: ansible
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
actions:
|
actions:
|
||||||
@ -7,10 +7,10 @@ actions:
|
|||||||
input:
|
input:
|
||||||
new_user_password:
|
new_user_password:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value: keystone
|
||||||
new_user_name:
|
new_user_name:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value: keystone
|
||||||
db_name:
|
db_name:
|
||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
@ -33,5 +33,5 @@ input:
|
|||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
|
|
||||||
tags: [resource/mariadb_user, resources/mariadb]
|
tags: [resource/mariadb_keystone_user, resources/mariadb]
|
||||||
|
|
@ -10,3 +10,9 @@
|
|||||||
- {{ port }}:3306
|
- {{ port }}:3306
|
||||||
env:
|
env:
|
||||||
MYSQL_ROOT_PASSWORD: {{ root_password }}
|
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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
id: mariadb
|
id: mariadb_service
|
||||||
handler: ansible
|
handler: ansible
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
input:
|
input:
|
||||||
@ -21,4 +21,4 @@ input:
|
|||||||
schema: str!
|
schema: str!
|
||||||
value:
|
value:
|
||||||
|
|
||||||
tags: [resource/mariadb, resources/mariadb]
|
tags: [resource/mariadb_service, resources/mariadb]
|
||||||
|
@ -74,6 +74,12 @@ class Cmd(object):
|
|||||||
parser.add_argument('-n', '--nodes')
|
parser.add_argument('-n', '--nodes')
|
||||||
parser.add_argument('-r', '--resources')
|
parser.add_argument('-r', '--resources')
|
||||||
|
|
||||||
|
# Run action on tags
|
||||||
|
parser = self.subparser.add_parser('run')
|
||||||
|
parser.set_defaults(func=getattr(self, 'run'))
|
||||||
|
parser.add_argument('-t', '--tags')
|
||||||
|
parser.add_argument('-a', '--action')
|
||||||
|
|
||||||
# Perform resources connection
|
# Perform resources connection
|
||||||
parser = self.subparser.add_parser('connect')
|
parser = self.subparser.add_parser('connect')
|
||||||
parser.set_defaults(func=getattr(self, 'connect'))
|
parser.set_defaults(func=getattr(self, 'connect'))
|
||||||
@ -81,6 +87,18 @@ class Cmd(object):
|
|||||||
'-p',
|
'-p',
|
||||||
'--profile')
|
'--profile')
|
||||||
|
|
||||||
|
def run(self, args):
|
||||||
|
from solar.core import actions
|
||||||
|
from solar.core import signals
|
||||||
|
|
||||||
|
resources = filter(
|
||||||
|
lambda r: Expression(args.tags, r.get('tags', [])).evaluate(),
|
||||||
|
self.db.get_list('resource'))
|
||||||
|
|
||||||
|
for resource in resources:
|
||||||
|
resource_obj = self.db.get_obj_resource(resource['id'])
|
||||||
|
actions.resource_action(resource_obj, args.action)
|
||||||
|
|
||||||
def profile(self, args):
|
def profile(self, args):
|
||||||
if args.create:
|
if args.create:
|
||||||
params = {'tags': args.tags, 'id': args.id}
|
params = {'tags': args.tags, 'id': args.id}
|
||||||
@ -107,6 +125,7 @@ class Cmd(object):
|
|||||||
lambda r: Expression(args.resources, r.get('tags', [])).evaluate(),
|
lambda r: Expression(args.resources, r.get('tags', [])).evaluate(),
|
||||||
self._get_resources_list())
|
self._get_resources_list())
|
||||||
|
|
||||||
|
print("For {0} nodes assign {1} resources".format(len(nodes), len(resources)))
|
||||||
assign_resources_to_nodes(resources, nodes)
|
assign_resources_to_nodes(resources, nodes)
|
||||||
|
|
||||||
def _get_resources_list(self):
|
def _get_resources_list(self):
|
||||||
|
@ -36,8 +36,8 @@ class ResourcesConnectionGraph(object):
|
|||||||
|
|
||||||
def iter_connections(self):
|
def iter_connections(self):
|
||||||
for connection in self.connections:
|
for connection in self.connections:
|
||||||
connections_from = self.resources_with_tags(depends_on(connection))
|
connections_to = self.resources_with_tags(depends_on(connection))
|
||||||
connections_to = self.resources_with_tags(connection['for_resources'])
|
connections_from = self.resources_with_tags(connection['for_resources'])
|
||||||
mapping = self.make_mapping(connection)
|
mapping = self.make_mapping(connection)
|
||||||
|
|
||||||
for connection_from in connections_from:
|
for connection_from in connections_from:
|
||||||
|
@ -16,11 +16,6 @@ class Ansible(BaseHandler):
|
|||||||
print 'EXECUTING: ', ' '.join(call_args)
|
print 'EXECUTING: ', ' '.join(call_args)
|
||||||
subprocess.call(call_args)
|
subprocess.call(call_args)
|
||||||
|
|
||||||
#def _get_connection(self, resource):
|
|
||||||
# return {'ssh_user': '',
|
|
||||||
# 'ssh_key': '',
|
|
||||||
# 'host': ''}
|
|
||||||
|
|
||||||
def _create_inventory(self, r):
|
def _create_inventory(self, r):
|
||||||
directory = self.dirs[r.name]
|
directory = self.dirs[r.name]
|
||||||
inventory_path = os.path.join(directory, 'inventory')
|
inventory_path = os.path.join(directory, 'inventory')
|
||||||
|
@ -10,33 +10,51 @@ extensions:
|
|||||||
tags: {{tags}}
|
tags: {{tags}}
|
||||||
|
|
||||||
connections:
|
connections:
|
||||||
- for_resources: [resource/keystone_config]
|
- for_resources: [resource/mariadb_service]
|
||||||
filter_resources: [resource/mariadb]
|
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:
|
mapping:
|
||||||
ip: db_host
|
ip: db_host
|
||||||
root_password: db_password
|
|
||||||
port: db_port
|
port: db_port
|
||||||
|
|
||||||
- for_resources: [resource/keystone_service]
|
- for_resources: [resource/mariadb_keystone_user]
|
||||||
filter_resources: [resources/haproxy]
|
filter_resources: [resource/keystone_config]
|
||||||
mapping:
|
mapping:
|
||||||
servers: ip
|
db_name: db_name
|
||||||
ports: admin_port
|
new_user_name: db_user
|
||||||
|
new_user_password: db_password
|
||||||
|
|
||||||
# NOTE(dshulyak) it is mandatory for some profiles to user graph based
|
- for_resources: [resource/keystone_config]
|
||||||
# api to provide order of execution for different events
|
filter_resources: [resource/keystone_service]
|
||||||
run:
|
mapping:
|
||||||
- containers.actions.clean_list
|
config_dir: config_dir
|
||||||
- docker.actions.run
|
|
||||||
- mariadb.actions.run
|
|
||||||
- mariadb.actions.wait
|
|
||||||
- mariadb.actions.users
|
|
||||||
- keystone.actions.run
|
|
||||||
- haproxy.actions.run
|
|
||||||
- containers.actions.ensure
|
|
||||||
|
|
||||||
remove:
|
- for_resources: [resource/keystone_service]
|
||||||
- haproxy.actions.remove
|
filter_resources: [resource/haproxy_keystone_config]
|
||||||
- keystone.actions.remove
|
mapping:
|
||||||
- mariadb.actions.remove
|
ip: servers
|
||||||
- docker.actions.remove
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user