We are trying to run yum install kernel-devel-$(uname -r)
via salt state file.
We tried following but it does not resolve the uname -r
at runtime. Instead it takes its value as it.
dependencies:
pkg.installed:
- pkgs:
- kernel-devel-$(uname -r)
- kernel-header-$(uname -r)
How can we handle it correctly in state file?
Try this to fetch grains.get kernelrelease
@saurabhnemade There are a couple approaches to accomplish what you're trying to do. You can use @ismail0352 's suggestion and pull the information from grains:
dependencies:
pkg.installed:
- pkgs:
- kernel-devel-{{ grains['kernelrelease'] }}
- kernel-header-{{ grains['kernelrelease'] }}
If you need to include the output from a command you can call the cmd.run module from the state file:
dependencies:
pkg.installed:
- pkgs:
- kernel-devel-{{ salt['cmd.run']('uname -r') }}
- kernel-header-{{ salt['cmd.run']('uname -r') }}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Most helpful comment
@saurabhnemade There are a couple approaches to accomplish what you're trying to do. You can use @ismail0352 's suggestion and pull the information from grains:
If you need to include the output from a command you can call the cmd.run module from the state file: