Skip to content

Grains refresh/reload failed #57468

Open
Open

Description

@AmiramMaimon

I'm trying to reload the minion grains during a sls run with no success.
I have tried to use:

  • reload_grains: True
  • saltutil.grains_refresh
  • salt service.running restart (using the watch statement)

Using each of the above function I failed to reload the grains during the state run.

Consider the following example:

before:
  cmd.run:
    - name: echo "{{ grains['dns'] }}"

echo "domain test" >> /etc/resolv.conf:
  cmd.run: []

after:
  cmd.run:
    - name: echo "{{ grains['dns'] }}"

At the before id I expect the domain field to be empty while on the after id I expect that the domain field would containtest
Another example, when i file.managed the grains.conf file I want that the grains change will take affect on the current run.

How can I achieve that?

I'm running on Ubuntu 16.04 with salt-minion and salt-master version 3000.3

Activity

  1. added
    bug
    on May 27, 2020
  2. added
    Core
    P4
    on May 27, 2020
  3. added this to the Approved milestone on May 27, 2020
  4. removed
    P4
    on Jun 3, 2020
  5. added
    severity-high
    on Jul 6, 2020
  6. added
    Aluminium
    on Jul 29, 2020
  7. sagetherage commented on Feb 17, 2021

    @sagetherage
    Contributor

    the Core team will not be able to get to this in Aluminium but we will review a PR if anyone in the community wants to submit one, moving to Silicon

  8. removed this from the Aluminium milestone on Feb 17, 2021
  9. 9 remaining items

  10. modified the milestones: Silicon, Approved on Aug 12, 2021
  11. added
    Phosphorus v3005.0
    and removed
    Silicon v3004.0
    on Sep 20, 2021
  12. garethgreenaway commented on Feb 16, 2022

    @garethgreenaway
    Contributor

    @AmiramMaimon Apologies for the delay, circling back on this one. If we look back at your original state where you're looking at the value of dns in the available grains, then updating the file which is the basis of that grain in the same state, because the state has been rendered already the values of the grains are not going to be updated until you run the state again which would cause the state to be rendered again with the updated grains. Anything that is wrapped in jinja templating will be rendered once and only once.

    What is the problem that you're looking to solve by updating the grain and then using it that update later?

  13. removed
    Phosphorus v3005.0
    on Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreGrainsbugseverity-high

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions