Skip to content

Commit

Permalink
add template
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed Nov 27, 2024
1 parent 57aaa35 commit 6b2fe03
Show file tree
Hide file tree
Showing 6 changed files with 356 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/template/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cloud/cs
cs/group2
cs/group4
5 changes: 5 additions & 0 deletions tests/integration/targets/template/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cs_template_hypervisor: Simulator
cs_template_os_type: Other Linux (64-bit)
cs_template_url: http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-vmware.ova
cs_template_format: OVA
3 changes: 3 additions & 0 deletions tests/integration/targets/template/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- cs_common
3 changes: 3 additions & 0 deletions tests/integration/targets/template/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- import_tasks: test1.yml
- import_tasks: test2.yml
161 changes: 161 additions & 0 deletions tests/integration/targets/template/tasks/test1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
---
- name: setup template
ngine_io.cloudstack.template:
name: "ansible-template-test1"
cross_zones: true
state: absent
register: template
- name: verify setup template
assert:
that:
- template is successful

- name: test download template in check mode
ngine_io.cloudstack.template:
name: "ansible-template-test1"
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
cross_zones: true
register: template
check_mode: true
- name: verify test download template in check mode
assert:
that:
- template is changed

- name: test download template
ngine_io.cloudstack.template:
name: "ansible-template-test1"
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
cross_zones: true
register: template
- name: verify test download template
assert:
that:
- template is changed
- template.name == "ansible-template-test1"
- template.display_text == "ansible-template-test1"
- template.cross_zones == true

- name: test download template idempotence
ngine_io.cloudstack.template:
name: "ansible-template-test1"
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
cross_zones: true
register: template
- name: verify test download template idempotence
assert:
that:
- template is not changed
- template.name == "ansible-template-test1"
- template.display_text == "ansible-template-test1"
- template.cross_zones == true

- name: test update template in check mode
ngine_io.cloudstack.template:
name: "ansible-template-test1"
display_text: "{{ cs_resource_prefix }}-template display_text"
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
is_featured: true
cross_zones: true
register: template
check_mode: true
- name: verify test update template in check mode
assert:
that:
- template is changed
- template.name == "ansible-template-test1"
- template.display_text == "ansible-template-test1"
- template.cross_zones == true
- template.is_featured == false

- name: test update template
ngine_io.cloudstack.template:
name: "ansible-template-test1"
display_text: "{{ cs_resource_prefix }}-template display_text"
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
is_featured: true
cross_zones: true
register: template
- name: verify test update template
assert:
that:
- template is changed
- template.name == "ansible-template-test1"
- template.display_text == cs_resource_prefix + "-template display_text"
- template.cross_zones == true
- template.is_featured == true

- name: test update template idempotence
ngine_io.cloudstack.template:
name: "ansible-template-test1"
display_text: "{{ cs_resource_prefix }}-template display_text"
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
is_featured: true
cross_zones: true
register: template
- name: verify test update template idempotence
assert:
that:
- template is not changed
- template.name == "ansible-template-test1"
- template.display_text == cs_resource_prefix + "-template display_text"
- template.cross_zones == true
- template.is_featured == true

- name: test remove template in check mode
ngine_io.cloudstack.template:
name: "ansible-template-test1"
state: absent
cross_zones: true
register: template
check_mode: true
- name: verify test remove template in check mode
assert:
that:
- template is changed
- template.name == "ansible-template-test1"
- template.display_text == cs_resource_prefix + "-template display_text"
- template.cross_zones == true

- name: test remove template
ngine_io.cloudstack.template:
name: "ansible-template-test1"
state: absent
cross_zones: true
register: template
- name: verify test remove template
assert:
that:
- template is changed
- template.name == "ansible-template-test1"
- template.display_text == cs_resource_prefix + "-template display_text"
- template.cross_zones == true

- name: test remove template idempotence
ngine_io.cloudstack.template:
name: "ansible-template-test1"
state: absent
cross_zones: true
register: template
- name: verify test remove template idempotence
assert:
that:
- template is not changed
181 changes: 181 additions & 0 deletions tests/integration/targets/template/tasks/test2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
- name: setup template first template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: first template
state: absent
cross_zones: yes
template_find_options: display_text
register: template
- name: verify setup template first template
assert:
that:
- template is successful

- name: setup template second template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: second template
state: absent
cross_zones: yes
template_find_options: display_text
register: template
- name: verify setup template second template
assert:
that:
- template is successful

- name: test register first template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: first template
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
cross_zones: yes
template_find_options: display_text
register: template_first
- name: verify test register first template
assert:
that:
- template_first is changed
- template_first.name == "ansible-template-test2"
- template_first.display_text == "first template"
- template_first.cross_zones == true

- name: test register second template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: second template
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
cross_zones: yes
template_find_options: display_text
register: template_second
- name: verify test register second template
assert:
that:
- template_second is changed
- template_second.name == "ansible-template-test2"
- template_second.display_text == "second template"
- template_second.cross_zones == true
- template_second.id != template_first.id

- name: test multiple template same name absent without find options
ngine_io.cloudstack.template:
name: ansible-template-test2
state: absent
cross_zones: yes
register: template
ignore_errors: yes
- name: verify test multiple template same name absent without find options
assert:
that:
- template is failed
- template.msg.startswith('Multiple templates found')

- name: test update second template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: second template
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
is_featured: yes
is_public: yes
cross_zones: yes
template_find_options: display_text
register: template
- name: verify test update second template
assert:
that:
- template is changed
- template.name == "ansible-template-test2"
- template.display_text == "second template"
- template.cross_zones == true
- template.id == template_second.id
- template.is_featured == true
- template.is_public == true

- name: test update second template idempotence
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: second template
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
is_featured: yes
is_public: yes
cross_zones: yes
template_find_options: display_text
register: template
- name: verify test update second template idempotence
assert:
that:
- template is not changed
- template.name == "ansible-template-test2"
- template.display_text == "second template"
- template.cross_zones == true
- template.id == template_second.id
- template.is_featured == true

- name: test update second template idempotence 2
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: second template
url: "{{ cs_template_url }}"
format: "{{ cs_template_format }}"
hypervisor: "{{ cs_template_hypervisor }}"
os_type: "{{ cs_template_os_type }}"
cross_zones: yes
template_find_options: display_text
register: template
- name: verify test update second template idempotence
assert:
that:
- template is not changed
- template.name == "ansible-template-test2"
- template.display_text == "second template"
- template.cross_zones == true
- template.id == template_second.id

- name: test delete first template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: first template
state: absent
cross_zones: yes
template_find_options: display_text
register: template
- name: verify test delete first template
assert:
that:
- template is changed
- template.name == "ansible-template-test2"
- template.display_text == "first template"
- template.cross_zones == true
- template.id == template_first.id
- template.is_featured == false

- name: test delete second template
ngine_io.cloudstack.template:
name: ansible-template-test2
display_text: second template
state: absent
cross_zones: yes
template_find_options: display_text
register: template
- name: verify test delete second template
assert:
that:
- template is changed
- template.name == "ansible-template-test2"
- template.display_text == "second template"
- template.cross_zones == true
- template.id == template_second.id
- template.is_featured == true

0 comments on commit 6b2fe03

Please sign in to comment.