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

blockinfile: do not crash when filename has no path #81638

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

felixfontein
Copy link
Contributor

SUMMARY

When path has no / in it and create=true, the module calls os.makedirs(''), resulting in a crash.

Fixes ansible-collections/community.general#7207.

ISSUE TYPE
  • Bugfix Pull Request

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. module This issue/PR relates to a module. has_issue labels Sep 5, 2023
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Sep 7, 2023
Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise code lgtm

path: "empty.txt"
block: Hello.
state: present
create: yes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test should be in block and have an 'always' section that removes the file created

bcoca
bcoca previously requested changes Sep 7, 2023
Copy link
Member

@bcoca bcoca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good, fix test and we can merge

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Sep 7, 2023
@ansibot ansibot added stale_review Updates were made after the last review and the last review is more than 7 days old. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 7, 2023
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Sep 16, 2023
@sivel
Copy link
Member

sivel commented Mar 20, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sivel sivel enabled auto-merge (squash) March 20, 2024 22:21
@sivel sivel dismissed bcoca’s stale review March 20, 2024 23:39

Changes made

@sivel sivel merged commit e659c23 into ansible:devel Mar 20, 2024
97 checks passed
@felixfontein felixfontein deleted the fix-path branch March 21, 2024 06:19
@felixfontein
Copy link
Contributor Author

@bcoca @sivel thanks for reviewing and merging!

felixfontein added a commit to felixfontein/ansible that referenced this pull request Mar 21, 2024
* Do not crash when filename has no path.

* Clean up file after test.

(cherry picked from commit e659c23)
felixfontein added a commit to felixfontein/ansible that referenced this pull request Mar 21, 2024
* Do not crash when filename has no path.

* Clean up file after test.

(cherry picked from commit e659c23)
sivel pushed a commit that referenced this pull request Apr 10, 2024
* Do not crash when filename has no path.

* Clean up file after test.

(cherry picked from commit e659c23)
@ansible ansible locked and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. has_issue module This issue/PR relates to a module. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

blockinfile does not create a file instead throws FileNotFoundError
4 participants