# requires --extra-vars="target='host1;host2;group etc' package='python-tahrir'"
#
# Alternatively, you could update a group of packages like
# --extra-vars="target='host1;host2' package='python-t*'"
#
# To update from testing, adjust as follow:
# --extra-vars="target='host1;host2' package='python-t*' testing=True"

- name: push packages out
  hosts: "{{target}}"
  user: root

  vars:
    testing: False

  tasks:

  - name: clean all metadata {%if testing%}(with infrastructure-testing on){%endif%}
    command: yum clean all {%if testing%} --enablerepo=infrastructure-testing {%endif%}
    always_run: yes

  - name: yum update {{ package }} from main repo
    yum: name="{{ package }}" state=latest
    when: not testing

  - name: yum update {{ package }} from testing repo
    yum: name="{{ package }}" state=latest enablerepo=infrastructure-testing
    when: testing
