Call os.path.expanduser in the creates= and removes= section of the command module so ~/ and the like works.
This commit is contained in:
parent
2886084ac0
commit
f3e8ffce43
1 changed files with 3 additions and 1 deletions
4
command
4
command
|
@ -145,6 +145,7 @@ class CommandModule(AnsibleModule):
|
|||
# do not run the command if the line contains creates=filename
|
||||
# and the filename already exists. This allows idempotence
|
||||
# of command executions.
|
||||
v = os.path.expanduser(v)
|
||||
if os.path.exists(v):
|
||||
self.exit_json(
|
||||
cmd=args,
|
||||
|
@ -158,10 +159,11 @@ class CommandModule(AnsibleModule):
|
|||
# do not run the command if the line contains removes=filename
|
||||
# and the filename do not exists. This allows idempotence
|
||||
# of command executions.
|
||||
v = os.path.expanduser(v)
|
||||
if not os.path.exists(v):
|
||||
self.exit_json(
|
||||
cmd=args,
|
||||
stdout="skipped, since %s do not exists" % v,
|
||||
stdout="skipped, since %s does not exist" % v,
|
||||
skipped=True,
|
||||
changed=False,
|
||||
stderr=False,
|
||||
|
|
Loading…
Reference in a new issue