Custom grains are not being recognized/persisting. We made a custom salt grain in the minion config ('/opt/local/etc/salt/minion') and performed saltutil.sync_grains which caused the grain to be updated but when we do run using cmd.run (which defaults to 'shell: /bin/sh'). It still performs our commands in /sh instead of /bash as we tried to set it.
grains:
shell: /bin/bashIs there a more definitive procedure to add a custom grain to define shell usage?
Bonus inquiry: how to have cmd.run calls in a state/sls file to use the same instance of a bash terminal?
Is the following a legitimate process to achieve the same instance for each cmd.run call? --->
install_software:
cmd.run:
- names:
-'. /h/scripts/my_script_that_sets_env_vars.sh'
-'/h/scripts/service stop'
-'sleep 30'
-'/var/tmp/software/installation.bin'
- cwd: '/h'
Salt-master: CentOS 7
Salt Version:
Dependency Versions:
System Versions:
Salt-minion: Solaris 10
Salt Version:
Dependency Versions:
System Versions:
Are you doing Grains or grains? the correct key is grains.
Also, you can just put shell: /bin/bash in /etc/salt/grains, and then the minion doesn't have to be restarted to load the grains, you just have to call saltutil.refresh_grains
'grains', I changed the post to reflect proper capitalization.
Would that shell: /bin/bash be within a config file in /etc/salt/grains? Can you flesh out that method of defining grains?
Also, for my additional question, do you have a thought on it?
Thank you!
/etc/salt/grains is just a yaml formatted file that gets converted to a dictionary and added to the grains dictionary.
so
/etc/salt/grains
shell: /bin/bash
Should work.
Daniel
You can also use the grains.set module and it will put it in the /etc/salt/grains file.
salt 'minionid' grains.set shell /bin/bash
Thank you for the information! I hadn't used saltutil.refresh_grains and that was why it was not reflected in the minion's salt 'target' grains.items listing.
Most helpful comment
Are you doing
Grainsorgrains? the correct key isgrains.Also, you can just put
shell: /bin/bashin /etc/salt/grains, and then the minion doesn't have to be restarted to load the grains, you just have to callsaltutil.refresh_grains