[BUG] 3002.6 pkgrepo.managed creates multiple identical lines in sources.list.d file for Ubuntu
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
pkgrepo.managed:
- name: {{ repostring }}
- file: /etc/apt/sources.list.d/foo.list
- key_url: {{ keyurl }}
This code in a state sls file causes the same line to be repeated in /etc/apt/sources.list.d/*.list:
deb http://repositories.tools/platforms/mo bionic main
deb http://repositories.tools/platforms/mo bionic main
deb http://repositories.tools/platforms/mo bionic main
deb http://repositories.tools/platforms/mo bionic main
deb http://repositories.tools/platforms/mo bionic main
deb http://repositories.tools/platforms/mo bionic main
deb http://repositories.tools/platforms/mo bionic main
Every state.apply adds a new identical line.
Setup
# cat foo/init.sls
{% from "foo/map.jinja" import foo with context %}
foo.repo:
pkgrepo.managed:
- name: {{ foo.repostring }}
- file: /etc/apt/sources.list.d/foo.list
- key_url: {{ foo.keyurl }}
# cat foo/map.jinja
{% set foo = salt['grains.filter_by']({
'xenial': {
'repostring': 'deb http://repositories.tools/platforms/mo xenial main',
'keyurl': 'http://repositories.tools/keys/foo.gpg',
'pkg': 'foo',
'version': '11.1'
},
'bionic': {
'repostring': 'deb http://repositories.tools/platforms/mo bionic main',
'keyurl': 'http://repositories.tools/platforms/all/all.key',
'pkg': 'foo',
'version': '11.2'
},
'focal': {
'repostring': 'deb http://repositories.tools/platforms/mo focal main',
'keyurl': 'http://repositories.tools/platforms/all/all.key',
'pkg': 'foo',
'version': '11.3'
},
}, grain='oscodename') %}
Steps to Reproduce the behavior
# salt-call state.apply
every state.apply adds a new identical line to the sources.list.d file
Expected behavior
Only one line of the same kind in the sources.list.d file.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)# salt --versions-report
Salt Version:
Salt: 3002.6
Dependency Versions:
cffi: Not Installed
cherrypy: unknown
dateutil: 2.7.3
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: 0.28.3
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: 3.6.1
pygit2: 1.0.3
Python: 3.8.5 (default, Jan 27 2021, 15:41:15)
python-gnupg: 0.4.5
PyYAML: 5.3.1
PyZMQ: 18.1.1
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.2
System Versions:
dist: ubuntu 20.04 focal
locale: utf-8
machine: x86_64
release: 5.4.0-66-generic
system: Linux
version: Ubuntu 20.04 focal
</details>
**Additional context**
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the shown pkgrepo.managed state and repeated state.apply commands, inspecting /etc/apt/sources.list.d/foo.list after each run. Trace the pkgrepo.managed entry point and its handling of the file option. Done means repeated applies leave only one identical repository line in the sources.list.d file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100