# requires --extra-vars="target='host1;host2;group etc' yumcommand=update'"

- name: update all run rkhunter if installed
  hosts: "{{ target }}"
  gather_facts: true
  user: root

  tasks:
  - name: run yum on yummy hosts yum -y {{ yumcommand }}
    yum: name=* update_cache=true state=latest
    when: ansible_distribution == "CentOS"

  - name: run dnf on dnfy hosts dnf -y {{ yumcommand }}
    dnf: name=* state=latest
    when: ansible_distribution == "Fedora"

  - name: check for rkhunter
    command: /usr/bin/test -f /usr/bin/rkhunter
    register: rkhunter
    ignore_errors: true
  
  - name: run rkhunter --propupd
    command: /usr/bin/rkhunter --propupd
    when: rkhunter|success
