# Server 2008 R2 uses a 3rd party program to foward the ports and it may
# not be ready straight away, we give it at least 5 minutes before
# conceding defeat
- name: Windows - make sure the port forwarder is active
  win_wait_for:
    host: ansible.http.tests
    port: 80
    state: started
    timeout: 300

- name: Windows - Get client cert/key
  win_get_url:
    url: http://ansible.http.tests/{{ item }}
    dest: '{{ remote_tmp_dir }}\{{ item }}'
  register: win_download
  # Server 2008 R2 is slightly slower, we attempt 5 retries
  retries: 5
  until: win_download is successful
  with_items:
    - client.pem
    - client.key

- name: Windows - Retrieve test cacert
  win_get_url:
    url: http://ansible.http.tests/cacert.pem
    dest: '{{ remote_tmp_dir }}\cacert.pem'

- name: Windows - Update ca trust
  win_certificate_store:
    path: '{{ remote_tmp_dir }}\cacert.pem'
    state: present
    store_location: LocalMachine
    store_name: Root
