mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-24 04:54:00 -07:00
VMware: Dynamic Inventory plugin (#37456)
* Disable warnings on validate_certs=False * Required requests version * Add testcase for inventory plugin * Include review comments from mattclay * remove pyvmomi installation * remove config file at exit * Add cache in vmware_inventory inventory plugin * shertel review comments * Rename vmware_inventory to vmware_vm_inventory * bcoca's review comments * Export username and password for failing testcase Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
9121f2a4c9
commit
9a561b53fa
6 changed files with 487 additions and 3 deletions
3
test/integration/targets/vmware_vm_inventory/aliases
Normal file
3
test/integration/targets/vmware_vm_inventory/aliases
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
shippable/vcenter/group1
|
||||
cloud/vcenter
|
||||
destructive
|
||||
5
test/integration/targets/vmware_vm_inventory/ansible.cfg
Normal file
5
test/integration/targets/vmware_vm_inventory/ansible.cfg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[defaults]
|
||||
inventory = test-config.vmware.yaml
|
||||
|
||||
[inventory]
|
||||
enable_plugins = vmware_vm_inventory
|
||||
37
test/integration/targets/vmware_vm_inventory/runme.sh
Executable file
37
test/integration/targets/vmware_vm_inventory/runme.sh
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export ANSIBLE_CONFIG=ansible.cfg
|
||||
export vcenter_host="${vcenter_host:-0.0.0.0}"
|
||||
export VMWARE_SERVER="${vcenter_host}"
|
||||
export VMWARE_USERNAME="${VMWARE_USERNAME:-user}"
|
||||
export VMWARE_PASSWORD="${VMWARE_PASSWORD:-pass}"
|
||||
VMWARE_CONFIG=test-config.vmware.yaml
|
||||
|
||||
cat > "$VMWARE_CONFIG" <<VMWARE_YAML
|
||||
plugin: vmware_vm_inventory
|
||||
strict: False
|
||||
validate_certs: False
|
||||
with_tags: False
|
||||
VMWARE_YAML
|
||||
|
||||
trap 'rm -f "${VMWARE_CONFIG}"' INT TERM EXIT
|
||||
|
||||
echo "DEBUG: Using ${vcenter_host} with username ${VMWARE_USERNAME} and password ${VMWARE_PASSWORD}"
|
||||
|
||||
echo "Kill all previous instances"
|
||||
curl "http://${vcenter_host}:5000/killall" > /dev/null 2>&1
|
||||
|
||||
echo "Start new VCSIM server"
|
||||
curl "http://${vcenter_host}:5000/spawn?datacenter=1&cluster=1&folder=0" > /dev/null 2>&1
|
||||
|
||||
echo "Debugging new instances"
|
||||
curl "http://${vcenter_host}:5000/govc_find"
|
||||
|
||||
# Get inventory
|
||||
ansible-inventory -i ${VMWARE_CONFIG} --list
|
||||
# Test playbook with given inventory
|
||||
ansible-playbook -i ${VMWARE_CONFIG} test_vmware_vm_inventory.yml --connection=local "$@"
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Test code for the vmware guest dynamic plugin module
|
||||
# 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)
|
||||
|
||||
---
|
||||
- name: Test VMware Guest Dynamic Inventroy Plugin
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: store the vcenter container ip
|
||||
set_fact:
|
||||
vcsim: "{{ lookup('env', 'vcenter_host') }}"
|
||||
|
||||
- debug:
|
||||
var: vcsim
|
||||
|
||||
- name: Check that there are 'all' and 'otherGuest' groups present in inventory
|
||||
assert:
|
||||
that: "'{{ item }}' in {{ groups.keys() | list }}"
|
||||
with_items:
|
||||
- all
|
||||
- otherGuest
|
||||
Loading…
Add table
Add a link
Reference in a new issue