- name: Set up those proxy redirects.  Wow!
  hosts: proxies-stg:proxies
  user: root
  gather_facts: True

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - "/srv/private/ansible/vars.yml"
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  handlers:
  - include: "{{ handlers }}/restart_services.yml"

  roles:

  # An exceptional rewrite for bugz.fp.o
  - role: packages/bugz.fp.o
    website: bugz.fedoraproject.org


  # Various app redirects
  - role: httpd/redirect
    name: community
    website: admin.fedoraproject.org
    path: /community
    target: https://apps.fedoraproject.org/packages

  - role: httpd/redirect
    name: docs
    website: fedoraproject.org
    path: /docs
    target: https://docs.fedoraproject.org/

  - role: httpd/redirect
    name: elections
    website: admin.fedoraproject.org
    path: /voting
    target: https://apps.fedoraproject.org/voting

  - role: httpd/redirect
    name: people-fp-o
    website: people.fedoraproject.org
    target: https://fedorapeople.org/

  - role: httpd/redirect
    name: fas
    website: fas.fedoraproject.org
    target: https://admin.fedoraproject.org/accounts/

  - role: httpd/redirect
    name: bodhi
    website: bodhi.fedoraproject.org
    target: https://admin.fedoraproject.org/updates/

  - role: httpd/redirect
    name: get-fedora
    website: get.fedoraproject.org
    target: https://getfedora.org/
    status: 302

  - role: httpd/redirect
    name: flocktofedora
    website: flocktofedora.org
    target: http://www.flocktofedora.org/
    status: 302

  - role: httpd/redirect
    name: fedoramy
    website: fedora.my
    target: http://www.fedora.my/
    status: 302

  - role: httpd/redirect
    name: join-fedora
    website: join.fedoraproject.org
    target: https://fedoraproject.org/wiki/Join
    status: 302

  - role: httpd/redirect
    name: get-help
    website: help.fedoraproject.org
    target: https://fedoraproject.org/get-help
    status: 302

  - role: httpd/redirect
    name: l10n
    website: l10n.fedoraproject.org
    target: https://translate.fedoraproject.org/


  # Redirect specific websites from fedoraproject.org to getfedora.org
  - role: httpd/redirect
    name: main-fedoraproject
    website: fedoraproject.org
    path: /index.html
    target: https://getfedora.org/

  - role: httpd/redirect
    name: get-fedora-old
    website: fedoraproject.org
    path: /get-fedora
    target: https://getfedora.org/

  - role: httpd/redirect
    name: sponsors
    website: fedoraproject.org
    path: /sponsors
    target: https://getfedora.org/sponsors

  - role: httpd/redirect
    name: code-of-conduct
    website: fedoraproject.org
    path: /code-of-conduct
    target: https://getfedora.org/code-of-conduct

  - role: httpd/redirect
    name: verify
    website: fedoraproject.org
    path: /verify
    target: https://getfedora.org/verify

  - role: httpd/redirect
    name: keys
    website: fedoraproject.org
    path: /keys
    target: https://getfedora.org/keys

  - role: httpd/redirect
    name: release-banner
    website: fedoraproject.org
    path: /static/js/release-counter-ext.js
    target: https://getfedora.org/static/js/release-counter-ext.js

