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>
pull/52872/head
Sam Doran 6 years ago committed by Dag Wieers
parent d65a91ea7e
commit cc9c72d6f8

@ -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)'

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

@ -470,9 +470,9 @@ def ensure_absent(path):
'path': path}) 'path': path})
diff = initial_diff(path, 'absent', prev_state) 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: else:
result.update({'path': path, 'changed': False}) result.update({'path': path, 'changed': False, 'state': 'absent'})
return result return result

Loading…
Cancel
Save