Skip to content

salt.states.grains.list_present adds duplicates names #31427

@githubcdr

Description

@githubcdr

Hi,

I noticed that using the 'grains' state multiple times results in duplicate list items. One would expect that the grains state immediately updates the roles grains after modifying it.

For example this state

# set roles
roles-nginx:
  grains.list_present:
    - name: roles
    - value:
      - webserver
      - webserver-nginx
    - require:
      - service: nginx-service

roles-nginx-php-fpm:
  grains.list_present:
    - name: roles
    - value:
      - php
      - php-fpm
      - webserver
      - webserver-nginx
      - webserver-nginx-php-fpm

yields this result

zsh 386 # salt minion grains.item roles
minion:
    ----------
    roles:
        - webserver
        - webserver-nginx
        - php
        - php-fpm
        - webserver
        - webserver-nginx
        - webserver-nginx-php-fpm

Is this a bug or a feature? It feels wrong to force a grain update in the state file?

Metadata

Metadata

Assignees

Labels

ConfirmedSalt engineer has confirmed bug/feature - often including a MCVECorerelates to code central or existential to SaltGrainsbugbroken, incorrect, or confusing behaviormust-fixseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions