ansible / proposals

Repository for sharing and tracking progress on enhancement proposals for Ansible.
Creative Commons Zero v1.0 Universal
93 stars 19 forks source link

Consistent handling of file creation overwriting directories #111

Open abadger opened 6 years ago

abadger commented 6 years ago

Proposal: Handle overwriting of directories in a consistent manner

Author: Toshio Kuratomi <@abadger> IRC: abadger1999

Date: 2017/04/28

Motivation

Currently, we have several modules which deal specifically with file creation and others which create files as a byproduct of their operation. We should have consistent behaviour among them. This proposal is for consistent behaviour when a directory already exists at the location where the file is to be written.

Problems

We currently deal with a directory existing where we are told to create a file in several ways:

There are numerous other modules which create files as a byproduct of their actions. (See any modules which have set the add_file_common_args=True parameter). These may error if the file is a directory or do something else.

There are pros and cons for each option:

  -  stat path=filename
  - file state=absent path=filename
    when: stat_results.isdir is True
  - file: state=link path=filename

Solution proposal

Dependencies (optional)

Explain any dependencies. This section is optional but could be helpful.

Testing (optional)

Documentation (optional)

Anything else?

A few existing issues about the behaviour of file: