vmware: refactoring of the vcenter_* test roles

Refactoring of `vcenter_folder` and `vcenter_license` to make use of the
new `prepare_vmware_tests` role.

This patch depends on: https://github.com/ansible/ansible/pull/55719

Original PR: https://github.com/ansible/ansible/pull/54882
pull/56068/head
Gonéri Le Bouder 6 years ago
parent affaedfca8
commit 541d73d82a

@ -0,0 +1,2 @@
dependencies:
- prepare_vmware_tests

@ -2,44 +2,11 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com> # Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for Flask controller to come up online
wait_for:
host: "{{ vcsim }}"
port: 5000
state: started
- name: kill vcsim
uri:
url: http://{{ vcsim }}:5000/killall
- name: start vcsim
uri:
url: http://{{ vcsim }}:5000/spawn?cluster=2
register: vcsim_instance
- debug:
var: vcsim_instance
- name: Wait for vcsim server to come up online
wait_for:
host: "{{ vcsim }}"
port: 443
state: started
- name: get datacenter
uri:
url: http://{{ vcsim }}:5000/govc_find?filter=DC
register: datacenters
- name: get a datacenter
set_fact:
dc1: "{{ datacenters.json[0] | basename }}"
- name: Create all types of folder in check mode - name: Create all types of folder in check mode
vcenter_folder: vcenter_folder:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ dc1 }}" datacenter: "{{ dc1 }}"
folder_name: "{{ item }}_folder" folder_name: "{{ item }}_folder"
@ -53,7 +20,8 @@
- network - network
check_mode: yes check_mode: yes
- debug: msg="{{ all_folder_results }}" - debug:
msg: "{{ all_folder_results }}"
- name: ensure everything for {{ dc1 }} - name: ensure everything for {{ dc1 }}
assert: assert:
@ -62,9 +30,9 @@
- name: Create all types of folder - name: Create all types of folder
vcenter_folder: vcenter_folder:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ dc1 }}" datacenter: "{{ dc1 }}"
folder_name: "{{ item }}_folder" folder_name: "{{ item }}_folder"
@ -77,7 +45,8 @@
- datastore - datastore
- network - network
- debug: msg="{{ all_folder_results }}" - debug:
msg: "{{ all_folder_results }}"
- name: ensure everything for {{ dc1 }} - name: ensure everything for {{ dc1 }}
assert: assert:
@ -86,9 +55,9 @@
- name: Create all types of sub folder in check mode - name: Create all types of sub folder in check mode
vcenter_folder: vcenter_folder:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ dc1 }}" datacenter: "{{ dc1 }}"
folder_name: "sub_{{ item }}_folder" folder_name: "sub_{{ item }}_folder"
@ -102,7 +71,8 @@
- network - network
check_mode: yes check_mode: yes
- debug: msg="{{ all_folder_results }}" - debug:
msg: "{{ all_folder_results }}"
- name: ensure everything for {{ dc1 }} - name: ensure everything for {{ dc1 }}
assert: assert:
@ -111,9 +81,9 @@
- name: Create all types of sub folder - name: Create all types of sub folder
vcenter_folder: vcenter_folder:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ dc1 }}" datacenter: "{{ dc1 }}"
folder_name: "sub_{{ item }}_folder" folder_name: "sub_{{ item }}_folder"
@ -128,9 +98,9 @@
- name: Recreate all types of sub folder - name: Recreate all types of sub folder
vcenter_folder: vcenter_folder:
hostname: "{{ vcsim }}" hostname: "{{ vcenter_hostname }}"
username: "{{ vcsim_instance.json.username }}" username: "{{ vcenter_username }}"
password: "{{ vcsim_instance.json.password }}" password: "{{ vcenter_password }}"
validate_certs: no validate_certs: no
datacenter: "{{ dc1 }}" datacenter: "{{ dc1 }}"
folder_name: "sub_{{ item }}_folder" folder_name: "sub_{{ item }}_folder"
@ -143,7 +113,8 @@
- datastore - datastore
- network - network
- debug: msg="{{ all_folder_results }}" - debug:
msg: "{{ all_folder_results }}"
- name: ensure everything for {{ dc1 }} - name: ensure everything for {{ dc1 }}
assert: assert:
@ -151,54 +122,55 @@
- all_folder_results.changed - all_folder_results.changed
- not recreate_folders.changed - not recreate_folders.changed
## Testcase: Delete Delete all types of folder ## Testcase: Delete all types of folder
# #
# Doesn't work with vcsim. Looks like UnregisterAndDestroy isn't supported. # Doesn't work with vcsim. Looks like UnregisterAndDestroy isn't supported.
# - when: vcsim is not defined
# - name: Delete all types of folder block:
# vcenter_folder: - name: Delete all types of folder
# hostname: "{{ vcsim }}" vcenter_folder:
# username: "{{ vcsim_instance.json.username }}" hostname: "{{ vcenter_hostname }}"
# password: "{{ vcsim_instance.json.password }}" username: "{{ vcenter_username }}"
# validate_certs: no password: "{{ vcenter_password }}"
# datacenter: "{{ dc1 }}" validate_certs: no
# folder_name: "{{ item }}_folder" datacenter: "{{ dc1 }}"
# folder_type: "{{ item }}" folder_name: "{{ item }}_folder"
# state: absent folder_type: "{{ item }}"
# register: all_folder_results state: absent
# with_items: register: all_folder_results
# - vm with_items:
# - host - vm
# - datastore - host
# - network - datastore
# - network
# - debug: msg="{{ all_folder_results }}"
# - debug: msg="{{ all_folder_results }}"
# - name: ensure everything for {{ dc1 }}
# assert: - name: ensure everything for {{ dc1 }}
# that: assert:
# - all_folder_results.changed that:
# - all_folder_results.changed
# - name: Delete all types of folder again
# vcenter_folder: - name: Delete all types of folder again
# hostname: "{{ vcsim }}" vcenter_folder:
# username: "{{ vcsim_instance.json.username }}" hostname: "{{ vcenter_hostname }}"
# password: "{{ vcsim_instance.json.password }}" username: "{{ vcenter_username }}"
# validate_certs: no password: "{{ vcenter_password }}"
# datacenter: "{{ dc1 }}" validate_certs: no
# folder_name: "{{ item }}_folder" datacenter: "{{ dc1 }}"
# folder_type: "{{ item }}" folder_name: "{{ item }}_folder"
# state: absent folder_type: "{{ item }}"
# register: all_folder_results state: absent
# with_items: register: all_folder_results
# - vm with_items:
# - host - vm
# - datastore - host
# - network - datastore
# - network
# - debug: msg="{{ all_folder_results }}"
# - debug: msg="{{ all_folder_results }}"
# - name: ensure everything for {{ dc1 }}
# assert: - name: ensure everything for {{ dc1 }}
# that: assert:
# - not all_folder_results.changed that:
- not all_folder_results.changed

