Search code examples
salt-project

When updating a salt-minion the grains.host changes to localhost, breaking states


Scenario:

  • salt-minion original version: salt-minion 2015.8.8.2 (Beryllium)
  • salt-minion updated version: salt-minion 2016.11.2 (Carbon)
  • running a state which uses grains.host breaks

Checks:

  • salt 'minion' grains.item host originally returned the hostname configured in /etc/hostname (eg: minion)
  • After the update, it returns localhost

I tried restarting the minion (as I had to change the master url anyway), also tried the undocumented sanitized=True, which only hides it away.

Any help is appreciated, couldn't find anything on the site.


Solution

  • I found recently that sometimes it does matter what are your settings in /etc/hosts.

    I had a set of hosts with FQDN like host01.company.com. And despite the same settings, one of them was having the same issues like you have. I went to /etc/hosts and removed record like

    127.0.0.1 host01 host01.company.com
    

    And after this and a minion restart, everything was fine immediately.

    Looks like there is some kind of reverse-lookup happening to set some grains.

    Hope this helps.