I’ve seen this problem already reported but i didn’t found any solution.
I can accept a salt key in foreman smart proxy, but the salt_minion host is not created when salt_master execute foreman-node
It 's OK if i run foreman-node my-salt-minion-host-name manually or if i run salt-call --grains from salt-minion host.
2020-09-09 12:29:55,999 [salt.loaded.int.module.cmdmod:854 ][ERROR ][8429] Command '['/usr/bin/foreman-node', 'sphynx.ac-test.fr']' failed with return code: 1
2020-09-09 12:29:56,000 [salt.loaded.int.module.cmdmod:856 ][ERROR ][8429] stdout: Could not get grains: undefined method `merge' for nil:NilClass
Couldn't retrieve ENC data: Could not send facts to Foreman: exit
2020-09-09 12:29:56,000 [salt.loaded.int.module.cmdmod:860 ][ERROR ][8429] retcode: 1
2020-09-09 12:29:56,000 [salt.loaded.int.module.cmdmod:1218][ERROR ][8429] Command '/usr/bin/foreman-node sphynx.ac-test.fr' failed with return code: 1
2020-09-09 12:29:56,001 [salt.loaded.int.module.cmdmod:1223][ERROR ][8429] output: Could not get grains: undefined method `merge' for nil:NilClass
Couldn't retrieve ENC data: Could not send facts to Foreman: exit
2020-09-09 12:29:56,001 [salt.loaded.int.pillar.puppet:31 ][CRITICAL][8429] YAML data from /usr/bin/foreman-node failed to parse
I’ve already tried this and i have the same problem : salt-key -a <minion> -y && salt-run -l quiet --output=json cache.grains <minion>
If i wait some seconds after that, cache is built (/var/cache/salt/master/<minion>/data.p file).
I’ve written a dirty bash script to see if this is a cache problem and replace foreman-node by it in ext_pillar config and it works :
I’ll try with https://yum.theforeman.org/releases/nightly/el8/x86_64/foreman-release.rpm because there is dependency problem.
I’ve installed foreman with https://yum.theforeman.org/releases/2.1/el8/x86_64/foreman-release.rpm
2020-09-16 12:28:20,774 [salt.loaded.int.module.cmdmod:854 ][ERROR ][29748] Command '['/usr/bin/foreman-node', 'sphynx.ac-test.fr']' failed with return code: 1
2020-09-16 12:28:20,774 [salt.loaded.int.module.cmdmod:856 ][ERROR ][29748] stdout: Could not get grains: No such file or directory @ rb_sysopen - /var/cache/salt/master/minions/sphynx.ac-test.fr/data.p
Couldn't retrieve ENC data: Could not send facts to Foreman: exit
2020-09-16 12:28:20,775 [salt.loaded.int.module.cmdmod:860 ][ERROR ][29748] retcode: 1
After a few seconds, the data.p file is created, but it’s too late.
For both get_grains_from_saltrun and get_grains_from_filecache, it should wait a little if cache is not ready immediatly, don’t you think ?