Closed yggdr closed 3 years ago
Thank you for reporting this @yggdr; I've just pushed two fixes related to this (https://github.com/Fizzadar/pyinfra/commit/0abfd55fe0e33d570f6cf3251fcba315967b4dde & https://github.com/Fizzadar/pyinfra/commit/c10ddc50dcbaa82a253c87ce35cd5a77f6356bec) that will be released shortly.
Now released in v1.4.19.
Describe the bug
Running a deploy with an
apt.repo
operation results in that repository being added despite being already present from a previous run.To Reproduce
This is part of the deploy to an Ubuntu 20.04 server:
Running the deploy multiple times results in identical lines being added:
Expected behavior
It should be recognised that the repo is already present and nothing needs to be done.
Meta
pyinfra --support
.+ Include pyinfra-debug.log (if one was created)-vv
and--debug
.--> Connecting to hosts... [pyinfra.api.connectors.ssh] Connecting to: executor.gfnw ({'allow_agent': True, 'look_for_keys': True, 'hostname': 'executor.gfnw', 'username': 'infrastructure', 'timeout': 10}) No host key for fd4b:5320:4954:6464:4::10.189.1.70 found in known_hosts [executor.gfnw] Connected [pyinfra.api.state] Activating host: executor.gfnw
--> Preparing operations... Loading: install_executor_apt.py [pyinfra.api.facts] Getting fact: lsb_release () (ensure_hosts: (Host(executor.gfnw),)) [pyinfra.api.connectors.ssh] Running command on executor.gfnw: (pty=False) sh -c '! command -v lsb_release >/dev/null || lsb_release -ca' [executor.gfnw] >>> sh -c '! command -v lsb_release >/dev/null || lsb_release -ca' [pyinfra.api.connectors.ssh] Waiting for exit status... [pyinfra.api.connectors.ssh] Command exit status: 0 Loaded fact lsb_release () [pyinfra.api.operation] Adding operation, {'Add Docker apt repository'}, opOrder=(5,), opHash=e7bd4757a271fd0d45eb5671af07ea672a855973 [pyinfra.api.facts] Getting fact: apt_sources () (ensure_hosts: (Host(executor.gfnw),)) [pyinfra.api.connectors.ssh] Running command on executor.gfnw: (pty=False) sudo -H -n sh -c '! command -v apt >/dev/null || (! test -f /etc/apt/sources.list || cat /etc/apt/sources.list) && (cat /etc/apt/sources.list.d/.list || true)' [executor.gfnw] >>> sudo -H -n sh -c '! command -v apt >/dev/null || (! test -f /etc/apt/sources.list || cat /etc/apt/sources.list) && (cat /etc/apt/sources.list.d/.list || true)' [pyinfra.api.connectors.ssh] Waiting for exit status... [pyinfra.api.connectors.ssh] Command exit status: 0 Loaded fact apt_sources () [pyinfra.api.facts] Getting fact: find_in_file (path=/etc/apt/sources.list, pattern=^.deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable.$, interpolate_variables=False) (ensure_hosts: (Hos t(executor.gfnw),)) [pyinfra.api.connectors.ssh] Running command on executor.gfnw: (pty=False) sudo -H -n sh -c 'grep -e '"'"'^.deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable.$'"'"' /etc/apt/sources.list 2> /dev/null || ( find /etc/apt/sources.list -type f > /dev/null && echo pyinfraexists/etc/apt/sources.list || true )' [executor.gfnw] >>> sudo -H -n sh -c 'grep -e '"'"'^.deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable.$'"'"' /etc/apt/sources.list 2> /dev/null || ( find /etc/apt/sources.list -type f > /dev /null && echo pyinfraexists/etc/apt/sources.list || true )' [pyinfra.api.connectors.ssh] Waiting for exit status... [pyinfra.api.connectors.ssh] Command exit status: 0 Loaded fact find_in_file (path=/etc/apt/sources.list, pattern=^.deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable.$, interpolate_variables=False) [executor.gfnw] Ready: install_executor_apt.py
--> Proposed changes: Groups: executor / gfnwtestbed [executor.gfnw] Operations: 1 Commands: 1
--> Beginning operation run... --> Starting operation: Add Docker apt repository [pyinfra.api.operations] Starting operation Add Docker apt repository on executor.gfnw [pyinfra.api.connectors.ssh] Running command on executor.gfnw: (pty=None) sudo -H -n sh -c 'echo '"'"'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable'"'"' >> /etc/apt/sources.list' [executor.gfnw] >>> sudo -H -n sh -c 'echo '"'"'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable'"'"' >> /etc/apt/sources.list' [pyinfra.api.connectors.ssh] Waiting for exit status... [pyinfra.api.connectors.ssh] Command exit status: 0 [executor.gfnw] Success
--> Results: Groups: executor / gfnwtestbed [executor.gfnw] Successful: 1 Errors: 0 Commands: 1/1