Hi Martin
thanks for your information.
but when i try on one of my testlab RHV 4.3 farm, ansible 2.9 complain that
ovirt_vm_facts not found, detail refer to below command output
based on RHV 4.3 ansible version as below:
# ansible --version
ansible 2.9.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules',
u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat
4.8.5-39)]
# ansible-doc --list | egrep -i ovirt_vm --> not showing ovirt_vm_facts module
[WARNING]: win_template parsing did not produce documentation.
[WARNING]: template parsing did not produce documentation.
ovirt_vm_info Retrieve information about
one or more oVirt/RHV virtual machines
ovirt_vmpool Module to manage VM pools in
oVirt/RHV
ovirt_vmpool_info Retrieve information about
one or more oVirt/RHV vmpools
ovirt_vm Module to manage Virtual
Machines in oVirt/RHV
[root@rhvm100 ~]#
#### use ovirt_vms_facts module
# cat list_vms01.yml
- hosts: localhost
connection: local
vars_files:
- engine_vars.yml
- password.yml
tasks:
- name: Obtain SSO token
ovirt_auth:
url: "{{ engine_url }}"
username: "{{ engine_user }}"
password: "{{ engine_password }}"
ca_file: "{{ engine_cafile | default(omit) }}"
# insecure: "{{ engine_insecure }}"
- name: List vms
ovirt_vms_facts:
fetch_nested: true
nested_attributes:
- description
auth: "{{ ovirt_auth }}"
- name: set vms
set_fact:
vm: "{{ item.name }}: {{ item.snapshots | map(attribute='description')
| join(',') }}"
with_items: "{{ ovirt_vms }}"
loop_control:
label: "{{ item.name }}"
register: all_vms
- name: make a list
set_fact: vms="{{ all_vms.results | map(attribute='ansible_facts.vm') |
list }}"
- name: Print vms
debug:
var: vms
# ansible-playbook list_vms01.yml --syntax-check
[WARNING]: provided hosts list is empty, only localhost is available. Note that the
implicit localhost does not match 'all'
ERROR! couldn't resolve module/action 'ovirt_vms_facts'. This often indicates
a misspelling, missing collection, or incorrect module path.
The error appears to be in '/root/rhv_ansible/list_vms01.yml': line 16, column 5,
but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: List vms
^ here
thanks