- name: Spin up maintainertest cloud instances
  hosts: maintainer-test
  gather_facts: False

  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - /srv/private/ansible/vars.yml
   - /srv/web/infra/ansible/vars/fedora-cloud.yml
   - /srv/private/ansible/files/openstack/passwords.yml

  tasks:
  - import_tasks: "{{ tasks_path }}/persistent_cloud.yml"

- name: Do some basic cloud setup on them
  hosts: maintainer-test
  gather_facts: True
  vars_files:
   - /srv/web/infra/ansible/vars/global.yml
   - /srv/private/ansible/vars.yml
   - /srv/private/ansible/files/openstack/passwords.yml
   - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  pre_tasks:
  - import_tasks: "{{ tasks_path }}/cloud_setup_basic.yml"
  - name: set hostname (required by some services, at least postfix need it)
    hostname: name="{{inventory_hostname}}"
  - debug: var=FedoraRawhideNumber
  - debug: var=FedoraBranchedNumber
  - debug: var=FedoraCycleNumber
  - debug: var=FedoraPreviousCycleNumber
  - debug: var=FedoraPreviousPreviousCycleNumber
  - debug: var=Frozen


- import_playbook: "/srv/web/infra/ansible/playbooks/include/happy_birthday.yml myhosts=arm-packager"

- name: Setup maintainer test hosts
  hosts: arm-packager:maintainer-test
  gather_facts: True
  tags:
   - maintainer-test

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

  pre_tasks:
  - import_tasks: "{{ tasks_path }}/yumrepos.yml"

  roles:
  - base
  - rkhunter
  - hosts
  - fas_client
  - sudo

  tasks:
  # this is how you include other task lists
  - import_tasks: "{{ tasks_path }}/motd.yml"

  - name: install packager tools (dnf)
    dnf: state=present pkg={{ item }}
    with_items:
    - fedora-packager
    when: ansible_distribution_major_version|int > 21
    tags:
    - packages

  - name: allow packagers to use mock
    copy: dest=/etc/pam.d/mock src="{{ files }}/common/mock"
    tags:
    - config

  handlers:
  - import_tasks: "{{ handlers_path }}/restart_services.yml"
