-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support to vmware_guest for template => vm conversion #31607
Merged
jctanner
merged 3 commits into
ansible:devel
from
doubleplush:vmware_guest_template_to_vm
Oct 31, 2017
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
test/integration/targets/vmware_guest/tasks/template_d1_c1_f0.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
- 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 with no folders | ||
uri: | ||
url: "http://{{ vcsim }}:5000/spawn?datacenter=1&cluster=1&folder=0" | ||
register: vcsim_instance | ||
|
||
- name: Wait for Flask controller to come up online | ||
wait_for: | ||
host: "{{ vcsim }}" | ||
port: 443 | ||
state: started | ||
|
||
- name: get a list of VMs from vcsim | ||
uri: | ||
url: "http://{{ vcsim }}:5000/govc_find?filter=VM" | ||
register: vmlist | ||
|
||
- debug: var=vcsim_instance | ||
- debug: var=vmlist | ||
|
||
- name: ensure that VMs are not flagged as templates | ||
vmware_guest: | ||
validate_certs: False | ||
hostname: "{{ vcsim }}" | ||
username: "{{ vcsim_instance['json']['username'] }}" | ||
password: "{{ vcsim_instance['json']['password'] }}" | ||
datacenter: "{{ (item|basename).split('_')[0] }}" | ||
folder: "{{ item|dirname }}" | ||
name: "{{ item|basename }}" | ||
state: present | ||
is_template: False | ||
with_items: "{{ vmlist['json'] }}" | ||
register: no_template_initial | ||
|
||
- debug: var=no_template_initial | ||
|
||
- name: ensure no changes were made | ||
assert: | ||
that: | ||
- "no_template_initial.results|map(attribute='changed')|unique|list == [False]" | ||
|
||
- name: convert all VMs to templates | ||
vmware_guest: | ||
validate_certs: False | ||
hostname: "{{ vcsim }}" | ||
username: "{{ vcsim_instance['json']['username'] }}" | ||
password: "{{ vcsim_instance['json']['password'] }}" | ||
datacenter: "{{ (item|basename).split('_')[0] }}" | ||
folder: "{{ item|dirname }}" | ||
name: "{{ item|basename }}" | ||
state: present | ||
is_template: True | ||
with_items: "{{ vmlist['json'] }}" | ||
register: convert_to_template | ||
|
||
- debug: var=convert_to_template | ||
|
||
- name: ensure that changes were made | ||
assert: | ||
that: | ||
- "convert_to_template.results|map(attribute='changed')|unique|list == [True]" | ||
|
||
- name: make double sure that all VMs are templates | ||
vmware_guest: | ||
validate_certs: False | ||
hostname: "{{ vcsim }}" | ||
username: "{{ vcsim_instance['json']['username'] }}" | ||
password: "{{ vcsim_instance['json']['password'] }}" | ||
datacenter: "{{ (item|basename).split('_')[0] }}" | ||
folder: "{{ item|dirname }}" | ||
name: "{{ item|basename }}" | ||
state: present | ||
is_template: True | ||
with_items: "{{ vmlist['json'] }}" | ||
register: still_templates | ||
|
||
- debug: var=still_templates | ||
|
||
- name: ensure that no changes were made | ||
assert: | ||
that: | ||
- "still_templates.results|map(attribute='changed')|unique|list == [False]" | ||
|
||
- name: convert all templates back to VMs | ||
vmware_guest: | ||
validate_certs: False | ||
hostname: "{{ vcsim }}" | ||
username: "{{ vcsim_instance['json']['username'] }}" | ||
password: "{{ vcsim_instance['json']['password'] }}" | ||
datacenter: "{{ (item|basename).split('_')[0] }}" | ||
folder: "{{ item|dirname }}" | ||
name: "{{ item|basename }}" | ||
state: present | ||
is_template: False | ||
with_items: "{{ vmlist['json'] }}" | ||
register: revert_to_vm | ||
|
||
- debug: var=revert_to_vm | ||
|
||
- name: ensure that changes were made | ||
assert: | ||
that: | ||
- "revert_to_vm.results|map(attribute='changed')|unique|list == [True]" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add one more test where all VMs are "again" converted to template to ensure idempotency of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull has been updated with new idempotency test.