pyinfra-dev / pyinfra-dev/pyinfra

hard to remove file-or-link

Open
#807 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
6k
Forks
548
Avg merge
7d 17h
Merged PRs (30d)
13

Description

1  files.file(path='/etc/resolv.conf', present=False)
2  files.link(path='/etc/resolv.conf', present=False)
3  files.template(src='templates/resolv.conf.j2', dest='/etc/resolv.conf', ns='10.2.0.1')

If I run 1,2,3 I get
--> pyinfra error: /etc/resolv.conf exists and is not a file

If I run just 2,3 I get (on another host)
--> pyinfra error: /etc/resolv.conf exists and is not a link

If I run just 3 I get no errors, but I'm left with some hosts having a symlink and some having a file.

I expected just 3 to work and replace symlinks with the templated file.

May be related to #791

Meta

System: Linux
  Platform: Linux-5.13.0-40-generic-x86_64-with-glibc2.34
  Release: 5.13.0-40-generic
  Machine: x86_64
pyinfra: v2.1
Executable: env/bin/pyinfra
Python: 3.9.9 (CPython, GCC 10.3.0)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the three sequences in the issue with files.file, files.link, and files.template on hosts where /etc/resolv.conf is a file or symlink. Read the implementations of those operations and compare their handling of existing paths. Done means the templated file operation works consistently when /etc/resolv.conf is either a file or a symlink, with regression coverage for the reported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.