Skip to content

Commit

Permalink
add instance_password_reset
Browse files Browse the repository at this point in the history
  • Loading branch information
resmo committed Nov 27, 2024
1 parent 6b2fe03 commit 36d77cb
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/instance_password_reset/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cloud/cs
cs/group1
cs/group4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
dependencies:
- cs_common
105 changes: 105 additions & 0 deletions tests/integration/targets/instance_password_reset/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
- name: reset without giving a VM or Zone
ngine_io.cloudstack.instance_password_reset:
ignore_errors: true
register: reset1
- name: verify that the argument was missing
assert:
that:
- reset1 is failed
- "reset1.msg == 'missing required arguments: vm, zone'"

- name: reset without giving a VM
ngine_io.cloudstack.instance_password_reset:
zone: "{{ cs_common_zone_basic }}"
ignore_errors: true
register: reset1
- name: verify that the argument was missing
assert:
that:
- reset1 is failed
- "reset1.msg == 'missing required arguments: vm'"

- name: disable password_enabled on default template
ngine_io.cloudstack.template:
name: "{{ cs_common_template }}"
template_filter: all
password_enabled: false
zone: "{{ cs_common_zone_basic }}"

- name: cleanup test VM
ngine_io.cloudstack.instance:
name: test-nopassword
zone: "{{ cs_common_zone_basic }}"
state: expunged

- name: create test VM
ngine_io.cloudstack.instance:
name: test-nopassword
template: "{{ cs_common_template }}"
service_offering: "{{ cs_common_service_offering }}"
zone: "{{ cs_common_zone_basic }}"
state: started
register: testvm_nopass
until: testvm_nopass is success
retries: 12
delay: 10

- name: stop test VM
ngine_io.cloudstack.instance:
name: test-nopassword
zone: "{{ cs_common_zone_basic }}"
state: stopped

- name: reset nopassword
ngine_io.cloudstack.instance_password_reset:
vm: test-nopassword
zone: "{{ cs_common_zone_basic }}"
ignore_errors: true
register: reset2
- name: verify that template was not pw enabled
assert:
that:
- reset2 is failed
- reset2.msg.endswith("the template is not password enabled'")

- name: enable password_enabled on default template
ngine_io.cloudstack.template:
name: "{{ cs_common_template }}"
template_filter: all
password_enabled: true
zone: "{{ cs_common_zone_basic }}"

- name: cleanup test VM
ngine_io.cloudstack.instance:
name: test-password
zone: "{{ cs_common_zone_basic }}"
state: expunged

- name: create test VM
ngine_io.cloudstack.instance:
name: test-password
template: "{{ cs_common_template }}"
service_offering: "{{ cs_common_service_offering }}"
zone: "{{ cs_common_zone_basic }}"
state: started

- name: stop test VM
ngine_io.cloudstack.instance:
name: test-password
zone: "{{ cs_common_zone_basic }}"
state: stopped

- name: reset password
ngine_io.cloudstack.instance_password_reset:
vm: test-password
zone: "{{ cs_common_zone_basic }}"
register: reset3
- name: verify that a password was set
assert:
that:
- reset3 is success
- reset3.password != ''

- debug:
var: reset3.password

0 comments on commit 36d77cb

Please sign in to comment.