mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
cs_template: implement update and revamp (#37015)
This commit is contained in:
parent
7f990cfc11
commit
dd953dbe96
8 changed files with 584 additions and 130 deletions
2
test/integration/targets/cs_template/aliases
Normal file
2
test/integration/targets/cs_template/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/cs
|
||||
shippable/cs/group1
|
5
test/integration/targets/cs_template/defaults/main.yml
Normal file
5
test/integration/targets/cs_template/defaults/main.yml
Normal file
|
@ -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
test/integration/targets/cs_template/meta/main.yml
Normal file
3
test/integration/targets/cs_template/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- cs_common
|
3
test/integration/targets/cs_template/tasks/main.yml
Normal file
3
test/integration/targets/cs_template/tasks/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- import_tasks: test1.yml
|
||||
- import_tasks: test2.yml
|
160
test/integration/targets/cs_template/tasks/test1.yml
Normal file
160
test/integration/targets/cs_template/tasks/test1.yml
Normal file
|
@ -0,0 +1,160 @@
|
|||
---
|
||||
- name: setup template
|
||||
cs_template:
|
||||
name: "ansible-template-test1"
|
||||
state: absent
|
||||
register: template
|
||||
- name: verify setup template
|
||||
assert:
|
||||
that:
|
||||
- template is successful
|
||||
|
||||
- name: test download template in check mode
|
||||
cs_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: yes
|
||||
register: template
|
||||
check_mode: yes
|
||||
- name: verify test download template in check mode
|
||||
assert:
|
||||
that:
|
||||
- template is changed
|
||||
|
||||
- name: test download template
|
||||
cs_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: yes
|
||||
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
|
||||
cs_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: yes
|
||||
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
|
||||
cs_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: yes
|
||||
cross_zones: yes
|
||||
register: template
|
||||
check_mode: yes
|
||||
- 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
|
||||
cs_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: yes
|
||||
cross_zones: yes
|
||||
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
|
||||
cs_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: yes
|
||||
cross_zones: yes
|
||||
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
|
||||
cs_template:
|
||||
name: "ansible-template-test1"
|
||||
state: absent
|
||||
cross_zones: yes
|
||||
register: template
|
||||
check_mode: yes
|
||||
- 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
|
||||
cs_template:
|
||||
name: "ansible-template-test1"
|
||||
state: absent
|
||||
cross_zones: yes
|
||||
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
|
||||
cs_template:
|
||||
name: "ansible-template-test1"
|
||||
state: absent
|
||||
cross_zones: yes
|
||||
register: template
|
||||
- name: verify test remove template idempotence
|
||||
assert:
|
||||
that:
|
||||
- template is not changed
|
176
test/integration/targets/cs_template/tasks/test2.yml
Normal file
176
test/integration/targets/cs_template/tasks/test2.yml
Normal file
|
@ -0,0 +1,176 @@
|
|||
---
|
||||
- name: setup template first template
|
||||
cs_template:
|
||||
name: ansible-template-test2
|
||||
display_text: first template
|
||||
state: absent
|
||||
template_find_options: display_text
|
||||
register: template
|
||||
- name: verify setup template first template
|
||||
assert:
|
||||
that:
|
||||
- template is successful
|
||||
|
||||
- name: setup template second template
|
||||
cs_template:
|
||||
name: ansible-template-test2
|
||||
display_text: second template
|
||||
state: absent
|
||||
template_find_options: display_text
|
||||
register: template
|
||||
- name: verify setup template second template
|
||||
assert:
|
||||
that:
|
||||
- template is successful
|
||||
|
||||
- name: test register first template
|
||||
cs_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
|
||||
cs_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
|
||||
cs_template:
|
||||
name: ansible-template-test2
|
||||
state: absent
|
||||
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
|
||||
cs_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
|
||||
cs_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
|
||||
cs_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
|
||||
cs_template:
|
||||
name: ansible-template-test2
|
||||
display_text: first template
|
||||
state: absent
|
||||
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
|
||||
cs_template:
|
||||
name: ansible-template-test2
|
||||
display_text: second template
|
||||
state: absent
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue