Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modile file, State=absent ignores recursive=false and does rmtree automatically for directory #52653

Open
ewarnke opened this Issue Feb 20, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@ewarnke
Copy link

ewarnke commented Feb 20, 2019

SUMMARY

File module ignores recursive=no and force=no and does rmtree on previous state=directory state=absent.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

File module

ANSIBLE VERSION
ansible 2.7.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/etc/ansible/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Nov  1 2018, 03:12:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36.0.1)]
CONFIGURATION
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=60s
ANSIBLE_SSH_CONTROL_PATH(/etc/ansible/ansible.cfg) = %(directory)s/%%h-%%r
ANSIBLE_SSH_CONTROL_PATH_DIR(/etc/ansible/ansible.cfg) = ~/.ansible/cp
CACHE_PLUGIN(/etc/ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/etc/ansible/ansible.cfg) = /root/ansible_cache
DEFAULT_GATHERING(/etc/ansible/ansible.cfg) = explicit
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/modules']
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 300
OS / ENVIRONMENT
STEPS TO REPRODUCE

We have a large number of hosts and encountered this when removing links across our inventory. One host the link was an actual directory and we had presumed that setting recursive=false would have raised an error and not gone ahead and blown away hundred of gigs of data.

EXPECTED RESULTS

shutil.rmtree should only be executed if previous state=directory AND recursive is set, otherwise unlink should be attempted, which will fail for non-empty directories.

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Feb 20, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.