Skip to content

Commit

Permalink
The echo flag now includes logic for displaying the embedded inventor…
Browse files Browse the repository at this point in the history
…y command
  • Loading branch information
Tejeda, Engelbert committed Aug 2, 2019
1 parent dc10e6e commit 5f1cd13
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ansible_taskrunner/lib/providers/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,32 @@ def invocation(yaml_input_file=None,
'-e {k}="{v}"'.format(k=key, v=value) for key, value in kwargs.items() if value]
ansible_extra_options.append('-e %s' % paramset_var)
# Build command string
inventory_command = '''
if [[ ($inventory) && ( '{emb}' == 'True') ]];then
echo -e """{ins}""" | while read line;do
eval "echo -e ${{line}}" >> "{inf}"
done
fi
'''.format(
emb=embedded_inventory,
ins=inventory_input,
inf=ansible_inventory_file_path,
)
inventory_command = reindent(inventory_command,0)
pre_commands = '''
{anc}
{dsv}
{dlv}
{clv}
{bfn}
if [[ ($inventory) && ( '{emb}' == 'True') ]];then
echo -e """{ins}""" | while read line;do
eval "echo -e ${{line}}" >> "{inf}"
done
fi
{inc}
'''.format(
anc=ansi_colors,
dlv='\n'.join(list_vars),
dsv='\n'.join(string_vars),
clv=cli_vars,
bfn='\n'.join(bash_functions),
ins=inventory_input,
inf=ansible_inventory_file_path,
emb=embedded_inventory,
inc=inventory_command,
deb=debug
)
ansible_command = '''
Expand All @@ -122,7 +128,10 @@ def invocation(yaml_input_file=None,
if prefix == 'echo':
if debug:
print(pre_commands)
print(ansible_command)
print(ansible_command)
else:
print(inventory_command)
print(ansible_command)
else:
CLIInvocation().call(command)
# Debugging
Expand Down

0 comments on commit 5f1cd13

Please sign in to comment.