community.libvirt
community.libvirt copied to clipboard
Cannot create a transient domain
SUMMARY
Hi, all. I cannot create a transient Libvirt domain from a XML with the create
command (1). As discussed in here, this is not a common behavior using Libvirt tools.
Also the module outputs that it requires 1 argument: "guest" (2). The output is misleading (2.1), the documentation does not provide information about a guest argument, which I believe is the "name" argument. Furthermore, as stated here, I understand that the module tries to find a domain with the same name, but this information, the domain name, is provided by the XML that one uses to create (2.2) and I'm not sure why is it needed in the case of the create command (as it is not necessary for the define). I believe this already works for the define command, that uses conn.defineXML(xml)
, while the create uses find_vm(vmid).create()
instead of conn.createXML(xml)
. From Virt.py:
def create(self, vmid):
return self.find_vm(vmid).create()
def define_from_xml(self, xml):
return self.conn.defineXML(xml)
ISSUE TYPE
- Bug Report
COMPONENT NAME
Virt
ANSIBLE VERSION
ansible 2.9.12
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/local/lib/python2.7/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.17 (default, Jul 20 2020, 15:37:01) [GCC 7.5.0]
CONFIGURATION
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=60s
DEFAULT_BECOME(/etc/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/etc/ansible/ansible.cfg) = sudo
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /etc/ansible/ansible.log
DEFAULT_VAULT_IDENTITY_LIST(/etc/ansible/ansible.cfg) = [u'dev@~/.ansible_secret/vault_pass_insecure']
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/etc/ansible/ansible.cfg) = /usr/bin/python3
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30
RETRY_FILES_ENABLED(env: ANSIBLE_RETRY_FILES_ENABLED) = False
OS / ENVIRONMENT
Target OS: Ubuntu 18.04.5 LTS
STEPS TO REPRODUCE
(1):
name: create a transient Libvirt domain from a XML
virt:
name: domain-name
command: create
xml: “{{ lookup(‘file’, ‘domain.mxl’) }}”
Or better (2):
name: create a transient Libvirt domain from a XML
virt:
command: create
xml: “{{ lookup(‘file’, ‘domain.mxl’) }}”
EXPECTED RESULTS
The domain being created.
ACTUAL RESULTS
For (1), using the name argument:
TASK [creates a transient domain] ************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: VMNotFound: virtual machine domain-name not found
fatal: [hv-1]: FAILED! => {"changed": false, "msg": "virtual machine domain-name not found"}
For (2), not using the name argument:
TASK [creates a transient domain] ************************
fatal: [hv-1]: FAILED! => {"changed": false, "msg": "create requires 1 argument: guest"}
Complementing, I noticed the virsh command (from which the non-idempotent commands defined by the module are similar, presumably) uses:
And, in the Python API bindings, there are the methods:
- create: "boot a previously defined guest domain from its persistent configuration"
- createXML: to "create and immediately boot a new transient guest domain"
Perhaps there is a misconception where:
- module
start
command should use apicreate
- module
create
command should use apicreateXML