Execute module only, if package is installed

18 views
Skip to first unread message

Denny Fuchs

unread,
Jun 18, 2019, 10:30:12 AM6/18/19
to Ansible Development
hi,

I'm pretty new to Ansible (2.8 on Debian Stretch) and we have very simple playbook for upgrading packages, including run rkhunter / puppet / reboot etc. My problem is, that I do not have puppet an all nodes installed, so I tried:

---
#vim:ts=2:sts=2:sw=2:et
  - hosts: all
    serial: 1
    tasks:
      - name: Gather package facts
        package_facts:
          manager: auto
      - name: Run puppet to apply last changes
        puppet:

      - include_tasks: update_packages.yaml

      - include_tasks: reboot.yaml

      - name: "Puppet test result"
        debug:
          msg: "Puppet found"
        when: "'puppet' in ansible_facts.packages"

      - name: Run puppet to fix possible changes
        puppet:

Problem is: on  nodes where "puppet" is installed, puppet is skipped and on nodes, where puppet is NOT install, the task fails. What I'm doing wrong ?

cu denny
Reply all
Reply to author
Forward
0 new messages