I have a package I need to install from a remote URL as in:
- get-url: url=http://foo.com/foo.deb dest=/tmp
- command: dpkg --skip-same-version -i /tmp/foo.deb
- apt: update_cache=yes
- apt: pkg=foo state=present
I'd only like to run the first 3 if pkg=foo isn't already present. What's the best way to achieve this?
You have to register a variable with the result, and then use when statement.
tasks:
- shell: /usr/bin/foo
register: result
ignore_errors: True
- debug: msg="it failed"
when: result|failed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With