I've defined a pkgrepo.managed state in my salt files. On every run of salt, it is adding an additional - and identical - line in the sources.list.d directory, resulting in an apt error. A google found another post with the same situation, but no solution.
newrelic-infrastructure-repo:
pkgrepo.managed:
- humanname: Newrelic Infrastructure Agent
- name: deb https://download.newrelic.com/infrastructure_agent/linux/apt xenial main
- dist: stable
- file: /etc/apt/sources.list.d/newrelic-infrastructure.list
- require_in:
- pkg: newrelic-infra-pkg
- gpgcheck: 1
- key_url: https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg
I declared this in my .sls file and applied I expected /etc/apt/sources.list.d/newrelic-infrastructure.list to contain a single line. However, after several runs my file has multiple lines:
staging-i-0e4fb7971dd8c0f05:/etc/apt/sources.list.d$ cat newrelic-infrastructure.list
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
deb https://download.newrelic.com/infrastructure_agent/linux/apt stable main
Probably because you're defining conflicting properties. Delete the - dist: stable and then change xenial to stable.
humanname also does nothing for apt repositories.
Basically, the examples in the docs are bad.