# This playbook updates hosts without guests.
#
# requires -e "target=somehostname" -e "yumcommand=update"


- name: update the system
  hosts: "{{ target }}"
  gather_facts: false
  remote_user: root
 
  tasks: 
#  - name: expire-caches
#    command: yum clean expire-cache
    
#  - name: yum -y {{ yumcommand }}
#    command: yum -y {{ yumcommand }}
#    async: 7200
#    poll: 30

  - name: Update all the packages
    yum: name=* state=latest update_cache=yes
    async: 7200
    poll: 30

- name: run rkhunter if installed
  hosts:  "{{ target }}"
  remote_user: root

  tasks:
  - 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