-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e89fe3e
commit fdaa257
Showing
5 changed files
with
58 additions
and
9 deletions.
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
1 change: 1 addition & 0 deletions
1
tests/integration/targets/vmware_inventory_esxi_hosts/defaults/main.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 @@ | ||
run_on_simulator: false |
6 changes: 6 additions & 0 deletions
6
tests/integration/targets/vmware_inventory_esxi_hosts/files/test.esxi_hosts.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,6 @@ | ||
--- | ||
plugin: vmware.vmware.esxi_hosts | ||
cache: false | ||
group_by_paths: true | ||
group_by_paths_prefix: test | ||
gather_tags: true |
13 changes: 13 additions & 0 deletions
13
tests/integration/targets/vmware_inventory_esxi_hosts/run.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,13 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
tasks: | ||
- name: Import eco-vcenter credentials | ||
ansible.builtin.include_vars: | ||
file: ../../integration_config.yml | ||
tags: eco-vcenter-ci | ||
|
||
- name: Call esxi_hosts inventory role | ||
ansible.builtin.import_role: | ||
name: vmware_inventory_esxi_hosts | ||
tags: | ||
- eco-vcenter-ci |
29 changes: 29 additions & 0 deletions
29
tests/integration/targets/vmware_inventory_esxi_hosts/tasks/main.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,29 @@ | ||
--- | ||
- block: | ||
- name: Import common vars | ||
ansible.builtin.include_vars: | ||
file: ../group_vars.yml | ||
|
||
- name: Run Inventory Plugin | ||
ansible.builtin.command: ansible-inventory -i "{{ role_path }}/files/test.esxi_hosts.yml" --list | ||
register: _inventory_out | ||
|
||
- name: Parse Inventory Results as JSON | ||
ansible.builtin.set_fact: | ||
inventory_results: "{{ _inventory_out.stdout | from_json }}" | ||
|
||
# you can't reference the 'all' property here for some reason. It reverts back to the test playbook inventory | ||
# instead of the inventory_results | ||
- name: Check Output | ||
ansible.builtin.assert: | ||
that: | ||
- first_host.ansible_host | ||
- first_host.tags is defined | ||
- first_host.tags_by_category is defined | ||
- >- | ||
(inventory_results.poweredOn.hosts | length) == | ||
(inventory_results._meta.hostvars.values() | selectattr('summary.runtime.powerState', 'equalto', 'poweredOn') | length) | ||
- (inventory_results | length) > 3 | ||
- ('test_' + vcenter_datacenter | replace('-', '_')) in inventory_results.keys() | ||
vars: | ||
first_host: "{{ (inventory_results._meta.hostvars.values() | first) }}" |