Do not add state: absent when a non-existent path is returned (#51350)

Leave it up to the module to return the state in the results.

I went through all the modules in files/ and only found one case where the module needed to return this. No other modules return paths that do not exists.

Signed-off-by: Sam Doran <sdoran@redhat.com>
This commit is contained in:
Sam Doran 2019-02-22 19:48:44 -05:00 committed by Dag Wieers
parent d65a91ea7e
commit cc9c72d6f8
3 changed files with 4 additions and 4 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- 'do not return ``state: absent`` when the module returns either ``path`` or ``dest`` but the file does not exists (https://github.com/ansible/ansible/issues/35382)'

View file

@ -1559,8 +1559,6 @@ class AnsibleModule(object):
if HAVE_SELINUX and self.selinux_enabled():
kwargs['secontext'] = ':'.join(self.selinux_context(path))
kwargs['size'] = st[stat.ST_SIZE]
else:
kwargs['state'] = 'absent'
return kwargs
def _check_locale(self):

View file

@ -470,9 +470,9 @@ def ensure_absent(path):
'path': path})
diff = initial_diff(path, 'absent', prev_state)
result.update({'path': path, 'changed': True, 'diff': diff})
result.update({'path': path, 'changed': True, 'diff': diff, 'state': 'absent'})
else:
result.update({'path': path, 'changed': False})
result.update({'path': path, 'changed': False, 'state': 'absent'})
return result