Save resource vars to inventory. Change resource name in args
This commit is contained in:
parent
28e26a06dc
commit
e27da1c01b
@ -3,7 +3,7 @@
|
||||
tasks:
|
||||
- name: mariadb container
|
||||
docker:
|
||||
name: {{ name }}
|
||||
name: {{ resource_name }}
|
||||
image: {{ image }}
|
||||
state: running
|
||||
ports:
|
||||
@ -11,7 +11,7 @@
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: {{ root_password }}
|
||||
|
||||
- shell: docker exec -t {{ name }} mysql -p{{ root_password }} -uroot -e "SELECT 1"
|
||||
- shell: docker exec -t {{ resource_name }} mysql -p{{ root_password }} -uroot -e "SELECT 1"
|
||||
register: result
|
||||
until: result.rc == 0
|
||||
retries: 30
|
||||
|
@ -30,9 +30,13 @@ class Ansible(BaseHandler):
|
||||
return inventory_path
|
||||
|
||||
def _render_inventory(self, r):
|
||||
inventory = '{0} ansible_ssh_host={1} ansible_connection=ssh ansible_ssh_user={2} ansible_ssh_private_key_file={3}'
|
||||
inventory = '{0} ansible_ssh_host={1} ansible_connection=ssh ansible_ssh_user={2} ansible_ssh_private_key_file={3} {4}'
|
||||
host, user, ssh_key = r.args['ip'].value, r.args['ssh_user'].value, r.args['ssh_key'].value
|
||||
inventory = inventory.format(host, host, user, ssh_key)
|
||||
args = []
|
||||
for arg in r.args:
|
||||
args.append('{0}="{1}"'.format(arg, r.args[arg].value))
|
||||
args = ' '.join(args)
|
||||
inventory = inventory.format(host, host, user, ssh_key, args)
|
||||
log.debug(inventory)
|
||||
return inventory
|
||||
|
||||
|
@ -47,7 +47,7 @@ class BaseHandler(object):
|
||||
return tpl.render(str=str, zip=zip, **args)
|
||||
|
||||
def _make_args(self, resource):
|
||||
args = {'name': resource.name}
|
||||
args = {'resource_name': resource.name}
|
||||
args['resource_dir'] = resource.metadata['base_path']
|
||||
args.update(resource.args)
|
||||
return args
|
||||
|
Loading…
x
Reference in New Issue
Block a user