How can I make Ansible execute a shell script if a (rpm) package is not installed? Is it somehow possible to leverage the yum module?
相关问题
- Access ansible.cfg variable in task
- Unable to get “exclude” option working with unarch
- Ansible: find file and loop over paths
- Generating tuples variables in ansible templates
- Ansible: setting user on dynamic ec2
相关文章
- Ansible create postgresql user with access to all
- Difference between shell and command in ansible
- How to make Ansible run one certain task only on o
- clone a specific branch from git through ansible p
- Check if a list contains an item in Ansible
- Defining host as variable in Ansible hosts file
- ansible/jinja2 get unique subelements
- Custom credentials in Ansible Tower with Custom Py
You shouldn't be using
dpkg -l package
because it has no idea if your package has been removed or is still installed.Instead it's probably better to use
dpkg -s package
.To check if the package is installed :
-
shell: dpkg -s package | grep 'install ok installed'
or if you don't mind the package on hold or other states :
-
shell: dpkg -s package | grep 'installed'
This return 0 when installed and 1 if not.
(It's important to use the shell as we are using a pipe
|
)