---
- name: ensure iso is deleted
  cs_iso:
    name: "{{ cs_resource_prefix }}-iso"
    state: absent
  register: iso
- name: verify ensure iso is deleted
  assert:
    that:
    - iso|success

- name: test download iso
  cs_iso:
    name: "{{ cs_resource_prefix }}-iso"
    url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
    os_type: Debian GNU/Linux 7(64-bit)
  register: iso
- name: verify test download iso
  assert:
    that:
    - iso|changed
    - iso.name == "{{ cs_resource_prefix }}-iso"

- name: test download iso idempotence
  cs_iso:
    name: "{{ cs_resource_prefix }}-iso"
    url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
    os_type: Debian GNU/Linux 7(64-bit)
  register: iso
- name: verify test download iso idempotence
  assert:
    that:
    - not iso|changed
    - iso.name == "{{ cs_resource_prefix }}-iso"

# TODO: on 4.6 simulator no checksum was returned
# TODO: check if this is a bug in 4.6
#- name: test download iso idempotence by checksum
#  cs_iso:
#    name: "{{ cs_resource_prefix }}-iso2"
#    checksum: "{{ iso.checksum }}"
#    url: http://mirror.switch.ch/ftp/mirror/debian-cd/current/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso
#    os_type: Debian GNU/Linux 7(64-bit)
#  register: iso2
#- name: verify test download iso idempotence by checksum
#  assert:
#    that:
#    - not iso2|changed
#    - iso2.name == "{{ cs_resource_prefix }}-iso"
#    - iso2.checksum == iso.checksum

- name: test remove iso
  cs_iso:
    name: "{{ cs_resource_prefix }}-iso"
    state: absent
  register: iso
- name: verify test remove iso
  assert:
    that:
    - iso|changed
    - iso.name == "{{ cs_resource_prefix }}-iso"

- name: test remove iso idempotence
  cs_iso:
    name: "{{ cs_resource_prefix }}-iso"
    state: absent
  register: iso
- name: verify test remove iso idempotence
  assert:
    that:
    - not iso|changed