@ -0,0 +1,2 @@
dependencies:
- prepare_vmware_tests

@ -2,55 +2,26 @@
# Copyright: (c) 2017, Dag Wieers <dag@wieers.com> # Copyright: (c) 2017, Dag Wieers <dag@wieers.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Wait for vcsim controller to come online {{ vcsim }} - when: vcsim is not defined
wait_for: block:
host: "{{ vcsim }}" - name: Add a vCenter evaluation license
port: 5000 vcenter_license: &vcenter_lic_data
state: started hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
- name: Kill vcsim password: "{{ vcenter_password }}"
uri: validate_certs: no
url: http://{{ vcsim }}:5000/killall license: 00000-00000-00000-00000-00000
state: present
- name: Start vcsim
uri: - name: Remove an (unused) vCenter evaluation license
url: http://{{ vcsim }}:5000/spawn?cluster=2 vcenter_license:
register: vcsim_instance <<: *vcenter_lic_data
state: absent
- name: Wait for vcsim server to come up online {{ vcsim }}
wait_for: - name: Add an invalid vCenter license
host: "{{ vcsim }}" vcenter_license:
port: 443 <<: *vcenter_lic_data
state: started license: 00000-00000-00000-00000-00001
state: present
- debug: register: vcenter_license_output
var: vcsim_instance failed_when: '"is not existing or can not be added" not in vcenter_license_output.msg'
# FIXME: ServerFaultCode: LicenseManager:LicenseManager does not implement: AddLicense
#- name: Add a vCenter evaluation license
# vcenter_license:
# hostname: '{{ vcsim }}'
# username: '{{ vcsim_instance["json"]["username"] }}'
# password: '{{ vcsim_instance["json"]["password"] }}'
# validate_certs: no
# license: 00000-00000-00000-00000-00000
# state: present
#- name: Remove an (unused) vCenter evaluation license
# vcenter_license:
# hostname: '{{ vcsim }}'
# username: '{{ vcsim_instance["json"]["username"] }}'
# password: '{{ vcsim_instance["json"]["password"] }}'
# validate_certs: no
# license: 00000-00000-00000-00000-00000
# state: absent
#- name: Add an invalid vCenter license
# vcenter_license:
# hostname: '{{ vcsim }}'
# username: '{{ vcsim_instance["json"]["username"] }}'
# password: '{{ vcsim_instance["json"]["password"] }}'
# validate_certs: no
# license: 00000-00000-00000-00000-00001
# state: present
# ignore_errors: yes

Loading…
Cancel
Save