# 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
    command: yum clean all
    always_run: yes
    when: not testing

  - name: clean all metadata (w/ infrastructure-testing enabled)
    command: yum clean all --enablerepo=infrastructure-testing
    always_run: yes
    when:  testing

  - 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