#
# When there is no prerelease we redirect the prerelease urls
# back to the main release. 
# This should be disabled when there is a prerelease
#
    name: prerelease-to-final
    website: getfedora.org
    regex: /(.*)/prerelease.*$
    target: https://stg.getfedora.org/$1
    when: env == 'staging'

  - role: httpd/redirectmatch
    name: prerelease-to-final
    website: getfedora.org
    regex: /(.*)/prerelease.*$
    target: https://getfedora.org/$1
    when: env != 'staging'

  - role: httpd/redirect
    name: store
    website: store.fedoraproject.org
    target: "https://redhat.corpmerchandise.com/ProductList.aspx?did=20588"

  # Fonts on the wiki
  - role: httpd/redirect
    name: fonts-wiki
    website: fonts.fedoraproject.org
    target: https://fedoraproject.org/wiki/Category:Fonts_SIG
    status: 302


  # Releng
  - role: httpd/redirect
    name: nightly
    website: nightly.fedoraproject.org
    target: https://alt.fedoraproject.org/pub/alt/nightly-composes/


  # Send fp.com to fp.org
  - role: httpd/redirect
    name: site
    website: fedoraproject.com
    target: https://getfedora.org/


  # Planet/people convenience
  - role: httpd/redirect
    name: infofeed
    website: fedoraproject.org
    path: /infofeed
    target: http://planet.fedoraproject.org/infofeed

  - role: httpd/redirect
    name: people
    website: fedoraproject.org
    path: /people
    target: http://planet.fedoraproject.org/

  - role: httpd/redirect
    name: fedorapeople
    website: fedoraproject.org
    path: /fedorapeople
    target: http://planet.fedoraproject.org/


  # QA
  - role: httpd/redirect
    name: qa
    website: qa.fedoraproject.org
    target: https://fedoraproject.org/wiki/QA


  # Various community sites
  - role: httpd/redirect
    name: it-fedoracommunity-redirect
    website: it.fedoracommunity.org
    target: http://www.fedoraonline.it/
    status: 302

  - role: httpd/redirect
    name: uk-fedoracommunity-redirect
    website: uk.fedoracommunity.org
    target: http://www.fedora-uk.org/
    status: 302


  # Spins
  - role: httpd/redirect
    name: kde
    website: kde.fedoraproject.org
    target: https://spins.fedoraproject.org/kde/
    status: 302


  # Various sites that we are friends with
  - role: httpd/redirect
    name: port389
    website: port389.org
    target: http://directory.fedoraproject.org/

  - role: httpd/redirect
    name: k12linux
    website: k12linux.org
    target: https://fedorahosted.org/k12linux/


  # Cloudy bits
  - role: httpd/redirect
    name: cloud-front-page
    website: cloud.fedoraproject.org
    target: https://getfedora.org/cloud/

  - role: httpd/redirectmatch
    name: redirect-cloudstart
    website: redirect.fedoraproject.org
    regex: /(console\.aws\.amazon\.com/ec2/v2/home.*)$
    target: https://$1

  ## Cloud image redirects

  # Redirects/pointers for fedora 22 BASE cloud images
  - role: httpd/redirect
    name: cloud-base-64bit-22
    website: cloud.fedoraproject.org
    path: /fedora-22.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2

  - role: httpd/redirect
    name: cloud-base-64bit-22-raw
    website: cloud.fedoraproject.org
    path: /fedora-22.x86_64.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.raw.xz

  - role: httpd/redirect
    name: cloud-base-32bit-22-raw
    website: cloud.fedoraproject.org
    path: /fedora-22.i386.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/i386/Images/Fedora-Cloud-Base-22-20150521.i386.raw.xz

  - role: httpd/redirect
    name: cloud-base-32bit-22
    website: cloud.fedoraproject.org
    path: /fedora-22.i386.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/i386/Images/Fedora-Cloud-Base-22-20150521.i386.qcow2

  # Redirects/pointers for fedora 22 ATOMIC cloud images
  - role: httpd/redirect
    name: cloud-atomic-64bit-22
    website: cloud.fedoraproject.org
    path: /fedora-atomic-22.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Atomic-22-20150521.x86_64.qcow2

  - role: httpd/redirect
    name: cloud-atomic-64bit-22-raw
    website: cloud.fedoraproject.org
    path: /fedora-atomic-22.x86_64.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Atomic-22-20150521.x86_64.raw.xz

  # Redirects/pointers for fedora 21 BASE cloud images
  - role: httpd/redirect
    name: cloud-base-64bit-21
    website: cloud.fedoraproject.org
    path: /fedora-21.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora-Cloud-Base-20141203-21.x86_64.qcow2

  - role: httpd/redirect
    name: cloud-base-64bit-21-raw
    website: cloud.fedoraproject.org
    path: /fedora-21.x86_64.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora-Cloud-Base-20141203-21.x86_64.raw.xz

  - role: httpd/redirect
    name: cloud-base-32bit-21-raw
    website: cloud.fedoraproject.org
    path: /fedora-21.i386.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/i386/Fedora-Cloud-Base-20141203-21.i386.raw.xz

  - role: httpd/redirect
    name: cloud-base-32bit-21
    website: cloud.fedoraproject.org
    path: /fedora-21.i386.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/i386/Fedora-Cloud-Base-20141203-21.i386.qcow2

  # Redirects/pointers for fedora 21 ATOMIC cloud images
  - role: httpd/redirect
    name: cloud-atomic-64bit-21
    website: cloud.fedoraproject.org
    path: /fedora-atomic-21.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora-Cloud-Atomic-20141203-21.x86_64.qcow2

  - role: httpd/redirect
    name: cloud-atomic-64bit-21-raw
    website: cloud.fedoraproject.org
    path: /fedora-atomic-21.x86_64.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora-Cloud-Atomic-20141203-21.x86_64.raw.xz

  # Except, there are no 32bit atomic images atm.
  #- role: httpd/redirect
  #  name: cloud-atomic-32bit-21-raw
  #  website: cloud.fedoraproject.org
  #  path: /fedora-atomic-21.i386.raw.xz
  #  target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/i386/Fedora-Cloud-Atomic-20141203-21.i386.raw.xz

  #- role: httpd/redirect
  #  name: cloud-atomic-32bit-21
  #  website: cloud.fedoraproject.org
  #  path: /fedora-atomic-21.i386.qcow2
  #  target: https://download.fedoraproject.org/pub/fedora/linux/releases/21/Cloud/Images/i386/Fedora-Cloud-Atomic-20141203-21.i386.qcow2

  # Redirects/pointers for fedora 20 cloud images
  - role: httpd/redirect
    name: cloud-64bit-20
    website: cloud.fedoraproject.org
    path: /fedora-20.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/x86_64/Fedora-x86_64-20-20140407-sda.qcow2

  - role: httpd/redirect
    name: cloud-32bit-20
    website: cloud.fedoraproject.org
    path: /fedora-20.i386.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/i386/Fedora-i386-20-20140407-sda.qcow2

  - role: httpd/redirect
    name: cloud-64bit-20-raw
    website: cloud.fedoraproject.org
    path: /fedora-20.x86_64.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/x86_64/Fedora-x86_64-20-20140407-sda.raw.xz

  - role: httpd/redirect
    name: cloud-32bit-20-raw
    website: cloud.fedoraproject.org
    path: /fedora-20.i386.raw.xz
    target: https://download.fedoraproject.org/pub/fedora/linux/updates/20/Images/i386/Fedora-i386-20-20140407-sda.raw.xz

  # Redirects/pointers for fedora 19 cloud images
  - role: httpd/redirect
    name: cloud-64bit-19
    website: cloud.fedoraproject.org
    path: /fedora-19.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/updates/19/Images/x86_64/Fedora-x86_64-19-20140407-sda.qcow2

  - role: httpd/redirect
    name: cloud-32bit-19
    website: cloud.fedoraproject.org
    path: /fedora-19.i386.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/updates/19/Images/i386/Fedora-i386-19-20140407-sda.qcow2

  # Redirects/pointers for latest fedora cloud images.
  - role: httpd/redirect
    name: cloud-64bit-latest
    website: cloud.fedoraproject.org
    path: /fedora-latest.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2

  - role: httpd/redirect
    name: cloud-32bit-latest
    website: cloud.fedoraproject.org
    path: /fedora-latest.i386.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/i386/Images/Fedora-Cloud-Base-22-20150521.i386.qcow2

  - role: httpd/redirect
    name: cloud-atomic-64bit-latest
    website: cloud.fedoraproject.org
    path: /fedora-atomic-latest.x86_64.qcow2
    target: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Atomic-22-20150521.x86_64.qcow2
