mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Removes expanduser in favor of type path (#21369)
Removes the usage of expanduser in favor of the type 'path' for module options. Related to #12263
This commit is contained in:
parent
2a576a1999
commit
2bf7297bf3
1 changed files with 8 additions and 10 deletions
|
@ -130,9 +130,9 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
command=dict(required=True),
|
command=dict(required=True),
|
||||||
chdir=dict(),
|
chdir=dict(type='path'),
|
||||||
creates=dict(),
|
creates=dict(type='path'),
|
||||||
removes=dict(),
|
removes=dict(type='path'),
|
||||||
responses=dict(type='dict', required=True),
|
responses=dict(type='dict', required=True),
|
||||||
timeout=dict(type='int', default=30),
|
timeout=dict(type='int', default=30),
|
||||||
echo=dict(type='bool', default=False),
|
echo=dict(type='bool', default=False),
|
||||||
|
@ -163,18 +163,17 @@ def main():
|
||||||
module.fail_json(rc=256, msg="no command given")
|
module.fail_json(rc=256, msg="no command given")
|
||||||
|
|
||||||
if chdir:
|
if chdir:
|
||||||
chdir = os.path.abspath(os.path.expanduser(chdir))
|
chdir = os.path.abspath(chdir)
|
||||||
os.chdir(chdir)
|
os.chdir(chdir)
|
||||||
|
|
||||||
if creates:
|
if creates:
|
||||||
# do not run the command if the line contains creates=filename
|
# do not run the command if the line contains creates=filename
|
||||||
# and the filename already exists. This allows idempotence
|
# and the filename already exists. This allows idempotence
|
||||||
# of command executions.
|
# of command executions.
|
||||||
v = os.path.expanduser(creates)
|
if os.path.exists(creates):
|
||||||
if os.path.exists(v):
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
cmd=args,
|
cmd=args,
|
||||||
stdout="skipped, since %s exists" % v,
|
stdout="skipped, since %s exists" % creates,
|
||||||
changed=False,
|
changed=False,
|
||||||
rc=0
|
rc=0
|
||||||
)
|
)
|
||||||
|
@ -183,11 +182,10 @@ def main():
|
||||||
# do not run the command if the line contains removes=filename
|
# do not run the command if the line contains removes=filename
|
||||||
# and the filename does not exist. This allows idempotence
|
# and the filename does not exist. This allows idempotence
|
||||||
# of command executions.
|
# of command executions.
|
||||||
v = os.path.expanduser(removes)
|
if not os.path.exists(removes):
|
||||||
if not os.path.exists(v):
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
cmd=args,
|
cmd=args,
|
||||||
stdout="skipped, since %s does not exist" % v,
|
stdout="skipped, since %s does not exist" % removes,
|
||||||
changed=False,
|
changed=False,
|
||||||
rc=0
|
rc=0
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue