List VMS with ansible version 2.9 ovirt_vms_info module

Hi All is someone use ansible to list guest vm and ovirt node on ansible 2.9 with ovirt_vms_info ? i read this https://lists.ovirt.org/pipermail/users/2017-May/081956.html but this is for ansible 2.8 and below with ovirt_vms_facts module. i new to ansible, hope someone manage to provide some sample playbook to start list vm on ovirt

On Thu, Dec 19, 2019 at 7:22 AM <csyeow@gmail.com> wrote:
Hi All
is someone use ansible to list guest vm and ovirt node on ansible 2.9 with ovirt_vms_info ? i read this https://lists.ovirt.org/pipermail/users/2017-May/081956.html but this is for ansible 2.8 and below with ovirt_vms_facts module.
ovirt_vm_facts was just recently removed to ovirt_vm_info, but their functionality is the same. From Ansible 2.9 both modules names works, but ovirt_vm_facts is deprecated and it should be removed in 2.12 AFAIR. More information about the module can be found in docs: https://docs.ansible.com/ansible/latest/modules/ovirt_vm_info_module.html#ov...
i new to ansible, hope someone manage to provide some sample playbook to start list vm on ovirt _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/M54DXWXTALU6EZ...
-- Martin Perina Manager, Software Engineering Red Hat Czech s.r.o.

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

Hello, I think it's just a typo. Try renaming "ovirt_vms_facts" to "ovirt_vm_facts". This worked for me: - hosts: localhost gather_facts: no tasks: - name: Login to oVirt ovirt_auth: url: https://<engine_fqdn>/ovirt-engine/api username: admin@internal password: <pass> insecure: yes - name: Gather info on all the virtual machines ovirt_vm_facts: auth: "{{ ovirt_auth }}" pattern: "cluster=Default" # Get VMs from cluster "Default" - name: Print the gathered info debug: var: ovirt_vms Or better yet, use directly "ovirt_vm_info" like this. Note that when using "ovirt_vm_info", you need to *register* the output in a variable. - hosts: localhost gather_facts: no tasks: - name: Login to oVirt ovirt_auth: url: https://<engine_fqdn>/ovirt-engine/api username: admin@internal password: <pass> insecure: yes - name: Gather info on all the virtual machines ovirt_vm_info: auth: "{{ ovirt_auth }}" pattern: "cluster=Default" # Get VMs from cluster "Default" register: vms - name: Print the gathered info debug: var: vms.ovirt_vms I believe that not being able to see documentation for "ovirt_vm_facts" in *ansible-doc* command is an intention. Best regards Jan On Thu, Dec 19, 2019 at 9:37 AM <csyeow@gmail.com> wrote:
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 _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/TUTNDLLOMOWX6R...
-- Jan Zmeskal Quality Engineer, RHV Core System Red Hat <https://www.redhat.com> <https://www.redhat.com>

Hi Jan Zmeskal thanks for assist. i manage to list guest vm name and snapshot name after renaming "ovirt_vms_facts" to "ovirt_vm_facts" the test results as below: TASK [Print vms] ************************************************************************************************************************************ ok: [localhost] => { "vms": [ "master0.ipa.internal: Active VM", "metrics-store-installer: Active VM", "testserver01: test_snapshot_28_08_2019,Active VM", "v2vtest-manual: Active VM" ] } PLAY RECAP ****************************************************************************************************************************************** localhost : ok=6 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

On Thu, 19 Dec 2019, 09:37 , <csyeow@gmail.com> wrote:
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:
Shouldn't there be ovirt_vm_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 _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/TUTNDLLOMOWX6R...
participants (3)
-
csyeow@gmail.com
-
Jan Zmeskal
-
Martin Perina