saltstack / saltstack/salt

Grains refresh/reload failed

Open
#57,468 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Core Grains severity-high
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how grains are loaded during cmd.run state execution, then compare the behavior of reload_grains, saltutil.grains_refresh, service.running, and file.managed. Verify whether changes to /etc/resolv.conf or grains.conf can affect later states in the same run, and define done as the after state observing the updated grain value.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.