- name: verify the frontend, stop it, upgrade the db, and restart it
  hosts: pdc_web:pdc_web_stg
  user: root
  vars_files: 
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"

  pre_tasks:
  - name: clean all metadata
    command: yum clean all
    check_mode: no
  - name: yum update PDC packages
    yum: name="{{item}}" state=latest
    with_items:
    - python-pdc
    - python2-productmd

  roles:
  - pdc/frontend

  post_tasks:
  - name: tell nagios to shush w.r.t. the frontend
    nagios: action=downtime minutes=15 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
    delegate_to: noc01.iad2.fedoraproject.org
    ignore_errors: true
  - service: name="httpd" state=stopped
  - name: Upgrade the database, only on the primary web node.
    command: python /usr/lib/python2.7/site-packages/pdc/manage.py migrate --noinput
    args:
        chdir: /usr/lib/python2.7/site-packages/pdc/
    when: inventory_hostname_short == 'pdc-web01'
  - service: name="httpd" state=started
  - name: tell nagios to unshush w.r.t. the frontend
    nagios: action=unsilence service=host host={{ inventory_hostname_short }}{{ env_suffix }}
    delegate_to: noc01.iad2.fedoraproject.org
    ignore_errors: true
