|
|
|
|
@ -228,6 +228,11 @@ stderr_lines:
|
|
|
|
|
returned: always
|
|
|
|
|
type: list
|
|
|
|
|
sample: [u'ls cannot access foo: No such file or directory', u'ls …']
|
|
|
|
|
skip_reason:
|
|
|
|
|
description: The reason why the task was skipped.
|
|
|
|
|
returned: when task is skipped
|
|
|
|
|
type: str
|
|
|
|
|
sample: 'skipped, since /tmp/file exists'
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import datetime
|
|
|
|
|
@ -235,11 +240,21 @@ import glob
|
|
|
|
|
import os
|
|
|
|
|
import shlex
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils._internal import _deprecator
|
|
|
|
|
from ansible.module_utils._internal._datatag import _tags
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
from ansible.module_utils.common.text.converters import to_native, to_bytes, to_text
|
|
|
|
|
from ansible.module_utils.common.collections import is_iterable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_DEPRECATE_SKIPPED_STDOUT = _tags.Deprecated(
|
|
|
|
|
msg='`stdout` is deprecated when creates/removes is used',
|
|
|
|
|
version='2.24',
|
|
|
|
|
deprecator=_deprecator.ANSIBLE_CORE_DEPRECATOR,
|
|
|
|
|
help_text='Use `skip_reason` instead.',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
# the command module is the one ansible module that does not take key=value args
|
|
|
|
|
@ -313,15 +328,16 @@ def main():
|
|
|
|
|
if creates:
|
|
|
|
|
if glob.glob(creates):
|
|
|
|
|
r['msg'] = "%s not run command since '%s' exists" % (shoulda, creates)
|
|
|
|
|
r['stdout'] = "skipped, since %s exists" % creates # TODO: deprecate
|
|
|
|
|
|
|
|
|
|
r['stdout'] = _DEPRECATE_SKIPPED_STDOUT.tag("skipped, since %s exists" % creates)
|
|
|
|
|
r['skip_reason'] = "skipped, since %s exists" % creates
|
|
|
|
|
r['rc'] = 0
|
|
|
|
|
|
|
|
|
|
# special skips for idempotence if file does not exist (assumes command removes)
|
|
|
|
|
if not r['msg'] and removes:
|
|
|
|
|
if not glob.glob(removes):
|
|
|
|
|
r['msg'] = "%s not run command since '%s' does not exist" % (shoulda, removes)
|
|
|
|
|
r['stdout'] = "skipped, since %s does not exist" % removes # TODO: deprecate
|
|
|
|
|
r['stdout'] = _DEPRECATE_SKIPPED_STDOUT.tag("skipped, since %s does not exist" % removes)
|
|
|
|
|
r['skip_reason'] = "skipped, since %s does not exist" % removes
|
|
|
|
|
r['rc'] = 0
|
|
|
|
|
|
|
|
|
|
if r['msg']:
|
|
|
|
|
@ -343,6 +359,7 @@ def main():
|
|
|
|
|
if creates is None and removes is None:
|
|
|
|
|
r['skipped'] = True
|
|
|
|
|
# skipped=True and changed=True are mutually exclusive
|
|
|
|
|
r['skip_reason'] = r['msg']
|
|
|
|
|
r['changed'] = False
|
|
|
|
|
|
|
|
|
|
# convert to text for jsonization and usability
|
|
|
|
|
|