[BUG] file.accumulated won't accumulate duplicate text
Open
Nobody has claimed this yet.
bug
severity-medium
State-Module
ZD
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
When using file.accumulated, duplicate text fields can not be added to a given named accumulator.
Setup
brothers.sls:
accumulate_distinct_brothers:
file.accumulated:
- name: uncledonald
- filename: /tmp/brothers.conf
- text:
- Huey
- Dewey
- Louie
- require_in:
- file: brothers.conf
accumulate_duplicate_brothers:
file.accumulated:
- name: newhart
- filename: /tmp/brothers.conf
- text:
- Larry
- Darryl
- Darryl
- require_in:
- file: brothers.conf
brothers.conf:
file.managed:
- name: /tmp/brothers.conf
- source: salt://brothers.jinja
- template: jinja
brothers.jinja:
{% for key, text in accumulator.items() -%}
{{ key }}: {{ text|join(', ') }}
{% endfor %}
Steps to Reproduce the behavior
[root@master1 ~]# salt-call --state-output terse state.apply brothers
local:
Name: uncledonald - Function: file.accumulated - Result: Clean Started: - 12:08:40.767783 Duration: 1.319 ms
Name: newhart - Function: file.accumulated - Result: Clean Started: - 12:08:40.776429 Duration: 1.363 ms
Name: /tmp/brothers.conf - Function: file.managed - Result: Changed Started: - 12:08:40.784444 Duration: 29.927 ms
Summary for local
------------
Succeeded: 3 (changed=1)
Failed: 0
------------
Total states run: 3
Total run time: 32.609 ms
[root@master1 ~]# cat /tmp/brothers.conf
uncledonald: Huey, Dewey, Louie
newhart: Larry, Darryl
Expected behavior
The other brother Darryl should show up in the resulting file:
uncledonald: Huey, Dewey, Louie
newhart: Larry, Darryl, Darryl
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3001.1
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.11.1
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Apr 2 2020, 13:34:55)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.1.4
System Versions:
dist: centos 7 Core
locale: UTF-8
machine: x86_64
release: 5.4.0-42-generic
system: Linux
version: CentOS Linux 7 Core
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 with the file.accumulated state described in the issue and reproduce the brothers.sls example to confirm that duplicate text is omitted. Trace how the named accumulator handles the text list, then add coverage for repeated values and verify that the generated brothers.conf contains both occurrences of Darryl.
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
- Clearly specified
- Newbie friendliness
- 52/100