bifrost-cli: fix relative paths in --extra-vars
Ansible accepts YAML files via the syntax `-e @path.yaml`. Since
bifrost-cli changes the working directory to "playbooks", relative paths
don't work as expected. Fix that by turning them into global paths.
Change-Id: I02ba2ac85c72362dbc424037c3d23231098e065b
(cherry picked from commit f0f6e6aa9e
)
This commit is contained in:
parent
5173c214f2
commit
06bc9e4eae
|
@ -47,6 +47,14 @@ def log(*message, only_if=True):
|
|||
print(*message, file=sys.stderr)
|
||||
|
||||
|
||||
def process_extra_vars(extra_vars):
|
||||
for item in extra_vars:
|
||||
if item.startswith('@'):
|
||||
# Make sure relative paths still work
|
||||
item = '@' + os.path.abspath(item[1:])
|
||||
yield ('-e', item)
|
||||
|
||||
|
||||
def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None,
|
||||
**params):
|
||||
extra = COMMON_PARAMS[:]
|
||||
|
@ -55,7 +63,7 @@ def ansible(playbook, inventory, verbose=False, env=None, extra_vars=None,
|
|||
if pair[1] is not None))
|
||||
if extra_vars:
|
||||
extra.extend(itertools.chain.from_iterable(
|
||||
('-e', item) for item in extra_vars))
|
||||
process_extra_vars(extra_vars)))
|
||||
if verbose:
|
||||
extra.append('-vvvv')
|
||||
args = [ANSIBLE, playbook, '-i', inventory] + extra
|
||||
|
|
Loading…
Reference in New Issue