summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/libvirt
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/community/libvirt')
-rw-r--r--ansible_collections/community/libvirt/.azure-pipelines/README.md3
-rw-r--r--ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml382
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/aggregate-coverage.sh15
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/combine-coverage.py60
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/process-results.sh24
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/publish-codecov.sh27
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/report-coverage.sh10
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/run-tests.sh34
-rwxr-xr-xansible_collections/community/libvirt/.azure-pipelines/scripts/time-command.py25
-rw-r--r--ansible_collections/community/libvirt/.azure-pipelines/templates/coverage.yml39
-rw-r--r--ansible_collections/community/libvirt/.azure-pipelines/templates/matrix.yml55
-rw-r--r--ansible_collections/community/libvirt/.azure-pipelines/templates/test.yml45
-rw-r--r--ansible_collections/community/libvirt/.gitignore9
-rw-r--r--ansible_collections/community/libvirt/CHANGELOG.rst80
-rw-r--r--ansible_collections/community/libvirt/CONTRIBUTING.md3
-rw-r--r--ansible_collections/community/libvirt/COPYING674
-rw-r--r--ansible_collections/community/libvirt/FILES.json992
-rw-r--r--ansible_collections/community/libvirt/MAINTAINERS3
-rw-r--r--ansible_collections/community/libvirt/MAINTAINING.md3
-rw-r--r--ansible_collections/community/libvirt/MANIFEST.json33
-rw-r--r--ansible_collections/community/libvirt/README.md155
-rw-r--r--ansible_collections/community/libvirt/REVIEW_CHECKLIST.md3
-rw-r--r--ansible_collections/community/libvirt/changelogs/changelog.yaml85
-rw-r--r--ansible_collections/community/libvirt/changelogs/config.yaml31
-rw-r--r--ansible_collections/community/libvirt/meta/runtime.yml2
-rw-r--r--ansible_collections/community/libvirt/plugins/connection/libvirt_lxc.py183
-rw-r--r--ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py361
-rw-r--r--ansible_collections/community/libvirt/plugins/doc_fragments/__init__.py0
-rw-r--r--ansible_collections/community/libvirt/plugins/doc_fragments/requirements.py14
-rw-r--r--ansible_collections/community/libvirt/plugins/doc_fragments/virt.py67
-rw-r--r--ansible_collections/community/libvirt/plugins/inventory/__init__.py0
-rw-r--r--ansible_collections/community/libvirt/plugins/inventory/libvirt.py212
-rw-r--r--ansible_collections/community/libvirt/plugins/modules/virt.py563
-rw-r--r--ansible_collections/community/libvirt/plugins/modules/virt_net.py647
-rw-r--r--ansible_collections/community/libvirt/plugins/modules/virt_pool.py707
-rw-r--r--ansible_collections/community/libvirt/shippable.yml53
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/aliases1
-rwxr-xr-xansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/runme.sh18
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/test_connection.inventory6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/aliases1
-rwxr-xr-xansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/runme.sh18
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/test_connection.inventory6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/aliases1
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_lxc.yml2
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_qemu.yml2
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/playbooks/test-inventory.yml7
-rwxr-xr-xansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/runme.sh13
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/aliases6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/files/foobar.xml9
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/tasks/main.yml90
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Debian.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Fedora-29.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-7.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-8.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-9.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-16.04.yml5
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.04.yml5
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.10.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/default.yml5
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/aliases6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/defaults/main.yml4
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/directory_based_pool.yml139
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/main.yml31
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/templates/test_pool.xml.j211
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-7.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-8.yml8
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Debian.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Fedora-34.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-7.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-8.yml9
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-9.yml9
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.04.yml5
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.10.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-20.04.yml6
-rw-r--r--ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/default.yml5
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt10
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt10
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.12.txt2
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.13.txt2
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.14.txt2
-rw-r--r--ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt10
-rw-r--r--ansible_collections/community/libvirt/tests/unit/compat/__init__.py0
-rw-r--r--ansible_collections/community/libvirt/tests/unit/compat/builtins.py33
-rw-r--r--ansible_collections/community/libvirt/tests/unit/compat/mock.py122
-rw-r--r--ansible_collections/community/libvirt/tests/unit/compat/unittest.py38
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/__init__.py0
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/loader.py116
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/path.py5
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/procenv.py90
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/vault_helper.py39
-rw-r--r--ansible_collections/community/libvirt/tests/unit/mock/yaml_helper.py121
-rw-r--r--ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/__init__.py0
-rw-r--r--ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/conftest.py69
-rw-r--r--ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/test_virt_net.py30
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py122
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/cloud.sh19
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/freebsd.sh22
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/linux.sh18
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/osx.sh22
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/remote.sh22
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/rhel.sh22
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/sanity.sh7
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/shippable.sh206
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/timing.py16
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/timing.sh5
-rwxr-xr-xansible_collections/community/libvirt/tests/utils/shippable/units.sh14
106 files changed, 7287 insertions, 0 deletions
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/README.md b/ansible_collections/community/libvirt/.azure-pipelines/README.md
new file mode 100644
index 000000000..385e70bac
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/README.md
@@ -0,0 +1,3 @@
+## Azure Pipelines Configuration
+
+Please see the [Documentation](https://github.com/ansible/community/wiki/Testing:-Azure-Pipelines) for more information.
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml b/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml
new file mode 100644
index 000000000..f6912428a
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/azure-pipelines.yml
@@ -0,0 +1,382 @@
+trigger:
+ batch: true
+ branches:
+ include:
+ - main
+ - stable-*
+
+pr:
+ autoCancel: true
+ branches:
+ include:
+ - main
+ - stable-*
+
+schedules:
+ - cron: 0 9 * * *
+ displayName: Nightly
+ always: true
+ branches:
+ include:
+ - main
+ - stable-*
+
+variables:
+ - name: checkoutPath
+ value: ansible_collections/community/libvirt
+ - name: coverageBranches
+ value: main
+ - name: pipelinesCoverage
+ value: coverage
+ - name: entryPoint
+ value: tests/utils/shippable/shippable.sh
+ - name: fetchDepth
+ value: 0
+
+resources:
+ containers:
+ - container: default
+ image: quay.io/ansible/azure-pipelines-test-container:3.0.0
+
+pool: Standard
+
+stages:
+### Sanity & units
+ - stage: Ansible_devel
+ displayName: Sanity & Units devel
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ targets:
+ - name: Sanity
+ test: 'devel/sanity/1'
+# - name: Sanity Extra # Only on devel
+# test: 'devel/sanity/extra'
+ - name: Units
+ test: 'devel/units/1'
+
+ - stage: Ansible_2_13
+ displayName: Sanity & Units 2.13
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ targets:
+ - name: Sanity
+ test: '2.13/sanity/1'
+ - name: Units
+ test: '2.13/units/1'
+
+ - stage: Ansible_2_12
+ displayName: Sanity & Units 2.12
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ targets:
+ - name: Sanity
+ test: '2.12/sanity/1'
+ - name: Units
+ test: '2.12/units/1'
+
+ - stage: Ansible_2_11
+ displayName: Sanity & Units 2.11
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ targets:
+ - name: Sanity
+ test: '2.11/sanity/1'
+ - name: Units
+ test: '2.11/units/1'
+
+ - stage: Ansible_2_10
+ displayName: Sanity & Units 2.10
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ targets:
+ - name: Sanity
+ test: '2.10/sanity/1'
+ - name: Units
+ test: '2.10/units/1'
+
+ - stage: Ansible_2_9
+ displayName: Sanity & Units 2.9
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ targets:
+ - name: Sanity
+ test: '2.9/sanity/1'
+ - name: Units
+ test: '2.9/units/1'
+### Docker
+ - stage: Docker_devel
+ displayName: Docker devel
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: devel/linux/{0}/1
+ targets:
+ - name: CentOS 7
+ test: centos7
+ - name: Fedora 35
+ test: fedora35
+ - name: Fedora 36
+ test: fedora36
+ - name: openSUSE 15 py3
+ test: opensuse15
+ - name: Ubuntu 20.04
+ test: ubuntu2004
+ - name: Ubuntu 22.04
+ test: ubuntu2204
+
+ - stage: Docker_2_13
+ displayName: Docker 2.13
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: 2.13/linux/{0}/1
+ targets:
+ - name: CentOS 7
+ test: centos7
+ - name: Fedora 34
+ test: fedora34
+ - name: openSUSE 15 py2
+ test: opensuse15py2
+ - name: openSUSE 15 py3
+ test: opensuse15
+ - name: Ubuntu 18.04
+ test: ubuntu1804
+ - name: Ubuntu 20.04
+ test: ubuntu2004
+
+ - stage: Docker_2_12
+ displayName: Docker 2.12
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: 2.12/linux/{0}/1
+ targets:
+ - name: CentOS 7
+ test: centos7
+ - name: Fedora 33
+ test: fedora33
+ - name: Fedora 34
+ test: fedora34
+ - name: openSUSE 15 py2
+ test: opensuse15py2
+ - name: openSUSE 15 py3
+ test: opensuse15
+ - name: Ubuntu 18.04
+ test: ubuntu1804
+ - name: Ubuntu 20.04
+ test: ubuntu2004
+
+ - stage: Docker_2_11
+ displayName: Docker 2.11
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: 2.11/linux/{0}/1
+ targets:
+ - name: CentOS 6
+ test: centos6
+ - name: CentOS 7
+ test: centos7
+ - name: Fedora 32
+ test: fedora32
+ - name: Fedora 33
+ test: fedora33
+ - name: openSUSE 15 py2
+ test: opensuse15py2
+ - name: openSUSE 15 py3
+ test: opensuse15
+ - name: Ubuntu 18.04
+ test: ubuntu1804
+ - name: Ubuntu 20.04
+ test: ubuntu2004
+
+ - stage: Docker_2_10
+ displayName: Docker 2.10
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: 2.10/linux/{0}/1
+ targets:
+ - name: CentOS 6
+ test: centos6
+ - name: CentOS 7
+ test: centos7
+ - name: Fedora 31
+ test: fedora31
+ - name: Fedora 32
+ test: fedora32
+ - name: openSUSE 15 py2
+ test: opensuse15py2
+ - name: openSUSE 15 py3
+ test: opensuse15
+ - name: Ubuntu 16.04
+ test: ubuntu1604
+ - name: Ubuntu 18.04
+ test: ubuntu1804
+
+ - stage: Docker_2_9
+ displayName: Docker 2.9
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: 2.9/linux/{0}/1
+ targets:
+ - name: CentOS 6
+ test: centos6
+ - name: CentOS 7
+ test: centos7
+ - name: Fedora 31
+ test: fedora31
+ - name: Fedora 32
+ test: fedora32
+ - name: openSUSE 15 py2
+ test: opensuse15py2
+ - name: openSUSE 15 py3
+ test: opensuse15
+ - name: Ubuntu 16.04
+ test: ubuntu1604
+ - name: Ubuntu 18.04
+ test: ubuntu1804
+
+### Remote
+ - stage: Remote_devel
+ displayName: Remote devel
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: 'devel/{0}/1'
+ targets:
+ - name: RHEL 7.9
+ test: rhel/7.9
+ - name: RHEL 8.6
+ test: rhel/8.6
+ - name: RHEL 9.0
+ test: rhel/9.0
+ - name: FreeBSD 12.3
+ test: freebsd/12.3
+ - name: FreeBSD 13.1
+ test: freebsd/13.1
+
+ - stage: Remote_2_13
+ displayName: Remote 2.13
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.13/{0}/1'
+ targets:
+ - name: RHEL 8.5
+ test: rhel/8.5
+ - name: FreeBSD 13.0
+ test: freebsd/13.0
+
+ - stage: Remote_2_12
+ displayName: Remote 2.12
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.12/{0}/1'
+ targets:
+ - name: RHEL 7.9
+ test: rhel/7.9
+ - name: RHEL 8.4
+ test: rhel/8.4
+ - name: FreeBSD 12.2
+ test: freebsd/12.2
+ - name: FreeBSD 13.0
+ test: freebsd/13.0
+
+ - stage: Remote_2_11
+ displayName: Remote 2.11
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.11/{0}/1'
+ targets:
+ - name: RHEL 7.9
+ test: rhel/7.9
+ - name: RHEL 8.3
+ test: rhel/8.3
+ - name: FreeBSD 11.4
+ test: freebsd/11.4
+ - name: FreeBSD 12.2
+ test: freebsd/12.2
+
+ - stage: Remote_2_10
+ displayName: Remote 2.10
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.10/{0}/1'
+ targets:
+ - name: RHEL 7.8
+ test: rhel/7.8
+ - name: RHEL 8.2
+ test: rhel/8.2
+ - name: FreeBSD 11.1
+ test: freebsd/11.1
+ - name: FreeBSD 12.1
+ test: freebsd/12.1
+
+ - stage: Remote_2_9
+ displayName: Remote 2.9
+ dependsOn: []
+ jobs:
+ - template: templates/matrix.yml
+ parameters:
+ testFormat: '2.9/{0}/1'
+ targets:
+ - name: RHEL 7.8
+ test: rhel/7.8
+ - name: RHEL 8.2
+ test: rhel/8.2
+ - name: FreeBSD 11.1
+ test: freebsd/11.1
+ - name: FreeBSD 12.1
+ test: freebsd/12.1
+
+ - stage: Summary
+ condition: succeededOrFailed()
+ dependsOn:
+ - Ansible_devel
+ - Ansible_2_13
+ - Ansible_2_12
+ - Ansible_2_11
+ - Ansible_2_10
+ - Ansible_2_9
+ - Docker_devel
+ - Docker_2_13
+ - Docker_2_12
+ - Docker_2_11
+ - Docker_2_10
+ - Docker_2_9
+ - Remote_devel
+ - Remote_2_13
+ - Remote_2_12
+ - Remote_2_11
+ - Remote_2_10
+ - Remote_2_9
+ jobs:
+ - template: templates/coverage.yml
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/aggregate-coverage.sh b/ansible_collections/community/libvirt/.azure-pipelines/scripts/aggregate-coverage.sh
new file mode 100755
index 000000000..2200502f5
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/aggregate-coverage.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+# Aggregate code coverage results for later processing.
+
+set -o pipefail -eu
+
+agent_temp_directory="$1"
+
+PATH="${PWD}/bin:${PATH}"
+
+mkdir "${agent_temp_directory}/coverage/"
+
+options=(--venv --venv-system-site-packages --color -v)
+
+ansible-test coverage combine --export "${agent_temp_directory}/coverage/" "${options[@]}"
+ansible-test coverage analyze targets generate "${agent_temp_directory}/coverage/coverage-analyze-targets.json" "${options[@]}"
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/combine-coverage.py b/ansible_collections/community/libvirt/.azure-pipelines/scripts/combine-coverage.py
new file mode 100755
index 000000000..506ade646
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/combine-coverage.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+"""
+Combine coverage data from multiple jobs, keeping the data only from the most recent attempt from each job.
+Coverage artifacts must be named using the format: "Coverage $(System.JobAttempt) {StableUniqueNameForEachJob}"
+The recommended coverage artifact name format is: Coverage $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)
+Keep in mind that Azure Pipelines does not enforce unique job display names (only names).
+It is up to pipeline authors to avoid name collisions when deviating from the recommended format.
+"""
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import os
+import re
+import shutil
+import sys
+
+
+def main():
+ """Main program entry point."""
+ source_directory = sys.argv[1]
+
+ if '/ansible_collections/' in os.getcwd():
+ output_path = "tests/output"
+ else:
+ output_path = "test/results"
+
+ destination_directory = os.path.join(output_path, 'coverage')
+
+ if not os.path.exists(destination_directory):
+ os.makedirs(destination_directory)
+
+ jobs = {}
+ count = 0
+
+ for name in os.listdir(source_directory):
+ match = re.search('^Coverage (?P<attempt>[0-9]+) (?P<label>.+)$', name)
+ label = match.group('label')
+ attempt = int(match.group('attempt'))
+ jobs[label] = max(attempt, jobs.get(label, 0))
+
+ for label, attempt in jobs.items():
+ name = 'Coverage {attempt} {label}'.format(label=label, attempt=attempt)
+ source = os.path.join(source_directory, name)
+ source_files = os.listdir(source)
+
+ for source_file in source_files:
+ source_path = os.path.join(source, source_file)
+ destination_path = os.path.join(destination_directory, source_file + '.' + label)
+ print('"%s" -> "%s"' % (source_path, destination_path))
+ shutil.copyfile(source_path, destination_path)
+ count += 1
+
+ print('Coverage file count: %d' % count)
+ print('##vso[task.setVariable variable=coverageFileCount]%d' % count)
+ print('##vso[task.setVariable variable=outputPath]%s' % output_path)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/process-results.sh b/ansible_collections/community/libvirt/.azure-pipelines/scripts/process-results.sh
new file mode 100755
index 000000000..f3f1d1bae
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/process-results.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Check the test results and set variables for use in later steps.
+
+set -o pipefail -eu
+
+if [[ "$PWD" =~ /ansible_collections/ ]]; then
+ output_path="tests/output"
+else
+ output_path="test/results"
+fi
+
+echo "##vso[task.setVariable variable=outputPath]${output_path}"
+
+if compgen -G "${output_path}"'/junit/*.xml' > /dev/null; then
+ echo "##vso[task.setVariable variable=haveTestResults]true"
+fi
+
+if compgen -G "${output_path}"'/bot/ansible-test-*' > /dev/null; then
+ echo "##vso[task.setVariable variable=haveBotResults]true"
+fi
+
+if compgen -G "${output_path}"'/coverage/*' > /dev/null; then
+ echo "##vso[task.setVariable variable=haveCoverageData]true"
+fi
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/publish-codecov.sh b/ansible_collections/community/libvirt/.azure-pipelines/scripts/publish-codecov.sh
new file mode 100755
index 000000000..6d184f0b8
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/publish-codecov.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# Upload code coverage reports to codecov.io.
+# Multiple coverage files from multiple languages are accepted and aggregated after upload.
+# Python coverage, as well as PowerShell and Python stubs can all be uploaded.
+
+set -o pipefail -eu
+
+output_path="$1"
+
+curl --silent --show-error https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/codecov.sh > codecov.sh
+
+for file in "${output_path}"/reports/coverage*.xml; do
+ name="${file}"
+ name="${name##*/}" # remove path
+ name="${name##coverage=}" # remove 'coverage=' prefix if present
+ name="${name%.xml}" # remove '.xml' suffix
+
+ bash codecov.sh \
+ -f "${file}" \
+ -n "${name}" \
+ -X coveragepy \
+ -X gcov \
+ -X fix \
+ -X search \
+ -X xcode \
+ || echo "Failed to upload code coverage report to codecov.io: ${file}"
+done
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/report-coverage.sh b/ansible_collections/community/libvirt/.azure-pipelines/scripts/report-coverage.sh
new file mode 100755
index 000000000..f15499831
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/report-coverage.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+# Generate code coverage reports for uploading to Azure Pipelines and codecov.io.
+
+set -o pipefail -eu
+
+PATH="${PWD}/bin:${PATH}"
+
+pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
+
+ansible-test coverage xml --stub --venv --venv-system-site-packages --color -v
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/run-tests.sh b/ansible_collections/community/libvirt/.azure-pipelines/scripts/run-tests.sh
new file mode 100755
index 000000000..a947fdf01
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/run-tests.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# Configure the test environment and run the tests.
+
+set -o pipefail -eu
+
+entry_point="$1"
+test="$2"
+read -r -a coverage_branches <<< "$3" # space separated list of branches to run code coverage on for scheduled builds
+
+export COMMIT_MESSAGE
+export COMPLETE
+export COVERAGE
+export IS_PULL_REQUEST
+
+if [ "${SYSTEM_PULLREQUEST_TARGETBRANCH:-}" ]; then
+ IS_PULL_REQUEST=true
+ COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD^2)
+else
+ IS_PULL_REQUEST=
+ COMMIT_MESSAGE=$(git log --format=%B -n 1 HEAD)
+fi
+
+COMPLETE=
+COVERAGE=
+
+if [ "${BUILD_REASON}" = "Schedule" ]; then
+ COMPLETE=yes
+
+ if printf '%s\n' "${coverage_branches[@]}" | grep -q "^${BUILD_SOURCEBRANCHNAME}$"; then
+ COVERAGE=yes
+ fi
+fi
+
+"${entry_point}" "${test}" 2>&1 | "$(dirname "$0")/time-command.py"
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/scripts/time-command.py b/ansible_collections/community/libvirt/.azure-pipelines/scripts/time-command.py
new file mode 100755
index 000000000..5e8eb8d4c
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/scripts/time-command.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+"""Prepends a relative timestamp to each input line from stdin and writes it to stdout."""
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import sys
+import time
+
+
+def main():
+ """Main program entry point."""
+ start = time.time()
+
+ sys.stdin.reconfigure(errors='surrogateescape')
+ sys.stdout.reconfigure(errors='surrogateescape')
+
+ for line in sys.stdin:
+ seconds = time.time() - start
+ sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
+ sys.stdout.flush()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/templates/coverage.yml b/ansible_collections/community/libvirt/.azure-pipelines/templates/coverage.yml
new file mode 100644
index 000000000..1864e4441
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/templates/coverage.yml
@@ -0,0 +1,39 @@
+# This template adds a job for processing code coverage data.
+# It will upload results to Azure Pipelines and codecov.io.
+# Use it from a job stage that completes after all other jobs have completed.
+# This can be done by placing it in a separate summary stage that runs after the test stage(s) have completed.
+
+jobs:
+ - job: Coverage
+ displayName: Code Coverage
+ container: default
+ workspace:
+ clean: all
+ steps:
+ - checkout: self
+ fetchDepth: $(fetchDepth)
+ path: $(checkoutPath)
+ - task: DownloadPipelineArtifact@2
+ displayName: Download Coverage Data
+ inputs:
+ path: coverage/
+ patterns: "Coverage */*=coverage.combined"
+ - bash: .azure-pipelines/scripts/combine-coverage.py coverage/
+ displayName: Combine Coverage Data
+ - bash: .azure-pipelines/scripts/report-coverage.sh
+ displayName: Generate Coverage Report
+ condition: gt(variables.coverageFileCount, 0)
+ - task: PublishCodeCoverageResults@1
+ inputs:
+ codeCoverageTool: Cobertura
+ # Azure Pipelines only accepts a single coverage data file.
+ # That means only Python or PowerShell coverage can be uploaded, but not both.
+ # Set the "pipelinesCoverage" variable to determine which type is uploaded.
+ # Use "coverage" for Python and "coverage-powershell" for PowerShell.
+ summaryFileLocation: "$(outputPath)/reports/$(pipelinesCoverage).xml"
+ displayName: Publish to Azure Pipelines
+ condition: gt(variables.coverageFileCount, 0)
+ - bash: .azure-pipelines/scripts/publish-codecov.sh "$(outputPath)"
+ displayName: Publish to codecov.io
+ condition: gt(variables.coverageFileCount, 0)
+ continueOnError: true
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/templates/matrix.yml b/ansible_collections/community/libvirt/.azure-pipelines/templates/matrix.yml
new file mode 100644
index 000000000..4e9555dd3
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/templates/matrix.yml
@@ -0,0 +1,55 @@
+# This template uses the provided targets and optional groups to generate a matrix which is then passed to the test template.
+# If this matrix template does not provide the required functionality, consider using the test template directly instead.
+
+parameters:
+ # A required list of dictionaries, one per test target.
+ # Each item in the list must contain a "test" or "name" key.
+ # Both may be provided. If one is omitted, the other will be used.
+ - name: targets
+ type: object
+
+ # An optional list of values which will be used to multiply the targets list into a matrix.
+ # Values can be strings or numbers.
+ - name: groups
+ type: object
+ default: []
+
+ # An optional format string used to generate the job name.
+ # - {0} is the name of an item in the targets list.
+ - name: nameFormat
+ type: string
+ default: "{0}"
+
+ # An optional format string used to generate the test name.
+ # - {0} is the name of an item in the targets list.
+ - name: testFormat
+ type: string
+ default: "{0}"
+
+ # An optional format string used to add the group to the job name.
+ # {0} is the formatted name of an item in the targets list.
+ # {{1}} is the group -- be sure to include the double "{{" and "}}".
+ - name: nameGroupFormat
+ type: string
+ default: "{0} - {{1}}"
+
+ # An optional format string used to add the group to the test name.
+ # {0} is the formatted test of an item in the targets list.
+ # {{1}} is the group -- be sure to include the double "{{" and "}}".
+ - name: testGroupFormat
+ type: string
+ default: "{0}/{{1}}"
+
+jobs:
+ - template: test.yml
+ parameters:
+ jobs:
+ - ${{ if eq(length(parameters.groups), 0) }}:
+ - ${{ each target in parameters.targets }}:
+ - name: ${{ format(parameters.nameFormat, coalesce(target.name, target.test)) }}
+ test: ${{ format(parameters.testFormat, coalesce(target.test, target.name)) }}
+ - ${{ if not(eq(length(parameters.groups), 0)) }}:
+ - ${{ each group in parameters.groups }}:
+ - ${{ each target in parameters.targets }}:
+ - name: ${{ format(format(parameters.nameGroupFormat, parameters.nameFormat), coalesce(target.name, target.test), group) }}
+ test: ${{ format(format(parameters.testGroupFormat, parameters.testFormat), coalesce(target.test, target.name), group) }}
diff --git a/ansible_collections/community/libvirt/.azure-pipelines/templates/test.yml b/ansible_collections/community/libvirt/.azure-pipelines/templates/test.yml
new file mode 100644
index 000000000..5250ed802
--- /dev/null
+++ b/ansible_collections/community/libvirt/.azure-pipelines/templates/test.yml
@@ -0,0 +1,45 @@
+# This template uses the provided list of jobs to create test one or more test jobs.
+# It can be used directly if needed, or through the matrix template.
+
+parameters:
+ # A required list of dictionaries, one per test job.
+ # Each item in the list must contain a "job" and "name" key.
+ - name: jobs
+ type: object
+
+jobs:
+ - ${{ each job in parameters.jobs }}:
+ - job: test_${{ replace(replace(replace(job.test, '/', '_'), '.', '_'), '-', '_') }}
+ displayName: ${{ job.name }}
+ container: default
+ workspace:
+ clean: all
+ steps:
+ - checkout: self
+ fetchDepth: $(fetchDepth)
+ path: $(checkoutPath)
+ - bash: .azure-pipelines/scripts/run-tests.sh "$(entryPoint)" "${{ job.test }}" "$(coverageBranches)"
+ displayName: Run Tests
+ - bash: .azure-pipelines/scripts/process-results.sh
+ condition: succeededOrFailed()
+ displayName: Process Results
+ - bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)"
+ condition: eq(variables.haveCoverageData, 'true')
+ displayName: Aggregate Coverage Data
+ - task: PublishTestResults@2
+ condition: eq(variables.haveTestResults, 'true')
+ inputs:
+ testResultsFiles: "$(outputPath)/junit/*.xml"
+ displayName: Publish Test Results
+ - task: PublishPipelineArtifact@1
+ condition: eq(variables.haveBotResults, 'true')
+ displayName: Publish Bot Results
+ inputs:
+ targetPath: "$(outputPath)/bot/"
+ artifactName: "Bot $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)"
+ - task: PublishPipelineArtifact@1
+ condition: eq(variables.haveCoverageData, 'true')
+ displayName: Publish Coverage Data
+ inputs:
+ targetPath: "$(Agent.TempDirectory)/coverage/"
+ artifactName: "Coverage $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)"
diff --git a/ansible_collections/community/libvirt/.gitignore b/ansible_collections/community/libvirt/.gitignore
new file mode 100644
index 000000000..fe044d71c
--- /dev/null
+++ b/ansible_collections/community/libvirt/.gitignore
@@ -0,0 +1,9 @@
+# python stuff
+__pycache__/
+*.py[cod]
+
+# ansible-test stuff
+/tests/output/
+
+# antsibull-changelog stuff
+/changelogs/.plugin-cache.yaml
diff --git a/ansible_collections/community/libvirt/CHANGELOG.rst b/ansible_collections/community/libvirt/CHANGELOG.rst
new file mode 100644
index 000000000..0452a4685
--- /dev/null
+++ b/ansible_collections/community/libvirt/CHANGELOG.rst
@@ -0,0 +1,80 @@
+===============================
+Community.Libvirt Release Notes
+===============================
+
+.. contents:: Topics
+
+
+v1.2.0
+======
+
+Release Summary
+---------------
+
+This is the minor release of the ``community.libvirt`` collection.
+This changelog contains all changes to the modules and plugins in this collection
+that have been made after the previous release.
+
+Minor Changes
+-------------
+
+- libvirt - add extra guest information to inventory (https://github.com/ansible-collections/community.libvirt/pull/113).
+- libvirt - replace the calls to listDomainsID() and listDefinedDomains() with listAllDomains() in find_vm() (https://github.com/ansible-collections/community.libvirt/pull/117)
+
+Bugfixes
+--------
+
+- virt_net - fix modify function which was not idempotent, depending on whether the network was active. See https://github.com/ansible-collections/community.libvirt/issues/107.
+- virt_pool - crashed out if pool didn't contain a target path. Fix allows this not to be set. (https://github.com/ansible-collections/community.libvirt/issues/129).
+
+v1.1.0
+======
+
+Release Summary
+---------------
+
+This is the minor release of the ``community.libvirt`` collection.
+This changelog contains all changes to the modules and plugins in this collection
+that have been made after the previous release 1.0.2.
+
+Bugfixes
+--------
+
+- replace deprecated ``distutils.spawn.find_executable`` with Ansible's ``get_bin_path`` in ``_search_executable`` function.
+
+v1.0.2
+======
+
+Release Summary
+---------------
+
+This is the patch release of the ``community.libvirt`` collection.
+This changelog contains all changes to the modules and plugins in this collection
+that have been made after release 1.0.1.
+
+Bugfixes
+--------
+
+- libvirt inventory plugin - Use FQCN for the inventory plugin name for compatibility with Ansible 2.10 and above (https://github.com/ansible-collections/community.libvirt/pull/73).
+
+v1.0.1
+======
+
+Bugfixes
+--------
+
+- libvirt_qemu - Mitigate a CPU hammering active wait loop
+- libvirt_qemu - add import error handling
+- virt - Correctly get the error message from libvirt
+- virt - Return "changed" status when using "define" command and domain XML was updated
+- virt - The define action searchs for the domain name into the xml definition to determine if the domain needs to be created or updated. The xml variable contains the parsed definition but doesn't guarantee the existence of the name tag. This change targets to fix the scenario where the xml var is not empty but doesn't contain a name tag.
+- virt_net - The name parameter is not required for the list_nets or facts command so we adjust the module to allow for that.
+
+v1.0.0
+======
+
+Major Changes
+-------------
+
+- added generic libvirt inventory plugin
+- removed libvirt_lxc inventory script
diff --git a/ansible_collections/community/libvirt/CONTRIBUTING.md b/ansible_collections/community/libvirt/CONTRIBUTING.md
new file mode 100644
index 000000000..edcfe55bc
--- /dev/null
+++ b/ansible_collections/community/libvirt/CONTRIBUTING.md
@@ -0,0 +1,3 @@
+# Contributing
+
+Refer to the [Ansible Contributing guidelines](https://github.com/ansible/community-docs/blob/main/contributing.rst) to learn how to contribute to this collection.
diff --git a/ansible_collections/community/libvirt/COPYING b/ansible_collections/community/libvirt/COPYING
new file mode 100644
index 000000000..f288702d2
--- /dev/null
+++ b/ansible_collections/community/libvirt/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/ansible_collections/community/libvirt/FILES.json b/ansible_collections/community/libvirt/FILES.json
new file mode 100644
index 000000000..f41264643
--- /dev/null
+++ b/ansible_collections/community/libvirt/FILES.json
@@ -0,0 +1,992 @@
+{
+ "files": [
+ {
+ "name": ".",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/aggregate-coverage.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "593b2d276522a1ed322e3798cc68a4f678e67be5bb83752d3f56f0d818b9910d",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/combine-coverage.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e34d4e863a65b9f53c4ca8ae37655858969898a949e050e9cb3cb0d5f02342d0",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/process-results.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c03d7273fe58882a439b6723e92ab89f1e127772b5ce35aa67c546dd62659741",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/publish-codecov.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "70c795c8dbca2534b7909b17911630b7afaa693bbd7154e63a51340bc8b28dad",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/report-coverage.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2e25d533467192222f4102029f29cd7695dbe35c066c69763cd6821ca46e6116",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/run-tests.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "cb08a3ec5715b00d476ae6d63ca22e11a9ad8887239439937d2a7ea342e5a623",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/scripts/time-command.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0232f415efeb583ddff907c058986963b775441eaf129d7162aee0acb0d36834",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/templates",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/templates/coverage.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "daf1930264760d47b54588f05c6339fd69ca2d239c77c44bc4cee3c4e9f76447",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/templates/matrix.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4fb0d3ffb2125d5806c7597e4f9d4b2af69cf8c337e9d57803081eddd4a6b081",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/templates/test.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2cfa1271f94c71f05ffa0b1f763d8946394b5636e14579cda8ee14bb38bbcf1c",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "61f20decd3c8fb34ac2cc6ff79f598fc5136e642130a7ba065ccc5aa37960cd2",
+ "format": 1
+ },
+ {
+ "name": ".azure-pipelines/azure-pipelines.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a549b47cd670d92e56c58995ee2854f176baccf8bbb7bc7a064829bae78034c2",
+ "format": 1
+ },
+ {
+ "name": "changelogs",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "changelogs/changelog.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4a77c0ce3b56db83490dbc6c9a159f7e65b9952b08ed66f7eb9c4e090c1fabe3",
+ "format": 1
+ },
+ {
+ "name": "changelogs/config.yaml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "19153bde83f70f9b9ea79dbde15e641d93afe0270005277a77bb9aabc27985ff",
+ "format": 1
+ },
+ {
+ "name": "meta",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "meta/runtime.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "df18179bb2f5447a56ac92261a911649b96821c0b2c08eea62d5cc6b0195203f",
+ "format": 1
+ },
+ {
+ "name": "plugins",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/connection",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/connection/libvirt_lxc.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "b9c4fe5544ca920c290ed4004122b499c5fa14c810ee4c6f1a616bf1a5a2c029",
+ "format": 1
+ },
+ {
+ "name": "plugins/connection/libvirt_qemu.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "fe6ca9c7dc6e723ac2ac1f720b78767ef3ba6663ecf3bfca03d1a62bb6d4d202",
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments/__init__.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments/requirements.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "daf2d7719d6fb21e7a71c09d4d23218414c25801d6d26619b1ddc857ebd0556d",
+ "format": 1
+ },
+ {
+ "name": "plugins/doc_fragments/virt.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d0b7a491bad2786203fe8111137a7d2cfb0853499dcb16bbef34e3ee170935bd",
+ "format": 1
+ },
+ {
+ "name": "plugins/inventory",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/inventory/__init__.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "format": 1
+ },
+ {
+ "name": "plugins/inventory/libvirt.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "71b0387fc55fca79ad138058e8105465e2f2c1a7f8d3ad0c48251232132cbedd",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/virt.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e23a3804a7fef3b08708ef89b61d70d155b5da55c77cf77ce084d4320452d6f9",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/virt_net.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1f5f65ec1c7fb458f33d22c06b5157ff251f72b01a5b5f2d9d6620447f0a9fb8",
+ "format": 1
+ },
+ {
+ "name": "plugins/modules/virt_pool.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5ab52e7d19324c40a072eb2172bb7f3995621da95872fa090e714e420e64dffa",
+ "format": 1
+ },
+ {
+ "name": "tests",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_lxc",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_lxc/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f13674351f8231c9e60fc923652b1ce94b62357ee00fedaf23ad3af677aff656",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_lxc/runme.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ccdab97fd6569dbe495460cfec0b901006efa79ec4c6d066a98250901b0c9d0e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_lxc/test_connection.inventory",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "d354b2fc291709ce47fbdbbf9da6a6bb27556a4f13f110d38655721f4324293f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_qemu",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_qemu/runme.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ccdab97fd6569dbe495460cfec0b901006efa79ec4c6d066a98250901b0c9d0e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_qemu/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f13674351f8231c9e60fc923652b1ce94b62357ee00fedaf23ad3af677aff656",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/connection_libvirt_qemu/test_connection.inventory",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "cb40d5a2e6d008f3d24987206225d961122ca2a7dac79c0fa692065125d6a61e",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt/playbooks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt/playbooks/test-inventory.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "80c34796e292eab6019d455e13acb7b574ba4b81aeec760da0cd79cef1df9e6a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f13674351f8231c9e60fc923652b1ce94b62357ee00fedaf23ad3af677aff656",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt/libvirt_lxc.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1f749a8321cfb62f5b8b7b7f5b03795dd6d0af247b9451516412152b8a04e0ae",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt/libvirt_qemu.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4eb5ba0c9ba6841323de3d26efa74db1536b808cb4b1732ff37d78d10a0f5d96",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/inventory_libvirt/runme.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "8a432783339cd49692af26c0245f35cdf5c9507c77d830c3f77d1e95aae182d3",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/files",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/files/foobar.xml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0eef2a64edd93c343bebeb04329b71950bf277c617814d4c522ff88fffe4ae00",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "74026357d60f81d90fb3808546bd52e476ff29367dae1cc3ad4a34df0717ff3a",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/Debian.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c14a6a591bb5743118ef270270598907dd9bf88df5de48f7e8ec95cb8a2f9c69",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/Fedora-29.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "abd108abc8b7648d1f151a3acb0c52d57b5bbc905191e7260dd8657ec5cdeaf1",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/RedHat-7.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a3521d37bb8642693686bf3399f8b82a6a76967a22aa8c5c80b9358a5410f3c0",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/RedHat-8.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "abd108abc8b7648d1f151a3acb0c52d57b5bbc905191e7260dd8657ec5cdeaf1",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/RedHat-9.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "abd108abc8b7648d1f151a3acb0c52d57b5bbc905191e7260dd8657ec5cdeaf1",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/Ubuntu-16.04.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "74ff440d1b032d67597323f3c0da75bf9bf15a58facec36d4e8d71f5a0de8bde",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/Ubuntu-18.04.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "74ff440d1b032d67597323f3c0da75bf9bf15a58facec36d4e8d71f5a0de8bde",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/Ubuntu-18.10.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "c14a6a591bb5743118ef270270598907dd9bf88df5de48f7e8ec95cb8a2f9c69",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/vars/default.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "74ff440d1b032d67597323f3c0da75bf9bf15a58facec36d4e8d71f5a0de8bde",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_net/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ed88adb08cb822c2646eec4b136ae4379b0f27f9c8025656446542f100844860",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/defaults",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/defaults/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6a432b3b928fb9e5cffcaea6bc281bc728a1f9baa0f31f8444aea5547c5a4804",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/tasks",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/tasks/directory_based_pool.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3cb8d08791ddef7a88e910f1a6753b2bff560ac1f426c075aa0d89132ce24b63",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/tasks/main.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f865ec27d51d1e97e0136c3250d3cf24b4e09a75198d540baf1ec59076add5e0",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/templates",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/templates/test_pool.xml.j2",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5e845ae3964262768ee6025c96c213c2db89155f549e562ef38836b8adb2da9f",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/CentOS-7.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7c354755cbffa20891592cc37fd5cdf7d2b80ce8c9ea92dc159a3b33e9f8adc4",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/CentOS-8.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "aed1c27549513f07fa505c78ecf21486ba43ba84eaf61095092771215ce0f6b6",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/Debian.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "af1e47dc44dd2d18b2f74b1bfd4c19732f1aeddc7730ef3ea83abade583a6968",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/Fedora-34.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a4aafb32375c3585dada91fd60ca23f24f79b07e184b8dc7960f31f3c36af2a8",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/RedHat-7.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7c354755cbffa20891592cc37fd5cdf7d2b80ce8c9ea92dc159a3b33e9f8adc4",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/RedHat-8.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3276bc55c697b7b17f0e8c93411ed657bad57a651b293440761f225123cbf979",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/RedHat-9.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3276bc55c697b7b17f0e8c93411ed657bad57a651b293440761f225123cbf979",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/Ubuntu-18.04.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4c325d23708f0fb6c0aadc7fe835a460aec43332f972a446841e2270dfa40597",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/Ubuntu-18.10.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "af1e47dc44dd2d18b2f74b1bfd4c19732f1aeddc7730ef3ea83abade583a6968",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/Ubuntu-20.04.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "af1e47dc44dd2d18b2f74b1bfd4c19732f1aeddc7730ef3ea83abade583a6968",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/vars/default.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4c325d23708f0fb6c0aadc7fe835a460aec43332f972a446841e2270dfa40597",
+ "format": 1
+ },
+ {
+ "name": "tests/integration/targets/virt_pool/aliases",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ed88adb08cb822c2646eec4b136ae4379b0f27f9c8025656446542f100844860",
+ "format": 1
+ },
+ {
+ "name": "tests/sanity",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/sanity/ignore-2.10.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3dbe66b16a396e94940e595e59436b4b2ff9163e53e7d33904839d5b51f1e572",
+ "format": 1
+ },
+ {
+ "name": "tests/sanity/ignore-2.11.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3dbe66b16a396e94940e595e59436b4b2ff9163e53e7d33904839d5b51f1e572",
+ "format": 1
+ },
+ {
+ "name": "tests/sanity/ignore-2.12.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
+ "format": 1
+ },
+ {
+ "name": "tests/sanity/ignore-2.13.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
+ "format": 1
+ },
+ {
+ "name": "tests/sanity/ignore-2.14.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a70097a1274b645cb1981448b0b17069dfe2bdfedcec83cf6ea12c9a2d9092c1",
+ "format": 1
+ },
+ {
+ "name": "tests/sanity/ignore-2.9.txt",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3dbe66b16a396e94940e595e59436b4b2ff9163e53e7d33904839d5b51f1e572",
+ "format": 1
+ },
+ {
+ "name": "tests/unit",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/compat",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/compat/__init__.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/compat/builtins.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0ca4cac919e166b25e601e11acb01f6957dddd574ff0a62569cb994a5ecb63e1",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/compat/mock.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "0af958450cf6de3fbafe94b1111eae8ba5a8dbe1d785ffbb9df81f26e4946d99",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/compat/unittest.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5401a046e5ce71fa19b6d905abd0f9bdf816c0c635f7bdda6730b3ef06e67096",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock/__init__.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock/loader.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "cfe3480f0eae6d3723ee62d01d00a0e9f58fcdc082ea1d8e4836157c56d4fa95",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock/path.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ee6c51ad6bb107708d9fe2a97a40302bf0b9dc23a30bf187fe4b3a8cda7846a6",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock/procenv.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4be64fe930952ee9967d840f02719fc913368f80badf3eb77f61b1422e8ddad7",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock/vault_helper.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4535613601c419f7d20f0c21e638dabccf69b4a7fac99d5f6f9b81d1519dafd6",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/mock/yaml_helper.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "5ee51da1a6ec8367e0fff9dadc8b012a4af96e00235bfea53301ee124c422434",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules/cloud",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules/cloud/misc",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules/cloud/misc/virt_net",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules/cloud/misc/virt_net/__init__.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules/cloud/misc/virt_net/conftest.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "a47598c50db65c1a4c60b347c94799cdf1d0d8577a26529b05bb2fd010c748ad",
+ "format": 1
+ },
+ {
+ "name": "tests/unit/modules/cloud/misc/virt_net/test_virt_net.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "775046136ce72fdada508a8f3d541477e600a7e24cebae44dd10ea977ab4f468",
+ "format": 1
+ },
+ {
+ "name": "tests/utils",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable",
+ "ftype": "dir",
+ "chksum_type": null,
+ "chksum_sha256": null,
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/freebsd.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2a140a1cea2fbf3b291009694bcfcf0f2877e92ec01c7e929e787f5b4cdd6d92",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/osx.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2a140a1cea2fbf3b291009694bcfcf0f2877e92ec01c7e929e787f5b4cdd6d92",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/rhel.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2a140a1cea2fbf3b291009694bcfcf0f2877e92ec01c7e929e787f5b4cdd6d92",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/check_matrix.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "4855ba1cb515a6b3a51e3ac26e00c34d853866d8a67ced189f8f733526ae3d8a",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/cloud.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "dd953f7e779b9962e76492c389142e03174e84a8115f53e56628e2af9e66b818",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/linux.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "07aa5e07a0b732a671bf9fdadfe073dd310b81857b897328ce2fa829e2c76315",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/remote.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2a140a1cea2fbf3b291009694bcfcf0f2877e92ec01c7e929e787f5b4cdd6d92",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/sanity.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1cd365c5bad1facb7e98cad97a20e34231f49fca169653ccd7d34bd955bd88f6",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/shippable.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "52459c0782603412feb8ff38e23cfdba88db821d928b90d72595d3b3eac01939",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/timing.py",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "ebb7d3553349747ad41d80899ed353e13cf32fcbecbb6566cf36e9d2bc33703e",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/timing.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f3f3cc03a997cdba719b0542fe668fc612451841cbe840ab36865f30aa54a1bd",
+ "format": 1
+ },
+ {
+ "name": "tests/utils/shippable/units.sh",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "00169bf628f2336b63e274821cd691569feeaaecd6d29afe7b0a3fa483a44157",
+ "format": 1
+ },
+ {
+ "name": ".gitignore",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "f17de8746390b50164c6080f7a7b0646063e9372b6c2ca054fc20d4f17dad9f3",
+ "format": 1
+ },
+ {
+ "name": "CHANGELOG.rst",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "6a5ac5751344499d6238ee7dce91c1b787ca62b388cdc2b2d40c5179bf53874b",
+ "format": 1
+ },
+ {
+ "name": "CONTRIBUTING.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "537598e3a4b1c7e00d763177f92a0b2a66b0c02747dd47f847bc6a03bcb50cc0",
+ "format": 1
+ },
+ {
+ "name": "COPYING",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986",
+ "format": 1
+ },
+ {
+ "name": "MAINTAINERS",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "1556ac2696482b9f63f5c98b8738505bb26dfbcd9b8670a4ac30b1cc616506c2",
+ "format": 1
+ },
+ {
+ "name": "MAINTAINING.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "2435665a6562d5f3841fff1631970f95f0466c498e949d2b8579ccc2a0b810ad",
+ "format": 1
+ },
+ {
+ "name": "README.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "7d0320a496915efd15c82bb7bab894a0b2d320f5b5eb92b0fb7d3718e2588d2a",
+ "format": 1
+ },
+ {
+ "name": "REVIEW_CHECKLIST.md",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "91ad4aff2cc14b98f81fbe2d90609c5a69ed96b6d836387a9c697c1112e603c0",
+ "format": 1
+ },
+ {
+ "name": "shippable.yml",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "dd3e1a178530d504227c9eb472916752b1403bb4f2d10f671a1a9bc1b156a619",
+ "format": 1
+ }
+ ],
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/community/libvirt/MAINTAINERS b/ansible_collections/community/libvirt/MAINTAINERS
new file mode 100644
index 000000000..51ed0ded7
--- /dev/null
+++ b/ansible_collections/community/libvirt/MAINTAINERS
@@ -0,0 +1,3 @@
+csmart
+drybjed
+odyssey4me
diff --git a/ansible_collections/community/libvirt/MAINTAINING.md b/ansible_collections/community/libvirt/MAINTAINING.md
new file mode 100644
index 000000000..9fad0d343
--- /dev/null
+++ b/ansible_collections/community/libvirt/MAINTAINING.md
@@ -0,0 +1,3 @@
+# Maintaining this collection
+
+Refer to the [Maintainer guidelines](https://github.com/ansible/community-docs/blob/main/maintaining.rst).
diff --git a/ansible_collections/community/libvirt/MANIFEST.json b/ansible_collections/community/libvirt/MANIFEST.json
new file mode 100644
index 000000000..6f9a9f4eb
--- /dev/null
+++ b/ansible_collections/community/libvirt/MANIFEST.json
@@ -0,0 +1,33 @@
+{
+ "collection_info": {
+ "namespace": "community",
+ "name": "libvirt",
+ "version": "1.2.0",
+ "authors": [
+ "Ansible (https://github.com/ansible)",
+ "community.libvirt"
+ ],
+ "readme": "README.md",
+ "tags": [
+ "libvirt",
+ "lxc",
+ "qemu"
+ ],
+ "description": null,
+ "license": [],
+ "license_file": "COPYING",
+ "dependencies": {},
+ "repository": "https://github.com/ansible-collections/community.libvirt",
+ "documentation": "https://docs.ansible.com/ansible/latest/collections/community/libvirt/index.html",
+ "homepage": "https://github.com/ansible-collections/community.libvirt",
+ "issues": "https://github.com/ansible-collections/community.libvirt/issues"
+ },
+ "file_manifest_file": {
+ "name": "FILES.json",
+ "ftype": "file",
+ "chksum_type": "sha256",
+ "chksum_sha256": "37ac18f37cae0fd2deb7d11e81c71b9c5d7a68b4a040ccd07c31976f563357ff",
+ "format": 1
+ },
+ "format": 1
+} \ No newline at end of file
diff --git a/ansible_collections/community/libvirt/README.md b/ansible_collections/community/libvirt/README.md
new file mode 100644
index 000000000..4f3e9f7b8
--- /dev/null
+++ b/ansible_collections/community/libvirt/README.md
@@ -0,0 +1,155 @@
+# community.libvirt Collection
+[![Build Status](
+https://dev.azure.com/ansible/community.libvirt/_apis/build/status/CI?branchName=main)](https://dev.azure.com/ansible/community.libvirt/_build?definitionId=27)
+[![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.libvirt)](https://codecov.io/gh/ansible-collections/community.libvirt)
+
+This repo hosts the `community.libvirt` Ansible Collection.
+
+The collection includes the libvirt modules and plugins supported by Ansible
+libvirt community to help the management of virtual machines and/or containers
+via the [libvirt](https://libvirt.org/) API.
+
+This collection is shipped with the `ansible` package.
+
+## Tested with Ansible
+<!-- List the versions of Ansible the collection has been tested with. Must match what is in galaxy.yml. -->
+
+- 2.9
+- 2.10
+- 2.11
+- devel
+
+## External requirements
+<!-- List any external resources the collection depends on, for example minimum versions of an OS, libraries, or utilities. Do not list other Ansible collections here. -->
+- python >= 2.6
+- [libvirt python bindings](https://pypi.org/project/libvirt-python/)
+
+## Included content
+<!-- Galaxy will eventually list the module docs within the UI, but until that is ready, you may need to either describe your plugins etc here, or point to an external docsite to cover that information. -->
+
+Modules:
+
+- [virt](https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_module.html)
+- [virt_net](https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_net_module.html)
+- [virt_pool](https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_pool_module.html)
+
+Inventory:
+
+- [libvirt](https://docs.ansible.com/ansible/latest/collections/community/libvirt/libvirt_inventory.html#ansible-collections-community-libvirt-libvirt-inventory)
+
+Connection:
+
+- [libvirt_lxc](https://docs.ansible.com/ansible/latest/collections/community/libvirt/libvirt_lxc_connection.html#ansible-collections-community-libvirt-libvirt-lxc-connection)
+- [libvirt_qemu](https://docs.ansible.com/ansible/latest/collections/community/libvirt/libvirt_qemu_connection.html#ansible-collections-community-libvirt-libvirt-qemu-connection)
+
+## Using this collection
+<!--Include some quick examples that cover the most common use cases for your collection content. -->
+
+Before using the libvirt collection, you need to install it with the Ansible Galaxy command-line tool:
+
+```bash
+ansible-galaxy collection install community.libvirt
+```
+
+You can include it in a `requirements.yml` file and install it via `ansible-galaxy collection install -r requirements.yml`, using the format:
+
+```yaml
+---
+collections:
+ - name: community.libvirt
+```
+
+You can also download the tarball from [Ansible Galaxy](https://galaxy.ansible.com/community/libvirt) and install the collection manually wherever you need.
+
+Note that if you install the collection from Ansible Galaxy with the command-line tool or tarball, it will not be upgraded automatically when you upgrade the Ansible package. To upgrade the collection to the latest available version, run the following command:
+
+```bash
+ansible-galaxy collection install community.libvirt --upgrade
+```
+
+You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax:
+
+```bash
+ansible-galaxy collection install community.libvirt:==X.Y.Z
+```
+
+See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details.
+
+## Contributing to this collection
+<!--Describe how the community can contribute to your collection. At a minimum, include how and where users can create issues to report problems or request features for this collection. List contribution requirements, including preferred workflows and necessary testing, so you can benefit from community PRs. -->
+
+The content of this collection is made by people just like you, a community of individuals collaborating on making the world better through developing automation software.
+
+We are actively accepting new contributors.
+
+All types of contributions are very welcome.
+
+You don't know how to start? Refer to our [contribution guide](https://github.com/ansible-collections/community.libvirt/blob/main/CONTRIBUTING.md)!
+
+The aspiration is to follow the following general guidelines:
+
+- Changes should include tests and documentation where appropriate.
+- Changes will be lint tested using standard python lint tests.
+- No changes which do not pass CI testing will be approved/merged.
+- The collection plugins must provide the same coverage of python support as
+ the versions of Ansible supported.
+- The versions of Ansible supported by the collection must be the same as
+ those in developed, or those maintained, as shown in the Ansible [Release and Maintenance](https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html) documentation.
+
+We use the following guidelines:
+
+* [CONTRIBUTING.md](https://github.com/ansible-collections/community.libvirt/blob/main/CONTRIBUTING.md)
+* [REVIEW_CHECKLIST.md](https://github.com/ansible-collections/community.libvirt/blob/main/REVIEW_CHECKLIST.md)
+* [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html)
+* [Ansible Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/index.html)
+* [Ansible Collection Development Guide](https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#contributing-to-collections)
+
+### Local Testing
+
+To learn how to test your pull request locally, refer to the [Quick-start guide](https://github.com/ansible/community-docs/blob/main/create_pr_quick_start_guide.rst#id3).
+
+To learn how to test a pull request made by another person in your local environment, refer to the [Test PR locally guide](https://github.com/ansible/community-docs/blob/main/test_pr_locally_guide.rst).
+
+## Collection maintenance
+
+The current maintainers (contributors with `write` or higher access) are listed in the [MAINTAINERS](https://github.com/ansible-collections/community.libvirt/blob/main/MAINTAINERS) file. If you have questions or need help, feel free to mention them in the proposals.
+
+To learn how to maintain / become a maintainer of this collection, refer to the [Maintainer guidelines](https://github.com/ansible-collections/community.libvirt/blob/main/MAINTAINING.md).
+
+It is necessary for maintainers of this collection to be subscribed to:
+
+* The collection itself (the `Watch` button -> `All Activity` in the upper right corner of the repository's homepage).
+* The "Changes Impacting Collection Contributors and Maintainers" [issue](https://github.com/ansible-collections/overview/issues/45).
+
+They also should be subscribed to Ansible's [The Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn).
+
+### Publishing New Version
+
+See the [Releasing guidelines](https://github.com/ansible/community-docs/blob/main/releasing_collections_without_release_branches.rst) to learn more.
+
+## Communication
+
+To communicate, we use:
+
+- The `#ansible-community` [Libera.Chat](https://libera.chat/) IRC channel.
+- [Issues](https://github.com/ansible-collections/libvirt/issues) in this repository.
+
+We announce important development changes and releases through Ansible's [The Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn). If you are a collection developer, be sure you are subscribed.
+
+We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit) virtually or in-person. Track [The Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn) and join us.
+
+For more information about communication, refer to the [Ansible Communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
+
+## Reference
+
+- [Ansible Collection overview](https://github.com/ansible-collections/overview)
+- [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html)
+- [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html)
+- [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
+
+## License
+<!-- Include the appropriate license information here and a pointer to the full licensing details. If the collection contains modules migrated from the ansible/ansible repo, you must use the same license that existed in the ansible/ansible repo. See the GNU license example below. -->
+
+GNU General Public License v3.0 or later.
+
+See [LICENCE](https://www.gnu.org/licenses/gpl-3.0.txt) to see the full text.
diff --git a/ansible_collections/community/libvirt/REVIEW_CHECKLIST.md b/ansible_collections/community/libvirt/REVIEW_CHECKLIST.md
new file mode 100644
index 000000000..9dccf7ef1
--- /dev/null
+++ b/ansible_collections/community/libvirt/REVIEW_CHECKLIST.md
@@ -0,0 +1,3 @@
+# Review Checklist
+
+Refer to the [Collection review checklist](https://github.com/ansible/community-docs/blob/main/review_checklist.rst).
diff --git a/ansible_collections/community/libvirt/changelogs/changelog.yaml b/ansible_collections/community/libvirt/changelogs/changelog.yaml
new file mode 100644
index 000000000..62a1b1a9e
--- /dev/null
+++ b/ansible_collections/community/libvirt/changelogs/changelog.yaml
@@ -0,0 +1,85 @@
+ancestor: null
+releases:
+ 1.0.0:
+ changes:
+ major_changes:
+ - added generic libvirt inventory plugin
+ - removed libvirt_lxc inventory script
+ fragments:
+ - 23-inventory.yml
+ release_date: '2020-08-18'
+ 1.0.1:
+ changes:
+ bugfixes:
+ - libvirt_qemu - Mitigate a CPU hammering active wait loop
+ - libvirt_qemu - add import error handling
+ - virt - Correctly get the error message from libvirt
+ - virt - Return "changed" status when using "define" command and domain XML
+ was updated
+ - virt - The define action searchs for the domain name into the xml definition
+ to determine if the domain needs to be created or updated. The xml variable
+ contains the parsed definition but doesn't guarantee the existence of the
+ name tag. This change targets to fix the scenario where the xml var is not
+ empty but doesn't contain a name tag.
+ - virt_net - The name parameter is not required for the list_nets or facts command
+ so we adjust the module to allow for that.
+ fragments:
+ - 43-virt-define-fail.yml
+ - 48-virt-detect-domain-update.yml
+ - 54-virt_net-optional-name.yml
+ - 55-virt-message-property.yml
+ - 59-libvirt_qemu-import-error-handling.yml
+ - 61-libvirt_qemu-mitigate-cpu-spike.yml
+ release_date: '2021-03-05'
+ 1.0.2:
+ changes:
+ bugfixes:
+ - libvirt inventory plugin - Use FQCN for the inventory plugin name for compatibility
+ with Ansible 2.10 and above (https://github.com/ansible-collections/community.libvirt/pull/73).
+ release_summary: 'This is the patch release of the ``community.libvirt`` collection.
+
+ This changelog contains all changes to the modules and plugins in this collection
+
+ that have been made after release 1.0.1.'
+ fragments:
+ - 1.0.2.yml
+ - 73-plugin-name-fqcn.yaml
+ release_date: '2021-07-22'
+ 1.1.0:
+ changes:
+ bugfixes:
+ - replace deprecated ``distutils.spawn.find_executable`` with Ansible's ``get_bin_path``
+ in ``_search_executable`` function.
+ release_summary: 'This is the minor release of the ``community.mysql`` collection.
+
+ This changelog contains all changes to the modules and plugins in this collection
+
+ that have been made after the previous release 1.0.2.'
+ fragments:
+ - 1.1.0.yml
+ - 114_replace_distutils_spawn.yml
+ - 90_add_integration_test_for_virt_pool.yml
+ release_date: '2022-05-12'
+ 1.2.0:
+ changes:
+ bugfixes:
+ - virt_net - fix modify function which was not idempotent, depending on whether
+ the network was active. See https://github.com/ansible-collections/community.libvirt/issues/107.
+ - virt_pool - crashed out if pool didn't contain a target path. Fix allows this
+ not to be set. (https://github.com/ansible-collections/community.libvirt/issues/129).
+ minor_changes:
+ - libvirt - add extra guest information to inventory (https://github.com/ansible-collections/community.libvirt/pull/113).
+ - libvirt - replace the calls to listDomainsID() and listDefinedDomains() with
+ listAllDomains() in find_vm() (https://github.com/ansible-collections/community.libvirt/pull/117)
+ release_summary: 'This is the minor release of the ``community.libvirt`` collection.
+
+ This changelog contains all changes to the modules and plugins in this collection
+
+ that have been made after the previous release.'
+ fragments:
+ - 1.2.0.yml
+ - 108_make_virt_net_modify_idempotent.yml
+ - 113_extra_inventory_info.yml
+ - 117_find_vms_update_calls.yml
+ - virt_pool_no_path.yml
+ release_date: '2022-08-04'
diff --git a/ansible_collections/community/libvirt/changelogs/config.yaml b/ansible_collections/community/libvirt/changelogs/config.yaml
new file mode 100644
index 000000000..83e48d028
--- /dev/null
+++ b/ansible_collections/community/libvirt/changelogs/config.yaml
@@ -0,0 +1,31 @@
+changelog_filename_template: ../CHANGELOG.rst
+changelog_filename_version_depth: 0
+changes_file: changelog.yaml
+changes_format: combined
+ignore_other_fragment_extensions: true
+keep_fragments: false
+mention_ancestor: true
+new_plugins_after_name: removed_features
+notesdir: fragments
+prelude_section_name: release_summary
+prelude_section_title: Release Summary
+sections:
+- - major_changes
+ - Major Changes
+- - minor_changes
+ - Minor Changes
+- - breaking_changes
+ - Breaking Changes / Porting Guide
+- - deprecated_features
+ - Deprecated Features
+- - removed_features
+ - Removed Features (previously deprecated)
+- - security_fixes
+ - Security Fixes
+- - bugfixes
+ - Bugfixes
+- - known_issues
+ - Known Issues
+title: Community.Libvirt
+trivial_section_name: trivial
+use_fqcn: true
diff --git a/ansible_collections/community/libvirt/meta/runtime.yml b/ansible_collections/community/libvirt/meta/runtime.yml
new file mode 100644
index 000000000..2ee3c9fa9
--- /dev/null
+++ b/ansible_collections/community/libvirt/meta/runtime.yml
@@ -0,0 +1,2 @@
+---
+requires_ansible: '>=2.9.10'
diff --git a/ansible_collections/community/libvirt/plugins/connection/libvirt_lxc.py b/ansible_collections/community/libvirt/plugins/connection/libvirt_lxc.py
new file mode 100644
index 000000000..eca94a0f0
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/connection/libvirt_lxc.py
@@ -0,0 +1,183 @@
+# Based on local.py (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
+# Based on chroot.py (c) 2013, Maykel Moya <mmoya@speedyrails.com>
+# (c) 2013, Michael Scherer <misc@zarb.org>
+# (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com>
+# (c) 2017 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = '''
+---
+author:
+ - Michael Scherer (@mscherer) <misc@zarb.org>
+name: libvirt_lxc
+short_description: Run tasks in lxc containers via libvirt
+description:
+ - Run commands or put/fetch files to an existing lxc container using libvirt.
+options:
+ remote_addr:
+ description:
+ - Container identifier.
+ default: The set user as per docker's configuration
+ vars:
+ - name: ansible_host
+ - name: ansible_libvirt_lxc_host
+'''
+
+import os
+import os.path
+import subprocess
+import traceback
+
+from ansible import constants as C
+from ansible.errors import AnsibleError
+from ansible.module_utils.six.moves import shlex_quote
+from ansible.module_utils.common.process import get_bin_path
+from ansible.module_utils._text import to_bytes
+from ansible.plugins.connection import ConnectionBase, BUFSIZE
+from ansible.utils.display import Display
+
+display = Display()
+
+
+class Connection(ConnectionBase):
+ ''' Local lxc based connections '''
+
+ transport = 'community.general.libvirt_lxc'
+ has_pipelining = True
+ # su currently has an undiagnosed issue with calculating the file
+ # checksums (so copy, for instance, doesn't work right)
+ # Have to look into that before re-enabling this
+ default_user = 'root'
+ has_tty = False
+
+ def __init__(self, play_context, new_stdin, *args, **kwargs):
+ super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
+ self.lxc = self._play_context.remote_addr
+
+ self.virsh = self._search_executable('virsh')
+
+ self._check_domain(self.lxc)
+
+ def _search_executable(self, executable):
+ try:
+ return get_bin_path(executable)
+ except ValueError:
+ raise AnsibleError("%s command not found in PATH") % executable
+
+ def _check_domain(self, domain):
+ p = subprocess.Popen([self.virsh, '-q', '-c', 'lxc:///', 'dominfo', to_bytes(domain)],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p.communicate()
+ if p.returncode:
+ raise AnsibleError("%s is not a lxc defined in libvirt" % domain)
+
+ def _connect(self):
+ ''' connect to the lxc; nothing to do here '''
+ super(Connection, self)._connect()
+ if not self._connected:
+ display.vvv("THIS IS A LOCAL LXC DIR", host=self.lxc)
+ self._connected = True
+
+ def _buffered_exec_command(self, cmd, stdin=subprocess.PIPE):
+ ''' run a command on the chroot. This is only needed for implementing
+ put_file() get_file() so that we don't have to read the whole file
+ into memory.
+
+ compared to exec_command() it looses some niceties like being able to
+ return the process's exit code immediately.
+ '''
+ executable = C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else '/bin/sh'
+ local_cmd = [self.virsh, '-q', '-c', 'lxc:///', 'lxc-enter-namespace']
+
+ if C.DEFAULT_LIBVIRT_LXC_NOSECLABEL:
+ local_cmd += ['--noseclabel']
+
+ local_cmd += [self.lxc, '--', executable, '-c', cmd]
+
+ display.vvv("EXEC %s" % (local_cmd,), host=self.lxc)
+ local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
+ p = subprocess.Popen(local_cmd, shell=False, stdin=stdin,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ return p
+
+ def exec_command(self, cmd, in_data=None, sudoable=False):
+ ''' run a command on the chroot '''
+ super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
+
+ p = self._buffered_exec_command(cmd)
+
+ stdout, stderr = p.communicate(in_data)
+ return (p.returncode, stdout, stderr)
+
+ def _prefix_login_path(self, remote_path):
+ ''' Make sure that we put files into a standard path
+
+ If a path is relative, then we need to choose where to put it.
+ ssh chooses $HOME but we aren't guaranteed that a home dir will
+ exist in any given chroot. So for now we're choosing "/" instead.
+ This also happens to be the former default.
+
+ Can revisit using $HOME instead if it's a problem
+ '''
+ if not remote_path.startswith(os.path.sep):
+ remote_path = os.path.join(os.path.sep, remote_path)
+ return os.path.normpath(remote_path)
+
+ def put_file(self, in_path, out_path):
+ ''' transfer a file from local to lxc '''
+ super(Connection, self).put_file(in_path, out_path)
+ display.vvv("PUT %s TO %s" % (in_path, out_path), host=self.lxc)
+
+ out_path = shlex_quote(self._prefix_login_path(out_path))
+ try:
+ with open(to_bytes(in_path, errors='surrogate_or_strict'), 'rb') as in_file:
+ if not os.fstat(in_file.fileno()).st_size:
+ count = ' count=0'
+ else:
+ count = ''
+ try:
+ p = self._buffered_exec_command('dd of=%s bs=%s%s' % (out_path, BUFSIZE, count), stdin=in_file)
+ except OSError:
+ raise AnsibleError("chroot connection requires dd command in the chroot")
+ try:
+ stdout, stderr = p.communicate()
+ except Exception:
+ traceback.print_exc()
+ raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path))
+ if p.returncode != 0:
+ raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, stdout, stderr))
+ except IOError:
+ raise AnsibleError("file or module does not exist at: %s" % in_path)
+
+ def fetch_file(self, in_path, out_path):
+ ''' fetch a file from lxc to local '''
+ super(Connection, self).fetch_file(in_path, out_path)
+ display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self.lxc)
+
+ in_path = shlex_quote(self._prefix_login_path(in_path))
+ try:
+ p = self._buffered_exec_command('dd if=%s bs=%s' % (in_path, BUFSIZE))
+ except OSError:
+ raise AnsibleError("chroot connection requires dd command in the chroot")
+
+ with open(to_bytes(out_path, errors='surrogate_or_strict'), 'wb+') as out_file:
+ try:
+ chunk = p.stdout.read(BUFSIZE)
+ while chunk:
+ out_file.write(chunk)
+ chunk = p.stdout.read(BUFSIZE)
+ except Exception:
+ traceback.print_exc()
+ raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path))
+ stdout, stderr = p.communicate()
+ if p.returncode != 0:
+ raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, stdout, stderr))
+
+ def close(self):
+ ''' terminate the connection; nothing to do here '''
+ super(Connection, self).close()
+ self._connected = False
diff --git a/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py
new file mode 100644
index 000000000..220c02283
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/connection/libvirt_qemu.py
@@ -0,0 +1,361 @@
+# Based on local.py (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
+# Based on chroot.py (c) 2013, Maykel Moya <mmoya@speedyrails.com>
+# (c) 2013, Michael Scherer <misc@zarb.org>
+# (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com>
+# (c) 2017 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = """
+---
+author:
+ - Jesse Pretorius (@odyssey4me) <jesse@odyssey4.me>
+name: libvirt_qemu
+short_description: Run tasks on libvirt/qemu virtual machines
+description:
+ - Run commands or put/fetch files to libvirt/qemu virtual machines using the qemu agent API.
+notes:
+ - Currently DOES NOT work with selinux set to enforcing in the VM.
+ - Requires the qemu-agent installed in the VM.
+ - Requires access to the qemu-ga commands guest-exec, guest-exec-status, guest-file-close, guest-file-open, guest-file-read, guest-file-write.
+extends_documentation_fragment:
+ - community.libvirt.requirements
+version_added: "2.10.0"
+options:
+ remote_addr:
+ description: Virtual machine name.
+ default: inventory_hostname
+ vars:
+ - name: ansible_host
+ executable:
+ description:
+ - Shell to use for execution inside container.
+ - Set this to 'cmd' or 'powershell' for Windows VMs.
+ default: /bin/sh
+ vars:
+ - name: ansible_shell_type
+ virt_uri:
+ description: Libvirt URI to connect to to access the virtual machine.
+ default: qemu:///system
+ vars:
+ - name: ansible_libvirt_uri
+"""
+
+import base64
+import json
+import shlex
+import time
+import traceback
+
+try:
+ import libvirt
+ import libvirt_qemu
+except ImportError as imp_exc:
+ LIBVIRT_IMPORT_ERROR = imp_exc
+else:
+ LIBVIRT_IMPORT_ERROR = None
+
+from ansible import constants as C
+from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
+from ansible.module_utils._text import to_bytes, to_native, to_text
+from ansible.module_utils.six import raise_from
+from ansible.plugins.connection import ConnectionBase, BUFSIZE
+from ansible.plugins.shell.powershell import _parse_clixml
+from ansible.utils.display import Display
+from functools import partial
+from os.path import exists, getsize
+
+display = Display()
+
+
+REQUIRED_CAPABILITIES = [
+ {'enabled': True, 'name': 'guest-exec', 'success-response': True},
+ {'enabled': True, 'name': 'guest-exec-status', 'success-response': True},
+ {'enabled': True, 'name': 'guest-file-close', 'success-response': True},
+ {'enabled': True, 'name': 'guest-file-open', 'success-response': True},
+ {'enabled': True, 'name': 'guest-file-read', 'success-response': True},
+ {'enabled': True, 'name': 'guest-file-write', 'success-response': True}
+]
+
+
+class Connection(ConnectionBase):
+ ''' Local libvirt qemu based connections '''
+
+ transport = 'community.libvirt.libvirt_qemu'
+ # TODO(odyssey4me):
+ # Figure out why pipelining does not work and fix it
+ has_pipelining = False
+ has_tty = False
+
+ def __init__(self, play_context, new_stdin, *args, **kwargs):
+ if LIBVIRT_IMPORT_ERROR:
+ raise_from(
+ AnsibleError('libvirt python bindings must be installed to use this plugin'),
+ LIBVIRT_IMPORT_ERROR)
+
+ super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
+
+ self._host = self._play_context.remote_addr
+
+ # Windows operates differently from a POSIX connection/shell plugin,
+ # we need to set various properties to ensure SSH on Windows continues
+ # to work
+ # Ensure that any Windows hosts in your inventory have one of the
+ # following set, in order to trigger this code:
+ # ansible_shell_type: cmd
+ # ansible_shell_type: powershell
+ if getattr(self._shell, "_IS_WINDOWS", False):
+ self.has_native_async = True
+ self.always_pipeline_modules = True
+ self.module_implementation_preferences = ('.ps1', '.exe', '')
+ self.allow_executable = False
+
+ def _connect(self):
+ ''' connect to the virtual machine; nothing to do here '''
+ super(Connection, self)._connect()
+ if not self._connected:
+
+ self._virt_uri = self.get_option('virt_uri')
+
+ self._display.vvv(u"CONNECT TO {0}".format(self._virt_uri), host=self._host)
+ try:
+ self.conn = libvirt.open(self._virt_uri)
+ except libvirt.libvirtError as err:
+ raise AnsibleConnectionFailure(to_native(err))
+
+ self._display.vvv(u"FIND DOMAIN {0}".format(self._host), host=self._host)
+ try:
+ self.domain = self.conn.lookupByName(self._host)
+ except libvirt.libvirtError as err:
+ raise AnsibleConnectionFailure(to_native(err))
+
+ request_cap = json.dumps({'execute': 'guest-info'})
+ response_cap = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_cap, 5, 0))
+ self.capabilities = response_cap['return']['supported_commands']
+ self._display.vvvvv(u"GUEST CAPABILITIES: {0}".format(self.capabilities), host=self._host)
+ missing_caps = []
+ for cap in REQUIRED_CAPABILITIES:
+ if cap not in self.capabilities:
+ missing_caps.append(cap['name'])
+ if len(missing_caps) > 0:
+ self._display.vvv(u"REQUIRED CAPABILITIES MISSING: {0}".format(missing_caps), host=self._host)
+ raise AnsibleConnectionFailure('Domain does not have required capabilities')
+
+ display.vvv(u"ESTABLISH {0} CONNECTION".format(self.transport), host=self._host)
+ self._connected = True
+
+ def exec_command(self, cmd, in_data=None, sudoable=True):
+ """ execute a command on the virtual machine host """
+ super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
+
+ self._display.vvv(u"EXEC {0}".format(cmd), host=self._host)
+
+ cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
+
+ if getattr(self._shell, "_IS_WINDOWS", False):
+ # Become method 'runas' is done in the wrapper that is executed,
+ # need to disable sudoable so the bare_run is not waiting for a
+ # prompt that will not occur
+ sudoable = False
+
+ # Generate powershell commands
+ cmd_args_list = self._shell._encode_script(cmd, as_list=True, strict_mode=False, preserve_rc=False)
+
+ # TODO(odyssey4me):
+ # Implement buffering much like the other connection plugins
+ # Implement 'env' for the environment settings
+ # Implement 'input-data' for whatever it might be useful for
+ request_exec = {
+ 'execute': 'guest-exec',
+ 'arguments': {
+ 'path': cmd_args_list[0],
+ 'capture-output': True,
+ 'arg': cmd_args_list[1:]
+ }
+ }
+ request_exec_json = json.dumps(request_exec)
+
+ display.vvv(u"GA send: {0}".format(request_exec_json), host=self._host)
+
+ # TODO(odyssey4me):
+ # Add timeout parameter
+ result_exec = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_exec_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_exec), host=self._host)
+
+ command_start = time.clock_gettime(time.CLOCK_MONOTONIC)
+
+ request_status = {
+ 'execute': 'guest-exec-status',
+ 'arguments': {
+ 'pid': result_exec['return']['pid']
+ }
+ }
+ request_status_json = json.dumps(request_status)
+
+ display.vvv(u"GA send: {0}".format(request_status_json), host=self._host)
+
+ # TODO(odyssey4me):
+ # Work out a better way to wait until the command has exited
+ result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_status), host=self._host)
+
+ while not result_status['return']['exited']:
+ # Wait for 5% of the time already elapsed
+ sleep_time = (time.clock_gettime(time.CLOCK_MONOTONIC) - command_start) * (5 / 100)
+ if sleep_time < 0.0002:
+ sleep_time = 0.0002
+ elif sleep_time > 1:
+ sleep_time = 1
+ time.sleep(sleep_time)
+ result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_status), host=self._host)
+
+ if result_status['return'].get('out-data'):
+ stdout = base64.b64decode(result_status['return']['out-data'])
+ else:
+ stdout = b''
+
+ if result_status['return'].get('err-data'):
+ stderr = base64.b64decode(result_status['return']['err-data'])
+ else:
+ stderr = b''
+
+ # Decode xml from windows
+ if getattr(self._shell, "_IS_WINDOWS", False) and stdout.startswith(b"#< CLIXML"):
+ stdout = _parse_clixml(stdout)
+
+ display.vvv(u"GA stdout: {0}".format(to_text(stdout)), host=self._host)
+ display.vvv(u"GA stderr: {0}".format(to_text(stderr)), host=self._host)
+
+ return result_status['return']['exitcode'], stdout, stderr
+
+ def put_file(self, in_path, out_path):
+ ''' transfer a file from local to domain '''
+ super(Connection, self).put_file(in_path, out_path)
+ display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._host)
+
+ if not exists(to_bytes(in_path, errors='surrogate_or_strict')):
+ raise AnsibleFileNotFound(
+ "file or module does not exist: %s" % in_path)
+
+ request_handle = {
+ 'execute': 'guest-file-open',
+ 'arguments': {
+ 'path': out_path,
+ 'mode': 'wb+'
+ }
+ }
+ request_handle_json = json.dumps(request_handle)
+
+ display.vvv(u"GA send: {0}".format(request_handle_json), host=self._host)
+
+ result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_handle), host=self._host)
+
+ # TODO(odyssey4me):
+ # Handle exception for file/path IOError
+ with open(to_bytes(in_path, errors='surrogate_or_strict'), 'rb') as in_file:
+ for chunk in iter(partial(in_file.read, BUFSIZE), b''):
+ try:
+ request_write = {
+ 'execute': 'guest-file-write',
+ 'arguments': {
+ 'handle': result_handle['return'],
+ 'buf-b64': base64.b64encode(chunk).decode()
+ }
+ }
+ request_write_json = json.dumps(request_write)
+
+ display.vvvvv(u"GA send: {0}".format(request_write_json), host=self._host)
+
+ result_write = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_write_json, 5, 0))
+
+ display.vvvvv(u"GA return: {0}".format(result_write), host=self._host)
+
+ except Exception:
+ traceback.print_exc()
+ raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path))
+
+ request_close = {
+ 'execute': 'guest-file-close',
+ 'arguments': {
+ 'handle': result_handle['return']
+ }
+ }
+ request_close_json = json.dumps(request_close)
+
+ display.vvv(u"GA send: {0}".format(request_close_json), host=self._host)
+
+ result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_close), host=self._host)
+
+ def fetch_file(self, in_path, out_path):
+ ''' fetch a file from domain to local '''
+ super(Connection, self).fetch_file(in_path, out_path)
+ display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._host)
+
+ request_handle = {
+ 'execute': 'guest-file-open',
+ 'arguments': {
+ 'path': in_path,
+ 'mode': 'r'
+ }
+ }
+ request_handle_json = json.dumps(request_handle)
+
+ display.vvv(u"GA send: {0}".format(request_handle_json), host=self._host)
+
+ result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_handle), host=self._host)
+
+ request_read = {
+ 'execute': 'guest-file-read',
+ 'arguments': {
+ 'handle': result_handle['return'],
+ 'count': BUFSIZE
+ }
+ }
+ request_read_json = json.dumps(request_read)
+
+ display.vvv(u"GA send: {0}".format(request_read_json), host=self._host)
+
+ with open(to_bytes(out_path, errors='surrogate_or_strict'), 'wb+') as out_file:
+ try:
+ result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, 5, 0))
+ display.vvvvv(u"GA return: {0}".format(result_read), host=self._host)
+ out_file.write(base64.b64decode(result_read['return']['buf-b64']))
+ while not result_read['return']['eof']:
+ result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, 5, 0))
+ display.vvvvv(u"GA return: {0}".format(result_read), host=self._host)
+ out_file.write(base64.b64decode(result_read['return']['buf-b64']))
+
+ except Exception:
+ traceback.print_exc()
+ raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path))
+
+ request_close = {
+ 'execute': 'guest-file-close',
+ 'arguments': {
+ 'handle': result_handle['return']
+ }
+ }
+ request_close_json = json.dumps(request_close)
+
+ display.vvv(u"GA send: {0}".format(request_close_json), host=self._host)
+
+ result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, 5, 0))
+
+ display.vvv(u"GA return: {0}".format(result_close), host=self._host)
+
+ def close(self):
+ ''' terminate the connection; nothing to do here '''
+ super(Connection, self).close()
+ self._connected = False
diff --git a/ansible_collections/community/libvirt/plugins/doc_fragments/__init__.py b/ansible_collections/community/libvirt/plugins/doc_fragments/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/doc_fragments/__init__.py
diff --git a/ansible_collections/community/libvirt/plugins/doc_fragments/requirements.py b/ansible_collections/community/libvirt/plugins/doc_fragments/requirements.py
new file mode 100644
index 000000000..a181ed68b
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/doc_fragments/requirements.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+
+
+class ModuleDocFragment(object):
+ DOCUMENTATION = r"""
+options: {}
+requirements:
+ - python >= 2.6
+ - libvirt python bindings
+ """
diff --git a/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py b/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py
new file mode 100644
index 000000000..a607299bf
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/doc_fragments/virt.py
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+
+
+class ModuleDocFragment(object):
+ OPTIONS_GUEST = r"""
+options:
+ name:
+ description:
+ - name of the guest VM being managed. Note that VM must be previously
+ defined with xml.
+ - This option is required unless I(command) is C(list_vms) or C(info).
+ type: str
+ aliases:
+ - guest
+ """
+
+ OPTIONS_STATE = r"""
+options:
+ state:
+ description:
+ - Note that there may be some lag for state requests like C(shutdown)
+ since these refer only to VM states. After starting a guest, it may not
+ be immediately accessible.
+ state and command are mutually exclusive except when command=list_vms. In
+ this case all VMs in specified state will be listed.
+ choices: [ destroyed, paused, running, shutdown ]
+ type: str
+ """
+
+ OPTIONS_COMMAND = r"""
+options:
+ command:
+ description:
+ - In addition to state management, various non-idempotent commands are available.
+ choices: [ create, define, destroy, freemem, get_xml, info, list_vms, nodeinfo, pause, shutdown, start, status, stop, undefine, unpause, virttype ]
+ type: str
+ """
+
+ OPTIONS_AUTOSTART = r"""
+options:
+ autostart:
+ description:
+ - Start VM at host startup.
+ type: bool
+ """
+
+ OPTIONS_URI = r"""
+options:
+ uri:
+ description:
+ - Libvirt connection uri.
+ default: qemu:///system
+ type: str
+ """
+
+ OPTIONS_XML = r"""
+options:
+ xml:
+ description:
+ - XML document used with the define command.
+ - Must be raw XML content using C(lookup). XML cannot be reference to a file.
+ type: str
+ """
diff --git a/ansible_collections/community/libvirt/plugins/inventory/__init__.py b/ansible_collections/community/libvirt/plugins/inventory/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/inventory/__init__.py
diff --git a/ansible_collections/community/libvirt/plugins/inventory/libvirt.py b/ansible_collections/community/libvirt/plugins/inventory/libvirt.py
new file mode 100644
index 000000000..903870cc0
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/inventory/libvirt.py
@@ -0,0 +1,212 @@
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+DOCUMENTATION = r'''
+name: libvirt
+extends_documentation_fragment:
+ - constructed
+ - community.libvirt.requirements
+short_description: Libvirt inventory source
+description:
+ - Get libvirt guests in an inventory source.
+author:
+ - Dave Olsthoorn (@daveol) <dave@bewaar.me>
+version_added: "2.10.0"
+options:
+ plugin:
+ description: Token that ensures this is a source file for the 'libvirt' plugin.
+ required: True
+ choices: ['libvirt', 'community.libvirt.libvirt']
+ uri:
+ description: Libvirt Connection URI
+ required: True
+ type: str
+ inventory_hostname:
+ description: |
+ What to register as the inventory hostname.
+ If set to 'uuid' the uuid of the server will be used and a
+ group will be created for the server name.
+ If set to 'name' the name of the server will be used unless
+ there are more than one server with the same name in which
+ case the 'uuid' logic will be used.
+ Default is to do 'name'.
+ type: string
+ choices:
+ - name
+ - uuid
+ default: "name"
+'''
+
+EXAMPLES = r'''
+# Connect to lxc host
+plugin: community.libvirt.libvirt
+uri: 'lxc:///'
+
+# Connect to qemu
+plugin: community.libvirt.libvirt
+uri: 'qemu:///system'
+'''
+
+from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
+from ansible.errors import AnsibleError
+from ansible.module_utils.six import raise_from
+
+try:
+ import libvirt
+except ImportError as imp_exc:
+ LIBVIRT_IMPORT_ERROR = imp_exc
+else:
+ LIBVIRT_IMPORT_ERROR = None
+
+VIRDOMAINSTATE = ["nostate", "running", "blocked", "paused", "shutdown", "shutoff", "crashed", "pmsuspended", "last"]
+
+
+class InventoryModule(BaseInventoryPlugin, Constructable):
+ NAME = 'community.libvirt.libvirt'
+
+ def parse(self, inventory, loader, path, cache=True):
+ if LIBVIRT_IMPORT_ERROR:
+ raise_from(
+ AnsibleError('libvirt python bindings must be installed to use this plugin'),
+ LIBVIRT_IMPORT_ERROR)
+
+ super(InventoryModule, self).parse(
+ inventory,
+ loader,
+ path,
+ cache=cache
+ )
+
+ config_data = self._read_config_data(path)
+
+ # set _options from config data
+ self._consume_options(config_data)
+
+ uri = self.get_option('uri')
+ if not uri:
+ raise AnsibleError("hypervisor uri not given")
+
+ connection = libvirt.open(uri)
+ if not connection:
+ raise AnsibleError("hypervisor connection failure")
+
+ # TODO(daveol)
+ # make using connection plugins optional
+ connection_plugin = dict({
+ 'LXC': 'community.libvirt.libvirt_lxc',
+ 'QEMU': 'community.libvirt.libvirt_qemu'
+ }).get(connection.getType())
+
+ for server in connection.listAllDomains():
+ inventory_hostname = dict({
+ 'uuid': server.UUIDString(),
+ 'name': server.name()
+ }).get(
+ self.get_option('inventory_hostname')
+ )
+
+ inventory_hostname_alias = dict({
+ 'name': server.UUIDString(),
+ 'uuid': server.name()
+ }).get(
+ self.get_option('inventory_hostname')
+ )
+
+ # TODO(daveol): Fix "Invalid characters were found in group names"
+ # This warning is generated because of uuid's
+ self.inventory.add_host(inventory_hostname)
+ self.inventory.add_group(inventory_hostname_alias)
+ self.inventory.add_child(inventory_hostname_alias, inventory_hostname)
+
+ if connection_plugin is not None:
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'ansible_libvirt_uri',
+ uri
+ )
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'ansible_connection',
+ connection_plugin
+ )
+
+ try:
+ domain = connection.lookupByUUIDString(server.UUIDString())
+ except libvirt.libvirtError as e:
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'ERROR',
+ str(e)
+ )
+ else:
+ _domain_state, _domain_maxmem, _domain_mem, _domain_cpus, _domain_cput = domain.info()
+ domain_info = {"state_number": _domain_state,
+ "state": VIRDOMAINSTATE[_domain_state],
+ "maxMem_kb": _domain_maxmem,
+ "memory_kb": _domain_mem,
+ "nrVirtCpu": _domain_cpus,
+ "cpuTime_ns": _domain_cput}
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'info',
+ domain_info
+ )
+
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'xml_desc',
+ domain.XMLDesc()
+ )
+
+ # This needs the guest powered on, 'qemu-guest-agent' installed and the org.qemu.guest_agent.0 channel configured.
+ try:
+ # type==0 returns all types (users, os, timezone, hostname, filesystem, disks, interfaces)
+ domain_guestInfo = domain.guestInfo(types=0)
+ except libvirt.libvirtError as e:
+ domain_guestInfo = {"error": str(e)}
+ finally:
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'guest_info',
+ domain_guestInfo
+ )
+
+ # This needs the guest powered on, 'qemu-guest-agent' installed and the org.qemu.guest_agent.0 channel configured.
+ try:
+ domain_interfaceAddresses = domain.interfaceAddresses(source=libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT)
+ except libvirt.libvirtError as e:
+ domain_interfaceAddresses = {"error": str(e)}
+ finally:
+ self.inventory.set_variable(
+ inventory_hostname,
+ 'interface_addresses',
+ domain_interfaceAddresses
+ )
+
+ # Get variables for compose
+ variables = self.inventory.hosts[inventory_hostname].get_vars()
+
+ # Set composed variables
+ self._set_composite_vars(
+ self.get_option('compose'),
+ variables,
+ inventory_hostname,
+ self.get_option('strict'),
+ )
+
+ # Add host to composed groups
+ self._add_host_to_composed_groups(
+ self.get_option('groups'),
+ variables,
+ inventory_hostname,
+ self.get_option('strict'),
+ )
+
+ # Add host to keyed groups
+ self._add_host_to_keyed_groups(
+ self.get_option('keyed_groups'),
+ variables,
+ inventory_hostname,
+ self.get_option('strict'),
+ )
diff --git a/ansible_collections/community/libvirt/plugins/modules/virt.py b/ansible_collections/community/libvirt/plugins/modules/virt.py
new file mode 100644
index 000000000..bbc2add06
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/modules/virt.py
@@ -0,0 +1,563 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright: (c) 2007, 2012 Red Hat, Inc
+# Michael DeHaan <michael.dehaan@gmail.com>
+# Seth Vidal <skvidal@fedoraproject.org>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+
+DOCUMENTATION = '''
+---
+module: virt
+short_description: Manages virtual machines supported by libvirt
+description:
+ - Manages virtual machines supported by I(libvirt).
+extends_documentation_fragment:
+ - community.libvirt.virt.options_uri
+ - community.libvirt.virt.options_xml
+ - community.libvirt.virt.options_guest
+ - community.libvirt.virt.options_autostart
+ - community.libvirt.virt.options_state
+ - community.libvirt.virt.options_command
+ - community.libvirt.requirements
+author:
+ - Ansible Core Team
+ - Michael DeHaan
+ - Seth Vidal (@skvidal)
+'''
+
+EXAMPLES = '''
+# a playbook task line:
+- name: Start a VM
+ community.libvirt.virt:
+ name: alpha
+ state: running
+
+# /usr/bin/ansible invocations
+# ansible host -m virt -a "name=alpha command=status"
+# ansible host -m virt -a "name=alpha command=get_xml"
+# ansible host -m virt -a "name=alpha command=create uri=lxc:///"
+
+# defining and launching an LXC guest
+- name: Define a VM
+ community.libvirt.virt:
+ command: define
+ xml: "{{ lookup('template', 'container-template.xml.j2') }}"
+ uri: 'lxc:///'
+- name: start vm
+ community.libvirt.virt:
+ name: foo
+ state: running
+ uri: 'lxc:///'
+
+# setting autostart on a qemu VM (default uri)
+- name: Set autostart for a VM
+ community.libvirt.virt:
+ name: foo
+ autostart: yes
+
+# Defining a VM and making is autostart with host. VM will be off after this task
+- name: Define vm from xml and set autostart
+ community.libvirt.virt:
+ command: define
+ xml: "{{ lookup('template', 'vm_template.xml.j2') }}"
+ autostart: yes
+
+# Listing VMs
+- name: List all VMs
+ community.libvirt.virt:
+ command: list_vms
+ register: all_vms
+
+- name: List only running VMs
+ community.libvirt.virt:
+ command: list_vms
+ state: running
+ register: running_vms
+'''
+
+RETURN = '''
+# for list_vms command
+list_vms:
+ description: The list of vms defined on the remote system.
+ type: list
+ returned: success
+ sample: [
+ "build.example.org",
+ "dev.example.org"
+ ]
+# for status command
+status:
+ description: The status of the VM, among running, crashed, paused and shutdown.
+ type: str
+ sample: "success"
+ returned: success
+'''
+
+import traceback
+
+try:
+ import libvirt
+ from libvirt import libvirtError
+except ImportError:
+ HAS_VIRT = False
+else:
+ HAS_VIRT = True
+
+import re
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils._text import to_native
+
+
+VIRT_FAILED = 1
+VIRT_SUCCESS = 0
+VIRT_UNAVAILABLE = 2
+
+ALL_COMMANDS = []
+VM_COMMANDS = ['create', 'define', 'destroy', 'get_xml', 'pause', 'shutdown', 'status', 'start', 'stop', 'undefine', 'unpause']
+HOST_COMMANDS = ['freemem', 'info', 'list_vms', 'nodeinfo', 'virttype']
+ALL_COMMANDS.extend(VM_COMMANDS)
+ALL_COMMANDS.extend(HOST_COMMANDS)
+
+VIRT_STATE_NAME_MAP = {
+ 0: 'running',
+ 1: 'running',
+ 2: 'running',
+ 3: 'paused',
+ 4: 'shutdown',
+ 5: 'shutdown',
+ 6: 'crashed',
+}
+
+
+class VMNotFound(Exception):
+ pass
+
+
+class LibvirtConnection(object):
+
+ def __init__(self, uri, module):
+
+ self.module = module
+
+ cmd = "uname -r"
+ rc, stdout, stderr = self.module.run_command(cmd)
+
+ if "xen" in stdout:
+ conn = libvirt.open(None)
+ elif "esx" in uri:
+ auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT], [], None]
+ conn = libvirt.openAuth(uri, auth)
+ else:
+ conn = libvirt.open(uri)
+
+ if not conn:
+ raise Exception("hypervisor connection failure")
+
+ self.conn = conn
+
+ def find_vm(self, vmid):
+ """
+ Extra bonus feature: vmid = -1 returns a list of everything
+ """
+
+ vms = self.conn.listAllDomains()
+
+ if vmid == -1:
+ return vms
+
+ for vm in vms:
+ if vm.name() == vmid:
+ return vm
+
+ raise VMNotFound("virtual machine %s not found" % vmid)
+
+ def shutdown(self, vmid):
+ return self.find_vm(vmid).shutdown()
+
+ def pause(self, vmid):
+ return self.suspend(vmid)
+
+ def unpause(self, vmid):
+ return self.resume(vmid)
+
+ def suspend(self, vmid):
+ return self.find_vm(vmid).suspend()
+
+ def resume(self, vmid):
+ return self.find_vm(vmid).resume()
+
+ def create(self, vmid):
+ return self.find_vm(vmid).create()
+
+ def destroy(self, vmid):
+ return self.find_vm(vmid).destroy()
+
+ def undefine(self, vmid):
+ return self.find_vm(vmid).undefine()
+
+ def get_status2(self, vm):
+ state = vm.info()[0]
+ return VIRT_STATE_NAME_MAP.get(state, "unknown")
+
+ def get_status(self, vmid):
+ state = self.find_vm(vmid).info()[0]
+ return VIRT_STATE_NAME_MAP.get(state, "unknown")
+
+ def nodeinfo(self):
+ return self.conn.getInfo()
+
+ def get_type(self):
+ return self.conn.getType()
+
+ def get_xml(self, vmid):
+ vm = self.conn.lookupByName(vmid)
+ return vm.XMLDesc(0)
+
+ def get_maxVcpus(self, vmid):
+ vm = self.conn.lookupByName(vmid)
+ return vm.maxVcpus()
+
+ def get_maxMemory(self, vmid):
+ vm = self.conn.lookupByName(vmid)
+ return vm.maxMemory()
+
+ def getFreeMemory(self):
+ return self.conn.getFreeMemory()
+
+ def get_autostart(self, vmid):
+ vm = self.conn.lookupByName(vmid)
+ return vm.autostart()
+
+ def set_autostart(self, vmid, val):
+ vm = self.conn.lookupByName(vmid)
+ return vm.setAutostart(val)
+
+ def define_from_xml(self, xml):
+ return self.conn.defineXML(xml)
+
+
+class Virt(object):
+
+ def __init__(self, uri, module):
+ self.module = module
+ self.uri = uri
+
+ def __get_conn(self):
+ self.conn = LibvirtConnection(self.uri, self.module)
+ return self.conn
+
+ def get_vm(self, vmid):
+ self.__get_conn()
+ return self.conn.find_vm(vmid)
+
+ def state(self):
+ vms = self.list_vms()
+ state = []
+ for vm in vms:
+ state_blurb = self.conn.get_status(vm)
+ state.append("%s %s" % (vm, state_blurb))
+ return state
+
+ def info(self):
+ vms = self.list_vms()
+ info = dict()
+ for vm in vms:
+ data = self.conn.find_vm(vm).info()
+ # libvirt returns maxMem, memory, and cpuTime as long()'s, which
+ # xmlrpclib tries to convert to regular int's during serialization.
+ # This throws exceptions, so convert them to strings here and
+ # assume the other end of the xmlrpc connection can figure things
+ # out or doesn't care.
+ info[vm] = dict(
+ state=VIRT_STATE_NAME_MAP.get(data[0], "unknown"),
+ maxMem=str(data[1]),
+ memory=str(data[2]),
+ nrVirtCpu=data[3],
+ cpuTime=str(data[4]),
+ autostart=self.conn.get_autostart(vm),
+ )
+
+ return info
+
+ def nodeinfo(self):
+ self.__get_conn()
+ data = self.conn.nodeinfo()
+ info = dict(
+ cpumodel=str(data[0]),
+ phymemory=str(data[1]),
+ cpus=str(data[2]),
+ cpumhz=str(data[3]),
+ numanodes=str(data[4]),
+ sockets=str(data[5]),
+ cpucores=str(data[6]),
+ cputhreads=str(data[7])
+ )
+ return info
+
+ def list_vms(self, state=None):
+ self.conn = self.__get_conn()
+ vms = self.conn.find_vm(-1)
+ results = []
+ for x in vms:
+ try:
+ if state:
+ vmstate = self.conn.get_status2(x)
+ if vmstate == state:
+ results.append(x.name())
+ else:
+ results.append(x.name())
+ except Exception:
+ pass
+ return results
+
+ def virttype(self):
+ return self.__get_conn().get_type()
+
+ def autostart(self, vmid, as_flag):
+ self.conn = self.__get_conn()
+ # Change autostart flag only if needed
+ if self.conn.get_autostart(vmid) != as_flag:
+ self.conn.set_autostart(vmid, as_flag)
+ return True
+
+ return False
+
+ def freemem(self):
+ self.conn = self.__get_conn()
+ return self.conn.getFreeMemory()
+
+ def shutdown(self, vmid):
+ """ Make the machine with the given vmid stop running. Whatever that takes. """
+ self.__get_conn()
+ self.conn.shutdown(vmid)
+ return 0
+
+ def pause(self, vmid):
+ """ Pause the machine with the given vmid. """
+
+ self.__get_conn()
+ return self.conn.suspend(vmid)
+
+ def unpause(self, vmid):
+ """ Unpause the machine with the given vmid. """
+
+ self.__get_conn()
+ return self.conn.resume(vmid)
+
+ def create(self, vmid):
+ """ Start the machine via the given vmid """
+
+ self.__get_conn()
+ return self.conn.create(vmid)
+
+ def start(self, vmid):
+ """ Start the machine via the given id/name """
+
+ self.__get_conn()
+ return self.conn.create(vmid)
+
+ def destroy(self, vmid):
+ """ Pull the virtual power from the virtual domain, giving it virtually no time to virtually shut down. """
+ self.__get_conn()
+ return self.conn.destroy(vmid)
+
+ def undefine(self, vmid):
+ """ Stop a domain, and then wipe it from the face of the earth. (delete disk/config file) """
+
+ self.__get_conn()
+ return self.conn.undefine(vmid)
+
+ def status(self, vmid):
+ """
+ Return a state suitable for server consumption. Aka, codes.py values, not XM output.
+ """
+ self.__get_conn()
+ return self.conn.get_status(vmid)
+
+ def get_xml(self, vmid):
+ """
+ Receive a Vm id as input
+ Return an xml describing vm config returned by a libvirt call
+ """
+
+ self.__get_conn()
+ return self.conn.get_xml(vmid)
+
+ def get_maxVcpus(self, vmid):
+ """
+ Gets the max number of VCPUs on a guest
+ """
+
+ self.__get_conn()
+ return self.conn.get_maxVcpus(vmid)
+
+ def get_max_memory(self, vmid):
+ """
+ Gets the max memory on a guest
+ """
+
+ self.__get_conn()
+ return self.conn.get_MaxMemory(vmid)
+
+ def define(self, xml):
+ """
+ Define a guest with the given xml
+ """
+ self.__get_conn()
+ return self.conn.define_from_xml(xml)
+
+
+def core(module):
+
+ state = module.params.get('state', None)
+ autostart = module.params.get('autostart', None)
+ guest = module.params.get('name', None)
+ command = module.params.get('command', None)
+ uri = module.params.get('uri', None)
+ xml = module.params.get('xml', None)
+
+ v = Virt(uri, module)
+ res = dict()
+
+ if state and command == 'list_vms':
+ res = v.list_vms(state=state)
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ if autostart is not None and command != 'define':
+ if not guest:
+ module.fail_json(msg="autostart requires 1 argument: name")
+ try:
+ v.get_vm(guest)
+ except VMNotFound:
+ module.fail_json(msg="domain %s not found" % guest)
+ res['changed'] = v.autostart(guest, autostart)
+ if not command and not state:
+ return VIRT_SUCCESS, res
+
+ if state:
+ if not guest:
+ module.fail_json(msg="state change requires a guest specified")
+
+ if state == 'running':
+ if v.status(guest) == 'paused':
+ res['changed'] = True
+ res['msg'] = v.unpause(guest)
+ elif v.status(guest) != 'running':
+ res['changed'] = True
+ res['msg'] = v.start(guest)
+ elif state == 'shutdown':
+ if v.status(guest) != 'shutdown':
+ res['changed'] = True
+ res['msg'] = v.shutdown(guest)
+ elif state == 'destroyed':
+ if v.status(guest) != 'shutdown':
+ res['changed'] = True
+ res['msg'] = v.destroy(guest)
+ elif state == 'paused':
+ if v.status(guest) == 'running':
+ res['changed'] = True
+ res['msg'] = v.pause(guest)
+ else:
+ module.fail_json(msg="unexpected state")
+
+ return VIRT_SUCCESS, res
+
+ if command:
+ if command in VM_COMMANDS:
+ if command == 'define':
+ if not xml:
+ module.fail_json(msg="define requires xml argument")
+ if guest:
+ # there might be a mismatch between quest 'name' in the module and in the xml
+ module.warn("'xml' is given - ignoring 'name'")
+ try:
+ domain_name = re.search('<name>(.*)</name>', xml).groups()[0]
+ except AttributeError:
+ module.fail_json(msg="Could not find domain 'name' in xml")
+
+ # From libvirt docs (https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDefineXML):
+ # -- A previous definition for this domain would be overridden if it already exists.
+ #
+ # In real world testing with libvirt versions 1.2.17-13, 2.0.0-10 and 3.9.0-14
+ # on qemu and lxc domains results in:
+ # operation failed: domain '<name>' already exists with <uuid>
+ #
+ # In case a domain would be indeed overwritten, we should protect idempotency:
+ try:
+ existing_domain_xml = v.get_vm(domain_name).XMLDesc(
+ libvirt.VIR_DOMAIN_XML_INACTIVE
+ )
+ except VMNotFound:
+ existing_domain_xml = None
+ try:
+ domain = v.define(xml)
+ if existing_domain_xml:
+ # if we are here, then libvirt redefined existing domain as the doc promised
+ if existing_domain_xml != domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE):
+ res = {'changed': True, 'change_reason': 'config changed'}
+ else:
+ res = {'changed': True, 'created': domain.name()}
+ except libvirtError as e:
+ if e.get_error_code() != 9: # 9 means 'domain already exists' error
+ module.fail_json(msg='libvirtError: %s' % e.get_error_message())
+ if autostart is not None and v.autostart(domain_name, autostart):
+ res = {'changed': True, 'change_reason': 'autostart'}
+
+ elif not guest:
+ module.fail_json(msg="%s requires 1 argument: guest" % command)
+ else:
+ res = getattr(v, command)(guest)
+ if not isinstance(res, dict):
+ res = {command: res}
+
+ return VIRT_SUCCESS, res
+
+ elif hasattr(v, command):
+ res = getattr(v, command)()
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ else:
+ module.fail_json(msg="Command %s not recognized" % command)
+
+ module.fail_json(msg="expected state or command parameter to be specified")
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(
+ name=dict(type='str', aliases=['guest']),
+ state=dict(type='str', choices=['destroyed', 'paused', 'running', 'shutdown']),
+ autostart=dict(type='bool'),
+ command=dict(type='str', choices=ALL_COMMANDS),
+ uri=dict(type='str', default='qemu:///system'),
+ xml=dict(type='str'),
+ ),
+ )
+
+ if not HAS_VIRT:
+ module.fail_json(msg='The `libvirt` module is not importable. Check the requirements.')
+
+ rc = VIRT_SUCCESS
+ try:
+ rc, result = core(module)
+ except Exception as e:
+ module.fail_json(msg=to_native(e), exception=traceback.format_exc())
+
+ if rc != 0: # something went wrong emit the msg
+ module.fail_json(rc=rc, msg=result)
+ else:
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/community/libvirt/plugins/modules/virt_net.py b/ansible_collections/community/libvirt/plugins/modules/virt_net.py
new file mode 100644
index 000000000..7492cac79
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/modules/virt_net.py
@@ -0,0 +1,647 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2015, Maciej Delmanowski <drybjed@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+
+DOCUMENTATION = '''
+---
+module: virt_net
+author: "Maciej Delmanowski (@drybjed)"
+short_description: Manage libvirt network configuration
+description:
+ - Manage I(libvirt) networks.
+options:
+ name:
+ aliases: ['network']
+ description:
+ - Name of the network being managed. Note that network must be previously
+ defined with xml.
+ type: str
+ state:
+ choices: [ "active", "inactive", "present", "absent" ]
+ description:
+ - Specify which state you want a network to be in.
+ If 'active', network will be started.
+ If 'present', ensure that network is present but do not change its
+ state; if it is missing, you need to specify xml argument.
+ If 'inactive', network will be stopped.
+ If 'undefined' or 'absent', network will be removed from I(libvirt) configuration.
+ type: str
+ command:
+ choices: [ "define", "create", "start", "stop", "destroy",
+ "undefine", "get_xml", "list_nets", "facts",
+ "info", "status", "modify"]
+ description:
+ - In addition to state management, various non-idempotent commands are available.
+ See examples.
+ Modify was added in Ansible version 2.1.
+ type: str
+ autostart:
+ type: bool
+ description:
+ - Specify if a given network should be started automatically on system boot.
+extends_documentation_fragment:
+ - community.libvirt.virt.options_uri
+ - community.libvirt.virt.options_xml
+ - community.libvirt.requirements
+requirements:
+ - "python-lxml"
+'''
+
+EXAMPLES = '''
+- name: Define a new network
+ community.libvirt.virt_net:
+ command: define
+ name: br_nat
+ xml: '{{ lookup("template", "network/bridge.xml.j2") }}'
+
+- name: Start a network
+ community.libvirt.virt_net:
+ command: create
+ name: br_nat
+
+- name: List available networks
+ community.libvirt.virt_net:
+ command: list_nets
+
+- name: Get XML data of a specified network
+ community.libvirt.virt_net:
+ command: get_xml
+ name: br_nat
+
+- name: Stop a network
+ community.libvirt.virt_net:
+ command: destroy
+ name: br_nat
+
+- name: Undefine a network
+ community.libvirt.virt_net:
+ command: undefine
+ name: br_nat
+
+# Gather facts about networks
+# Facts will be available as 'ansible_libvirt_networks'
+- name: Gather facts about networks
+ community.libvirt.virt_net:
+ command: facts
+
+- name: Gather information about network managed by 'libvirt' remotely using uri
+ community.libvirt.virt_net:
+ command: info
+ uri: '{{ item }}'
+ with_items: '{{ libvirt_uris }}'
+ register: networks
+
+- name: Ensure that a network is active (needs to be defined and built first)
+ community.libvirt.virt_net:
+ state: active
+ name: br_nat
+
+- name: Ensure that a network is inactive
+ community.libvirt.virt_net:
+ state: inactive
+ name: br_nat
+
+- name: Ensure that a given network will be started at boot
+ community.libvirt.virt_net:
+ autostart: yes
+ name: br_nat
+
+- name: Disable autostart for a given network
+ community.libvirt.virt_net:
+ autostart: no
+ name: br_nat
+
+- name: Add a new host in the dhcp pool
+ community.libvirt.virt_net:
+ name: br_nat
+ command: modify
+ xml: "<host mac='FC:C2:33:00:6c:3c' name='my_vm' ip='192.168.122.30'/>"
+'''
+
+try:
+ import libvirt
+except ImportError:
+ HAS_VIRT = False
+else:
+ HAS_VIRT = True
+
+try:
+ from lxml import etree
+except ImportError:
+ HAS_XML = False
+else:
+ HAS_XML = True
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils._text import to_native
+
+
+VIRT_FAILED = 1
+VIRT_SUCCESS = 0
+VIRT_UNAVAILABLE = 2
+
+ALL_COMMANDS = []
+ENTRY_COMMANDS = ['create', 'status', 'start', 'stop',
+ 'undefine', 'destroy', 'get_xml', 'define',
+ 'modify']
+HOST_COMMANDS = ['list_nets', 'facts', 'info']
+ALL_COMMANDS.extend(ENTRY_COMMANDS)
+ALL_COMMANDS.extend(HOST_COMMANDS)
+
+ENTRY_STATE_ACTIVE_MAP = {
+ 0: "inactive",
+ 1: "active"
+}
+
+ENTRY_STATE_AUTOSTART_MAP = {
+ 0: "no",
+ 1: "yes"
+}
+
+ENTRY_STATE_PERSISTENT_MAP = {
+ 0: "no",
+ 1: "yes"
+}
+
+
+class EntryNotFound(Exception):
+ pass
+
+
+class LibvirtConnection(object):
+
+ def __init__(self, uri, module):
+
+ self.module = module
+
+ conn = libvirt.open(uri)
+
+ if not conn:
+ raise Exception("hypervisor connection failure")
+
+ self.conn = conn
+
+ def find_entry(self, entryid):
+ if entryid == -1: # Get active entries
+ names = self.conn.listNetworks() + self.conn.listDefinedNetworks()
+ return [self.conn.networkLookupByName(n) for n in names]
+
+ try:
+ return self.conn.networkLookupByName(entryid)
+ except libvirt.libvirtError as e:
+ if e.get_error_code() == libvirt.VIR_ERR_NO_NETWORK:
+ raise EntryNotFound("network %s not found" % entryid)
+ raise
+
+ def create(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).create()
+ else:
+ try:
+ state = self.find_entry(entryid).isActive()
+ except Exception:
+ return self.module.exit_json(changed=True)
+ if not state:
+ return self.module.exit_json(changed=True)
+
+ def modify(self, entryid, xml):
+ network = self.find_entry(entryid)
+ # identify what type of entry is given in the xml
+ new_data = etree.fromstring(xml)
+ old_data = etree.fromstring(network.XMLDesc(0))
+ if new_data.tag == 'host':
+ mac_addr = new_data.get('mac')
+ hosts = old_data.xpath('/network/ip/dhcp/host')
+ # find the one mac we're looking for
+ host = None
+ for h in hosts:
+ if h.get('mac') == mac_addr:
+ host = h
+ break
+ if host is None:
+ # add the host
+ if not self.module.check_mode:
+ if network.isActive():
+ res = network.update(libvirt.VIR_NETWORK_UPDATE_COMMAND_ADD_LAST,
+ libvirt.VIR_NETWORK_SECTION_IP_DHCP_HOST,
+ -1, xml, libvirt.VIR_NETWORK_UPDATE_AFFECT_LIVE | libvirt.VIR_NETWORK_UPDATE_AFFECT_CONFIG)
+ else:
+ res = network.update(libvirt.VIR_NETWORK_UPDATE_COMMAND_ADD_LAST,
+ libvirt.VIR_NETWORK_SECTION_IP_DHCP_HOST,
+ -1, xml, libvirt.VIR_NETWORK_UPDATE_AFFECT_CONFIG)
+ else:
+ # pretend there was a change
+ res = 0
+ if res == 0:
+ return True
+ else:
+ # change the host
+ if host.get('name') == new_data.get('name') and host.get('ip') == new_data.get('ip'):
+ return False
+ else:
+ if not self.module.check_mode:
+ if network.isActive():
+ res = network.update(libvirt.VIR_NETWORK_UPDATE_COMMAND_MODIFY,
+ libvirt.VIR_NETWORK_SECTION_IP_DHCP_HOST,
+ -1, xml, libvirt.VIR_NETWORK_UPDATE_AFFECT_LIVE | libvirt.VIR_NETWORK_UPDATE_AFFECT_CONFIG)
+ else:
+ res = network.update(libvirt.VIR_NETWORK_UPDATE_COMMAND_MODIFY,
+ libvirt.VIR_NETWORK_SECTION_IP_DHCP_HOST,
+ -1, xml, libvirt.VIR_NETWORK_UPDATE_AFFECT_CONFIG)
+ else:
+ # pretend there was a change
+ res = 0
+ if res == 0:
+ return True
+ # command, section, parentIndex, xml, flags=0
+ self.module.fail_json(msg='updating this is not supported yet %s' % to_native(xml))
+
+ def destroy(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).destroy()
+ else:
+ if self.find_entry(entryid).isActive():
+ return self.module.exit_json(changed=True)
+
+ def undefine(self, entryid):
+ entry = None
+ try:
+ entry = self.find_entry(entryid)
+ found = True
+ except EntryNotFound:
+ found = False
+
+ if found:
+ return self.find_entry(entryid).undefine()
+
+ if self.module.check_mode:
+ return self.module.exit_json(changed=found)
+
+ def get_status2(self, entry):
+ state = entry.isActive()
+ return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
+
+ def get_status(self, entryid):
+ if not self.module.check_mode:
+ state = self.find_entry(entryid).isActive()
+ return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
+ else:
+ try:
+ state = self.find_entry(entryid).isActive()
+ return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
+ except Exception:
+ return ENTRY_STATE_ACTIVE_MAP.get("inactive", "unknown")
+
+ def get_uuid(self, entryid):
+ return self.find_entry(entryid).UUIDString()
+
+ def get_xml(self, entryid):
+ return self.find_entry(entryid).XMLDesc(0)
+
+ def get_forward(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/network/forward')[0].get('mode')
+ except Exception:
+ raise ValueError('Forward mode not specified')
+ return result
+
+ def get_domain(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/network/domain')[0].get('name')
+ except Exception:
+ raise ValueError('Domain not specified')
+ return result
+
+ def get_macaddress(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/network/mac')[0].get('address')
+ except Exception:
+ raise ValueError('MAC address not specified')
+ return result
+
+ def get_autostart(self, entryid):
+ state = self.find_entry(entryid).autostart()
+ return ENTRY_STATE_AUTOSTART_MAP.get(state, "unknown")
+
+ def get_autostart2(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).autostart()
+ else:
+ try:
+ return self.find_entry(entryid).autostart()
+ except Exception:
+ return self.module.exit_json(changed=True)
+
+ def set_autostart(self, entryid, val):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).setAutostart(val)
+ else:
+ try:
+ state = self.find_entry(entryid).autostart()
+ except Exception:
+ return self.module.exit_json(changed=True)
+ if bool(state) != val:
+ return self.module.exit_json(changed=True)
+
+ def get_bridge(self, entryid):
+ return self.find_entry(entryid).bridgeName()
+
+ def get_persistent(self, entryid):
+ state = self.find_entry(entryid).isPersistent()
+ return ENTRY_STATE_PERSISTENT_MAP.get(state, "unknown")
+
+ def get_dhcp_leases(self, entryid):
+ network = self.find_entry(entryid)
+ return network.DHCPLeases()
+
+ def define_from_xml(self, entryid, xml):
+ if not self.module.check_mode:
+ return self.conn.networkDefineXML(xml)
+ else:
+ try:
+ self.find_entry(entryid)
+ except Exception:
+ return self.module.exit_json(changed=True)
+
+
+class VirtNetwork(object):
+
+ def __init__(self, uri, module):
+ self.module = module
+ self.uri = uri
+ self.conn = LibvirtConnection(self.uri, self.module)
+
+ def get_net(self, entryid):
+ return self.conn.find_entry(entryid)
+
+ def list_nets(self, state=None):
+ results = []
+ for entry in self.conn.find_entry(-1):
+ if state:
+ if state == self.conn.get_status2(entry):
+ results.append(entry.name())
+ else:
+ results.append(entry.name())
+ return results
+
+ def state(self):
+ results = []
+ for entry in self.list_nets():
+ state_blurb = self.conn.get_status(entry)
+ results.append("%s %s" % (entry, state_blurb))
+ return results
+
+ def autostart(self, entryid):
+ return self.conn.set_autostart(entryid, True)
+
+ def get_autostart(self, entryid):
+ return self.conn.get_autostart2(entryid)
+
+ def set_autostart(self, entryid, state):
+ return self.conn.set_autostart(entryid, state)
+
+ def create(self, entryid):
+ if self.conn.get_status(entryid) == "active":
+ return
+ try:
+ return self.conn.create(entryid)
+ except libvirt.libvirtError as e:
+ if e.get_error_code() == libvirt.VIR_ERR_NETWORK_EXIST:
+ return None
+ raise
+
+ def modify(self, entryid, xml):
+ return self.conn.modify(entryid, xml)
+
+ def start(self, entryid):
+ return self.create(entryid)
+
+ def stop(self, entryid):
+ if self.conn.get_status(entryid) == "active":
+ return self.conn.destroy(entryid)
+
+ def destroy(self, entryid):
+ return self.stop(entryid)
+
+ def undefine(self, entryid):
+ return self.conn.undefine(entryid)
+
+ def status(self, entryid):
+ return self.conn.get_status(entryid)
+
+ def get_xml(self, entryid):
+ return self.conn.get_xml(entryid)
+
+ def define(self, entryid, xml):
+ return self.conn.define_from_xml(entryid, xml)
+
+ def info(self):
+ return self.facts(facts_mode='info')
+
+ def facts(self, name=None, facts_mode='facts'):
+ results = dict()
+ if name:
+ entries = [name]
+ else:
+ entries = self.list_nets()
+ for entry in entries:
+ results[entry] = dict()
+ results[entry]["autostart"] = self.conn.get_autostart(entry)
+ results[entry]["persistent"] = self.conn.get_persistent(entry)
+ results[entry]["state"] = self.conn.get_status(entry)
+ results[entry]["bridge"] = self.conn.get_bridge(entry)
+ results[entry]["uuid"] = self.conn.get_uuid(entry)
+ try:
+ results[entry]["dhcp_leases"] = self.conn.get_dhcp_leases(entry)
+ # not supported on RHEL 6
+ except AttributeError:
+ pass
+
+ try:
+ results[entry]["forward_mode"] = self.conn.get_forward(entry)
+ except ValueError:
+ pass
+
+ try:
+ results[entry]["domain"] = self.conn.get_domain(entry)
+ except ValueError:
+ pass
+
+ try:
+ results[entry]["macaddress"] = self.conn.get_macaddress(entry)
+ except ValueError:
+ pass
+
+ facts = dict()
+ if facts_mode == 'facts':
+ facts["ansible_facts"] = dict()
+ facts["ansible_facts"]["ansible_libvirt_networks"] = results
+ elif facts_mode == 'info':
+ facts['networks'] = results
+ return facts
+
+
+def core(module):
+
+ state = module.params.get('state', None)
+ name = module.params.get('name', None)
+ command = module.params.get('command', None)
+ uri = module.params.get('uri', None)
+ xml = module.params.get('xml', None)
+ autostart = module.params.get('autostart', None)
+
+ v = VirtNetwork(uri, module)
+ res = {}
+
+ if state and command == 'list_nets':
+ res = v.list_nets(state=state)
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ if state:
+ if not name:
+ module.fail_json(msg="state change requires a specified name")
+
+ res['changed'] = False
+ if state in ['active']:
+ if v.status(name) != 'active':
+ res['changed'] = True
+ res['msg'] = v.start(name)
+ elif state in ['present']:
+ try:
+ v.get_net(name)
+ except EntryNotFound:
+ if not xml:
+ module.fail_json(msg="network '" + name + "' not present, but xml not specified")
+ v.define(name, xml)
+ res = {'changed': True, 'created': name}
+ elif state in ['inactive']:
+ entries = v.list_nets()
+ if name in entries:
+ if v.status(name) != 'inactive':
+ res['changed'] = True
+ res['msg'] = v.destroy(name)
+ elif state in ['undefined', 'absent']:
+ entries = v.list_nets()
+ if name in entries:
+ if v.status(name) != 'inactive':
+ v.destroy(name)
+ res['changed'] = True
+ res['msg'] = v.undefine(name)
+ else:
+ module.fail_json(msg="unexpected state")
+
+ return VIRT_SUCCESS, res
+
+ if command:
+ if command in ENTRY_COMMANDS:
+ if not name:
+ module.fail_json(msg="%s requires 1 argument: name" % command)
+ if command in ('define', 'modify'):
+ if not xml:
+ module.fail_json(msg=command + " requires xml argument")
+ try:
+ v.get_net(name)
+ except EntryNotFound:
+ v.define(name, xml)
+ res = {'changed': True, 'created': name}
+ else:
+ if command == 'modify':
+ mod = v.modify(name, xml)
+ res = {'changed': mod, 'modified': name}
+ return VIRT_SUCCESS, res
+ res = getattr(v, command)(name)
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ elif hasattr(v, command):
+ if command == 'facts' and name:
+ res = v.facts(name)
+ else:
+ res = getattr(v, command)()
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ else:
+ module.fail_json(msg="Command %s not recognized" % command)
+
+ if autostart is not None:
+ if not name:
+ module.fail_json(msg="state change requires a specified name")
+
+ res['changed'] = False
+ if autostart:
+ if not v.get_autostart(name):
+ res['changed'] = True
+ res['msg'] = v.set_autostart(name, True)
+ else:
+ if v.get_autostart(name):
+ res['changed'] = True
+ res['msg'] = v.set_autostart(name, False)
+
+ return VIRT_SUCCESS, res
+
+ module.fail_json(msg="expected state or command parameter to be specified")
+
+
+def main():
+
+ module = AnsibleModule(
+ argument_spec=dict(
+ name=dict(aliases=['network']),
+ state=dict(choices=['active', 'inactive', 'present', 'absent']),
+ command=dict(choices=ALL_COMMANDS),
+ uri=dict(default='qemu:///system'),
+ xml=dict(),
+ autostart=dict(type='bool')
+ ),
+ supports_check_mode=True,
+ required_if=[
+ ('command', 'create', ['name']),
+ ('command', 'status', ['name']),
+ ('command', 'start', ['name']),
+ ('command', 'stop', ['name']),
+ ('command', 'undefine', ['name']),
+ ('command', 'destroy', ['name']),
+ ('command', 'get_xml', ['name']),
+ ('command', 'define', ['name']),
+ ('command', 'modify', ['name']),
+ ]
+ )
+
+ if not HAS_VIRT:
+ module.fail_json(
+ msg='The `libvirt` module is not importable. Check the requirements.'
+ )
+
+ if not HAS_XML:
+ module.fail_json(
+ msg='The `lxml` module is not importable. Check the requirements.'
+ )
+
+ rc = VIRT_SUCCESS
+ try:
+ rc, result = core(module)
+ except Exception as e:
+ module.fail_json(msg=str(e))
+
+ if rc != 0: # something went wrong emit the msg
+ module.fail_json(rc=rc, msg=result)
+ else:
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/community/libvirt/plugins/modules/virt_pool.py b/ansible_collections/community/libvirt/plugins/modules/virt_pool.py
new file mode 100644
index 000000000..70145c617
--- /dev/null
+++ b/ansible_collections/community/libvirt/plugins/modules/virt_pool.py
@@ -0,0 +1,707 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# (c) 2015, Maciej Delmanowski <drybjed@gmail.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+
+DOCUMENTATION = '''
+---
+module: virt_pool
+author: "Maciej Delmanowski (@drybjed)"
+short_description: Manage libvirt storage pools
+description:
+ - Manage I(libvirt) storage pools.
+options:
+ name:
+ aliases: [ "pool" ]
+ description:
+ - Name of the storage pool being managed. Note that pool must be previously
+ defined with xml.
+ type: str
+ state:
+ choices: [ "active", "inactive", "present", "absent", "undefined", "deleted" ]
+ description:
+ - Specify which state you want a storage pool to be in.
+ If 'active', pool will be started.
+ If 'present', ensure that pool is present but do not change its
+ state; if it is missing, you need to specify xml argument.
+ If 'inactive', pool will be stopped.
+ If 'undefined' or 'absent', pool will be removed from I(libvirt) configuration.
+ If 'deleted', pool contents will be deleted and then pool undefined.
+ type: str
+ command:
+ choices: [ "define", "build", "create", "start", "stop", "destroy",
+ "delete", "undefine", "get_xml", "list_pools", "facts",
+ "info", "status", "refresh" ]
+ description:
+ - In addition to state management, various non-idempotent commands are available.
+ See examples.
+ type: str
+ autostart:
+ type: bool
+ description:
+ - Specify if a given storage pool should be started automatically on system boot.
+ mode:
+ choices: [ 'new', 'repair', 'resize', 'no_overwrite', 'overwrite', 'normal', 'zeroed' ]
+ description:
+ - Pass additional parameters to 'build' or 'delete' commands.
+ type: str
+extends_documentation_fragment:
+ - community.libvirt.virt.options_uri
+ - community.libvirt.virt.options_xml
+ - community.libvirt.requirements
+requirements:
+ - "python-lxml"
+'''
+
+EXAMPLES = '''
+- name: Define a new storage pool
+ community.libvirt.virt_pool:
+ command: define
+ name: vms
+ xml: '{{ lookup("template", "pool/dir.xml.j2") }}'
+
+- name: Build a storage pool if it does not exist
+ community.libvirt.virt_pool:
+ command: build
+ name: vms
+
+- name: Start a storage pool
+ community.libvirt.virt_pool:
+ command: create
+ name: vms
+
+- name: List available pools
+ community.libvirt.virt_pool:
+ command: list_pools
+
+- name: Get XML data of a specified pool
+ community.libvirt.virt_pool:
+ command: get_xml
+ name: vms
+
+- name: Stop a storage pool
+ community.libvirt.virt_pool:
+ command: destroy
+ name: vms
+
+- name: Delete a storage pool (destroys contents)
+ community.libvirt.virt_pool:
+ command: delete
+ name: vms
+
+- name: Undefine a storage pool
+ community.libvirt.virt_pool:
+ command: undefine
+ name: vms
+
+# Gather facts about storage pools
+# Facts will be available as 'ansible_libvirt_pools'
+- name: Gather facts about storage pools
+ community.libvirt.virt_pool:
+ command: facts
+
+- name: Gather information about pools managed by 'libvirt' remotely using uri
+ community.libvirt.virt_pool:
+ command: info
+ uri: '{{ item }}'
+ with_items: '{{ libvirt_uris }}'
+ register: storage_pools
+
+- name: Ensure that a pool is active (needs to be defined and built first)
+ community.libvirt.virt_pool:
+ state: active
+ name: vms
+
+- name: Ensure that a pool is inactive
+ community.libvirt.virt_pool:
+ state: inactive
+ name: vms
+
+- name: Ensure that a given pool will be started at boot
+ community.libvirt.virt_pool:
+ autostart: yes
+ name: vms
+
+- name: Disable autostart for a given pool
+ community.libvirt.virt_pool:
+ autostart: no
+ name: vms
+'''
+
+try:
+ import libvirt
+except ImportError:
+ HAS_VIRT = False
+else:
+ HAS_VIRT = True
+
+try:
+ from lxml import etree
+except ImportError:
+ HAS_XML = False
+else:
+ HAS_XML = True
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+VIRT_FAILED = 1
+VIRT_SUCCESS = 0
+VIRT_UNAVAILABLE = 2
+
+ALL_COMMANDS = []
+ENTRY_COMMANDS = ['create', 'status', 'start', 'stop', 'build', 'delete',
+ 'undefine', 'destroy', 'get_xml', 'define', 'refresh']
+HOST_COMMANDS = ['list_pools', 'facts', 'info']
+ALL_COMMANDS.extend(ENTRY_COMMANDS)
+ALL_COMMANDS.extend(HOST_COMMANDS)
+
+ENTRY_STATE_ACTIVE_MAP = {
+ 0: "inactive",
+ 1: "active"
+}
+
+ENTRY_STATE_AUTOSTART_MAP = {
+ 0: "no",
+ 1: "yes"
+}
+
+ENTRY_STATE_PERSISTENT_MAP = {
+ 0: "no",
+ 1: "yes"
+}
+
+ENTRY_STATE_INFO_MAP = {
+ 0: "inactive",
+ 1: "building",
+ 2: "running",
+ 3: "degraded",
+ 4: "inaccessible"
+}
+
+ENTRY_BUILD_FLAGS_MAP = {
+ "new": 0,
+ "repair": 1,
+ "resize": 2,
+ "no_overwrite": 4,
+ "overwrite": 8
+}
+
+ENTRY_DELETE_FLAGS_MAP = {
+ "normal": 0,
+ "zeroed": 1
+}
+
+ALL_MODES = []
+ALL_MODES.extend(ENTRY_BUILD_FLAGS_MAP.keys())
+ALL_MODES.extend(ENTRY_DELETE_FLAGS_MAP.keys())
+
+
+class EntryNotFound(Exception):
+ pass
+
+
+class LibvirtConnection(object):
+
+ def __init__(self, uri, module):
+
+ self.module = module
+
+ conn = libvirt.open(uri)
+
+ if not conn:
+ raise Exception("hypervisor connection failure")
+
+ self.conn = conn
+
+ def find_entry(self, entryid):
+ # entryid = -1 returns a list of everything
+
+ results = []
+
+ # Get active entries
+ for name in self.conn.listStoragePools():
+ entry = self.conn.storagePoolLookupByName(name)
+ results.append(entry)
+
+ # Get inactive entries
+ for name in self.conn.listDefinedStoragePools():
+ entry = self.conn.storagePoolLookupByName(name)
+ results.append(entry)
+
+ if entryid == -1:
+ return results
+
+ for entry in results:
+ if entry.name() == entryid:
+ return entry
+
+ raise EntryNotFound("storage pool %s not found" % entryid)
+
+ def create(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).create()
+ else:
+ try:
+ state = self.find_entry(entryid).isActive()
+ except Exception:
+ return self.module.exit_json(changed=True)
+ if not state:
+ return self.module.exit_json(changed=True)
+
+ def destroy(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).destroy()
+ else:
+ if self.find_entry(entryid).isActive():
+ return self.module.exit_json(changed=True)
+
+ def undefine(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).undefine()
+ else:
+ if not self.find_entry(entryid):
+ return self.module.exit_json(changed=True)
+
+ def get_status2(self, entry):
+ state = entry.isActive()
+ return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
+
+ def get_status(self, entryid):
+ if not self.module.check_mode:
+ state = self.find_entry(entryid).isActive()
+ return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
+ else:
+ try:
+ state = self.find_entry(entryid).isActive()
+ return ENTRY_STATE_ACTIVE_MAP.get(state, "unknown")
+ except Exception:
+ return ENTRY_STATE_ACTIVE_MAP.get("inactive", "unknown")
+
+ def get_uuid(self, entryid):
+ return self.find_entry(entryid).UUIDString()
+
+ def get_xml(self, entryid):
+ return self.find_entry(entryid).XMLDesc(0)
+
+ def get_info(self, entryid):
+ return self.find_entry(entryid).info()
+
+ def get_volume_count(self, entryid):
+ return self.find_entry(entryid).numOfVolumes()
+
+ def get_volume_names(self, entryid):
+ return self.find_entry(entryid).listVolumes()
+
+ def get_devices(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ if xml.xpath('/pool/source/device'):
+ result = []
+ for device in xml.xpath('/pool/source/device'):
+ result.append(device.get('path'))
+ try:
+ return result
+ except Exception:
+ raise ValueError('No devices specified')
+
+ def get_format(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/pool/source/format')[0].get('type')
+ except Exception:
+ raise ValueError('Format not specified')
+ return result
+
+ def get_host(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/pool/source/host')[0].get('name')
+ except Exception:
+ raise ValueError('Host not specified')
+ return result
+
+ def get_source_path(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/pool/source/dir')[0].get('path')
+ except Exception:
+ raise ValueError('Source path not specified')
+ return result
+
+ def get_path(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ try:
+ result = xml.xpath('/pool/target/path')[0].text
+ except Exception:
+ raise ValueError('Target path not specified')
+ return result
+
+ def get_type(self, entryid):
+ xml = etree.fromstring(self.find_entry(entryid).XMLDesc(0))
+ return xml.get('type')
+
+ def build(self, entryid, flags):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).build(flags)
+ else:
+ try:
+ state = self.find_entry(entryid)
+ except Exception:
+ return self.module.exit_json(changed=True)
+ if not state:
+ return self.module.exit_json(changed=True)
+
+ def delete(self, entryid, flags):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).delete(flags)
+ else:
+ try:
+ state = self.find_entry(entryid)
+ except Exception:
+ return self.module.exit_json(changed=True)
+ if state:
+ return self.module.exit_json(changed=True)
+
+ def get_autostart(self, entryid):
+ state = self.find_entry(entryid).autostart()
+ return ENTRY_STATE_AUTOSTART_MAP.get(state, "unknown")
+
+ def get_autostart2(self, entryid):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).autostart()
+ else:
+ try:
+ return self.find_entry(entryid).autostart()
+ except Exception:
+ return self.module.exit_json(changed=True)
+
+ def set_autostart(self, entryid, val):
+ if not self.module.check_mode:
+ return self.find_entry(entryid).setAutostart(val)
+ else:
+ try:
+ state = self.find_entry(entryid).autostart()
+ except Exception:
+ return self.module.exit_json(changed=True)
+ if bool(state) != val:
+ return self.module.exit_json(changed=True)
+
+ def refresh(self, entryid):
+ return self.find_entry(entryid).refresh()
+
+ def get_persistent(self, entryid):
+ state = self.find_entry(entryid).isPersistent()
+ return ENTRY_STATE_PERSISTENT_MAP.get(state, "unknown")
+
+ def define_from_xml(self, entryid, xml):
+ if not self.module.check_mode:
+ return self.conn.storagePoolDefineXML(xml)
+ else:
+ try:
+ self.find_entry(entryid)
+ except Exception:
+ return self.module.exit_json(changed=True)
+
+
+class VirtStoragePool(object):
+
+ def __init__(self, uri, module):
+ self.module = module
+ self.uri = uri
+ self.conn = LibvirtConnection(self.uri, self.module)
+
+ def get_pool(self, entryid):
+ return self.conn.find_entry(entryid)
+
+ def list_pools(self, state=None):
+ results = []
+ for entry in self.conn.find_entry(-1):
+ if state:
+ if state == self.conn.get_status2(entry):
+ results.append(entry.name())
+ else:
+ results.append(entry.name())
+ return results
+
+ def state(self):
+ results = []
+ for entry in self.list_pools():
+ state_blurb = self.conn.get_status(entry)
+ results.append("%s %s" % (entry, state_blurb))
+ return results
+
+ def autostart(self, entryid):
+ return self.conn.set_autostart(entryid, True)
+
+ def get_autostart(self, entryid):
+ return self.conn.get_autostart2(entryid)
+
+ def set_autostart(self, entryid, state):
+ return self.conn.set_autostart(entryid, state)
+
+ def create(self, entryid):
+ return self.conn.create(entryid)
+
+ def start(self, entryid):
+ return self.conn.create(entryid)
+
+ def stop(self, entryid):
+ return self.conn.destroy(entryid)
+
+ def destroy(self, entryid):
+ return self.conn.destroy(entryid)
+
+ def undefine(self, entryid):
+ return self.conn.undefine(entryid)
+
+ def status(self, entryid):
+ return self.conn.get_status(entryid)
+
+ def get_xml(self, entryid):
+ return self.conn.get_xml(entryid)
+
+ def define(self, entryid, xml):
+ return self.conn.define_from_xml(entryid, xml)
+
+ def build(self, entryid, flags):
+ return self.conn.build(entryid, ENTRY_BUILD_FLAGS_MAP.get(flags, 0))
+
+ def delete(self, entryid, flags):
+ return self.conn.delete(entryid, ENTRY_DELETE_FLAGS_MAP.get(flags, 0))
+
+ def refresh(self, entryid):
+ return self.conn.refresh(entryid)
+
+ def info(self):
+ return self.facts(facts_mode='info')
+
+ def facts(self, facts_mode='facts'):
+ results = dict()
+ for entry in self.list_pools():
+ results[entry] = dict()
+ if self.conn.find_entry(entry):
+ data = self.conn.get_info(entry)
+ # libvirt returns maxMem, memory, and cpuTime as long()'s, which
+ # xmlrpclib tries to convert to regular int's during serialization.
+ # This throws exceptions, so convert them to strings here and
+ # assume the other end of the xmlrpc connection can figure things
+ # out or doesn't care.
+ results[entry] = {
+ "status": ENTRY_STATE_INFO_MAP.get(data[0], "unknown"),
+ "size_total": str(data[1]),
+ "size_used": str(data[2]),
+ "size_available": str(data[3]),
+ }
+ results[entry]["autostart"] = self.conn.get_autostart(entry)
+ results[entry]["persistent"] = self.conn.get_persistent(entry)
+ results[entry]["state"] = self.conn.get_status(entry)
+ results[entry]["type"] = self.conn.get_type(entry)
+ results[entry]["uuid"] = self.conn.get_uuid(entry)
+ if self.conn.find_entry(entry).isActive():
+ results[entry]["volume_count"] = self.conn.get_volume_count(entry)
+ results[entry]["volumes"] = list()
+ for volume in self.conn.get_volume_names(entry):
+ results[entry]["volumes"].append(volume)
+ else:
+ results[entry]["volume_count"] = -1
+
+ try:
+ results[entry]["path"] = self.conn.get_path(entry)
+ except ValueError:
+ pass
+
+ try:
+ results[entry]["host"] = self.conn.get_host(entry)
+ except ValueError:
+ pass
+
+ try:
+ results[entry]["source_path"] = self.conn.get_source_path(entry)
+ except ValueError:
+ pass
+
+ try:
+ results[entry]["format"] = self.conn.get_format(entry)
+ except ValueError:
+ pass
+
+ try:
+ devices = self.conn.get_devices(entry)
+ results[entry]["devices"] = devices
+ except ValueError:
+ pass
+
+ else:
+ results[entry]["state"] = self.conn.get_status(entry)
+
+ facts = dict()
+ if facts_mode == 'facts':
+ facts["ansible_facts"] = dict()
+ facts["ansible_facts"]["ansible_libvirt_pools"] = results
+ elif facts_mode == 'info':
+ facts['pools'] = results
+ return facts
+
+
+def core(module):
+
+ state = module.params.get('state', None)
+ name = module.params.get('name', None)
+ command = module.params.get('command', None)
+ uri = module.params.get('uri', None)
+ xml = module.params.get('xml', None)
+ autostart = module.params.get('autostart', None)
+ mode = module.params.get('mode', None)
+
+ v = VirtStoragePool(uri, module)
+ res = {}
+
+ if state and command == 'list_pools':
+ res = v.list_pools(state=state)
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ if state:
+ if not name:
+ module.fail_json(msg="state change requires a specified name")
+
+ res['changed'] = False
+ if state in ['active']:
+ if v.status(name) != 'active':
+ res['changed'] = True
+ res['msg'] = v.start(name)
+ elif state in ['present']:
+ try:
+ v.get_pool(name)
+ except EntryNotFound:
+ if not xml:
+ module.fail_json(msg="storage pool '" + name + "' not present, but xml not specified")
+ v.define(name, xml)
+ res = {'changed': True, 'created': name}
+ elif state in ['inactive']:
+ entries = v.list_pools()
+ if name in entries:
+ if v.status(name) != 'inactive':
+ res['changed'] = True
+ res['msg'] = v.destroy(name)
+ elif state in ['undefined', 'absent']:
+ entries = v.list_pools()
+ if name in entries:
+ if v.status(name) != 'inactive':
+ v.destroy(name)
+ res['changed'] = True
+ res['msg'] = v.undefine(name)
+ elif state in ['deleted']:
+ entries = v.list_pools()
+ if name in entries:
+ if v.status(name) != 'inactive':
+ v.destroy(name)
+ v.delete(name, mode)
+ res['changed'] = True
+ res['msg'] = v.undefine(name)
+ else:
+ module.fail_json(msg="unexpected state")
+
+ return VIRT_SUCCESS, res
+
+ if command:
+ if command in ENTRY_COMMANDS:
+ if not name:
+ module.fail_json(msg="%s requires 1 argument: name" % command)
+ if command == 'define':
+ if not xml:
+ module.fail_json(msg="define requires xml argument")
+ try:
+ v.get_pool(name)
+ except EntryNotFound:
+ v.define(name, xml)
+ res = {'changed': True, 'created': name}
+ return VIRT_SUCCESS, res
+ elif command == 'build':
+ res = v.build(name, mode)
+ if not isinstance(res, dict):
+ res = {'changed': True, command: res}
+ return VIRT_SUCCESS, res
+ elif command == 'delete':
+ res = v.delete(name, mode)
+ if not isinstance(res, dict):
+ res = {'changed': True, command: res}
+ return VIRT_SUCCESS, res
+ res = getattr(v, command)(name)
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ elif hasattr(v, command):
+ res = getattr(v, command)()
+ if not isinstance(res, dict):
+ res = {command: res}
+ return VIRT_SUCCESS, res
+
+ else:
+ module.fail_json(msg="Command %s not recognized" % command)
+
+ if autostart is not None:
+ if not name:
+ module.fail_json(msg="state change requires a specified name")
+
+ res['changed'] = False
+ if autostart:
+ if not v.get_autostart(name):
+ res['changed'] = True
+ res['msg'] = v.set_autostart(name, True)
+ else:
+ if v.get_autostart(name):
+ res['changed'] = True
+ res['msg'] = v.set_autostart(name, False)
+
+ return VIRT_SUCCESS, res
+
+ module.fail_json(msg="expected state or command parameter to be specified")
+
+
+def main():
+
+ module = AnsibleModule(
+ argument_spec=dict(
+ name=dict(aliases=['pool']),
+ state=dict(choices=['active', 'inactive', 'present', 'absent', 'undefined', 'deleted']),
+ command=dict(choices=ALL_COMMANDS),
+ uri=dict(default='qemu:///system'),
+ xml=dict(),
+ autostart=dict(type='bool'),
+ mode=dict(choices=ALL_MODES),
+ ),
+ supports_check_mode=True
+ )
+
+ if not HAS_VIRT:
+ module.fail_json(
+ msg='The `libvirt` module is not importable. Check the requirements.'
+ )
+
+ if not HAS_XML:
+ module.fail_json(
+ msg='The `lxml` module is not importable. Check the requirements.'
+ )
+
+ rc = VIRT_SUCCESS
+ try:
+ rc, result = core(module)
+ except Exception as e:
+ module.fail_json(msg=str(e))
+
+ if rc != 0: # something went wrong emit the msg
+ module.fail_json(rc=rc, msg=result)
+ else:
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/community/libvirt/shippable.yml b/ansible_collections/community/libvirt/shippable.yml
new file mode 100644
index 000000000..5e9560289
--- /dev/null
+++ b/ansible_collections/community/libvirt/shippable.yml
@@ -0,0 +1,53 @@
+language: python
+
+env:
+ matrix:
+ - T=none
+
+matrix:
+ exclude:
+ - env: T=none
+ include:
+ - env: T=sanity
+
+ - env: T=units/2.6
+ - env: T=units/2.7
+ - env: T=units/3.5
+ - env: T=units/3.6
+ - env: T=units/3.7
+ - env: T=units/3.8
+ - env: T=units/3.9
+
+# - env: T=aix/7.2/1
+# - env: T=osx/10.11/1
+ - env: T=rhel/7.8/1
+ - env: T=rhel/8.2/1
+ - env: T=freebsd/11.1/1
+ - env: T=freebsd/12.1/1
+ - env: T=linux/centos6/1
+ - env: T=linux/centos7/1
+ - env: T=linux/fedora31/1
+ - env: T=linux/fedora32/1
+ - env: T=linux/opensuse15py2/1
+ - env: T=linux/opensuse15/1
+ - env: T=linux/ubuntu1604/1
+ - env: T=linux/ubuntu1804/1
+
+
+branches:
+ except:
+ - "*-patch-*"
+ - "revert-*-*"
+
+build:
+ ci:
+ - tests/utils/shippable/timing.sh tests/utils/shippable/shippable.sh $T
+
+integrations:
+ notifications:
+ - integrationName: email
+ type: email
+ on_success: never
+ on_failure: never
+ on_start: never
+ on_pull_request: never
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/aliases b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/aliases
new file mode 100644
index 000000000..ad7ccf7ad
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/aliases
@@ -0,0 +1 @@
+unsupported
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/runme.sh b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/runme.sh
new file mode 100755
index 000000000..d3976ff30
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/runme.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
+# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
+
+group=$(python -c \
+ "from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
+
+cd ../connection
+
+INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
+ -e target_hosts="${group}" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/test_connection.inventory b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/test_connection.inventory
new file mode 100644
index 000000000..45e060586
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_lxc/test_connection.inventory
@@ -0,0 +1,6 @@
+[libvirt_lxc]
+libvirt_lxc-pipelining ansible_ssh_pipelining=true
+libvirt_lxc-no-pipelining ansible_ssh_pipelining=false
+[libvirt_lxc:vars]
+ansible_host=lv-ubuntu-wily-amd64
+ansible_connection=community.libvirt.libvirt_lxc
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/aliases b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/aliases
new file mode 100644
index 000000000..ad7ccf7ad
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/aliases
@@ -0,0 +1 @@
+unsupported
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/runme.sh b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/runme.sh
new file mode 100755
index 000000000..d3976ff30
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/runme.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
+# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
+
+group=$(python -c \
+ "from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
+
+cd ../connection
+
+INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
+ -e target_hosts="${group}" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/test_connection.inventory b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/test_connection.inventory
new file mode 100644
index 000000000..27bb6b2f0
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/connection_libvirt_qemu/test_connection.inventory
@@ -0,0 +1,6 @@
+[libvirt]
+libvirt-pipelining ansible_ssh_pipelining=true
+libvirt-no-pipelining ansible_ssh_pipelining=false
+[libvirt:vars]
+ansible_host=lv-ubuntu-wily-amd64
+ansible_connection=community.libvirt.libvirt_qemu
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/aliases b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/aliases
new file mode 100644
index 000000000..ad7ccf7ad
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/aliases
@@ -0,0 +1 @@
+unsupported
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_lxc.yml b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_lxc.yml
new file mode 100644
index 000000000..36b74a4ed
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_lxc.yml
@@ -0,0 +1,2 @@
+plugin: community.libvirt.libvirt
+uri: 'lxc:///'
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_qemu.yml b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_qemu.yml
new file mode 100644
index 000000000..b31664245
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/libvirt_qemu.yml
@@ -0,0 +1,2 @@
+plugin: community.libvirt.libvirt
+uri: 'qemu:///system'
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/playbooks/test-inventory.yml b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/playbooks/test-inventory.yml
new file mode 100644
index 000000000..00176d316
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/playbooks/test-inventory.yml
@@ -0,0 +1,7 @@
+---
+- name: Create servers and test libvirt inventory plugin
+ hosts: localhost
+ gather_facts: False
+ tasks:
+ - debug:
+ var: hostvars
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/runme.sh b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/runme.sh
new file mode 100755
index 000000000..3ac654520
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/inventory_libvirt/runme.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Exit on errors, exit when accessing unset variables and print all commands
+set -eux
+
+# Testing qemu connection
+export ANSIBLE_INVENTORY="./libvirt_qemu.yml"
+ansible-playbook playbooks/test-inventory.yml "$@"
+
+
+# Testing lxc connection
+export ANSIBLE_INVENTORY="./libvirt_lxc.yml"
+ansible-playbook playbooks/test-inventory.yml "$@"
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/aliases b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/aliases
new file mode 100644
index 000000000..e2a1952cb
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/aliases
@@ -0,0 +1,6 @@
+shippable/posix/group1
+skip/aix
+skip/freebsd
+skip/osx
+needs/privileged
+destructive
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/files/foobar.xml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/files/foobar.xml
new file mode 100644
index 000000000..768e10eaa
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/files/foobar.xml
@@ -0,0 +1,9 @@
+<network>
+ <name>foobar</name>
+ <forward mode='nat'/>
+ <ip address='192.168.125.1' netmask='255.255.255.0'>
+ <dhcp>
+ <range start='192.168.125.2' end='192.168.125.254'/>
+ </dhcp>
+ </ip>
+</network>
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/tasks/main.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/tasks/main.yml
new file mode 100644
index 000000000..3ea55b58b
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/tasks/main.yml
@@ -0,0 +1,90 @@
+---
+- include_vars: '{{ item }}'
+ with_first_found:
+ - "{{ ansible_distribution }}-{{ ansible_distribution_version}}.yml"
+ - "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml"
+ - "{{ ansible_distribution }}.yml"
+ - "default.yml"
+
+- block:
+ - name: Install libvirt packages
+ package:
+ name: "{{ virt_net_packages }}"
+
+ - name: Start libvirt
+ service:
+ name: libvirtd
+ state: started
+
+ - name: Define the foobar network
+ community.libvirt.virt_net:
+ command: define
+ name: foobar
+ xml: '{{ lookup("file", "foobar.xml") }}'
+
+ - name: Define the foobar network (again)
+ community.libvirt.virt_net:
+ command: define
+ name: foobar
+ xml: '{{ lookup("file", "foobar.xml") }}'
+ register: second_virt_net_define
+
+ - name: Start the foobar network
+ community.libvirt.virt_net:
+ command: start
+ name: foobar
+
+ - name: Start the foobar network (again)
+ community.libvirt.virt_net:
+ command: start
+ name: foobar
+ register: second_virt_net_start
+
+ - name: Get facts for the foobar network
+ community.libvirt.virt_net:
+ command: facts
+ name: foobar
+ register: virt_net_facts
+
+ - name: Destroy the foobar network
+ community.libvirt.virt_net:
+ command: destroy
+ name: foobar
+
+ - name: Undefine the foobar network
+ community.libvirt.virt_net:
+ command: undefine
+ name: foobar
+ register: second_virt_net_define
+
+ - name: Undefine the foobar network (again)
+ community.libvirt.virt_net:
+ command: undefine
+ name: foobar
+ register: second_virt_net_undefine
+
+ - name: Ensure the second calls return "unchanged"
+ assert:
+ that:
+ - "second_virt_net_start is not changed"
+ - "second_virt_net_define is not changed"
+ - "second_virt_net_undefine is not changed"
+
+ - name: List all the networks
+ community.libvirt.virt_net:
+ command: list_nets
+
+ - name: Get all the network facts
+ community.libvirt.virt_net:
+ command: facts
+
+ always:
+ - name: Stop libvirt
+ service:
+ name: libvirtd
+ state: stopped
+
+ - name: Remove only the libvirt packages
+ package:
+ name: "{{ virt_net_packages|select('match', '.*libvirt.*')|list }}"
+ state: absent
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Debian.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Debian.yml
new file mode 100644
index 000000000..7d06d77cd
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Debian.yml
@@ -0,0 +1,6 @@
+---
+virt_net_packages:
+ - libvirt-daemon
+ - libvirt-daemon-system
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Fedora-29.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Fedora-29.yml
new file mode 100644
index 000000000..dcf754dc9
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Fedora-29.yml
@@ -0,0 +1,6 @@
+---
+virt_net_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-7.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-7.yml
new file mode 100644
index 000000000..263281fec
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-7.yml
@@ -0,0 +1,6 @@
+---
+virt_net_packages:
+ - libvirt
+ - libvirt-daemon
+ - libvirt-python
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-8.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-8.yml
new file mode 100644
index 000000000..dcf754dc9
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-8.yml
@@ -0,0 +1,6 @@
+---
+virt_net_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-9.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-9.yml
new file mode 100644
index 000000000..dcf754dc9
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/RedHat-9.yml
@@ -0,0 +1,6 @@
+---
+virt_net_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-16.04.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-16.04.yml
new file mode 100644
index 000000000..b9ad4aa66
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-16.04.yml
@@ -0,0 +1,5 @@
+---
+virt_net_packages:
+ - libvirt-daemon
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.04.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.04.yml
new file mode 100644
index 000000000..b9ad4aa66
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.04.yml
@@ -0,0 +1,5 @@
+---
+virt_net_packages:
+ - libvirt-daemon
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.10.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.10.yml
new file mode 100644
index 000000000..7d06d77cd
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/Ubuntu-18.10.yml
@@ -0,0 +1,6 @@
+---
+virt_net_packages:
+ - libvirt-daemon
+ - libvirt-daemon-system
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/default.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/default.yml
new file mode 100644
index 000000000..b9ad4aa66
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_net/vars/default.yml
@@ -0,0 +1,5 @@
+---
+virt_net_packages:
+ - libvirt-daemon
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/aliases b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/aliases
new file mode 100644
index 000000000..e2a1952cb
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/aliases
@@ -0,0 +1,6 @@
+shippable/posix/group1
+skip/aix
+skip/freebsd
+skip/osx
+needs/privileged
+destructive
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/defaults/main.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/defaults/main.yml
new file mode 100644
index 000000000..4a329bff0
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+pool_info:
+ name: test_pool
+ path: /tmp/test_pool
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/directory_based_pool.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/directory_based_pool.yml
new file mode 100644
index 000000000..0ec09d85b
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/directory_based_pool.yml
@@ -0,0 +1,139 @@
+---
+#
+# Create working directory
+#
+
+- name: "Crean up working directory"
+ file:
+ path: /tmp/test_pool
+ state: absent
+
+- name: "Create working directory"
+ file:
+ path: /tmp/test_pool
+ mode: 0755
+ state: directory
+
+#
+# Define storage pool
+#
+- name: "Define {{ pool_info.name }} on check_mode(pre)"
+ community.libvirt.virt_pool:
+ state: present
+ name: "{{ pool_info.name }}"
+ xml: '{{ lookup("template", "test_pool.xml.j2") }}'
+ register: result_pre
+ check_mode: true
+
+- name: "Define {{ pool_info.name }}"
+ community.libvirt.virt_pool:
+ state: present
+ name: "{{ pool_info.name }}"
+ xml: '{{ lookup("template", "test_pool.xml.j2") }}'
+ register: result
+
+- name: "Define {{ pool_info.name }} on check_mode(post)"
+ community.libvirt.virt_pool:
+ state: present
+ name: "{{ pool_info.name }}"
+ xml: '{{ lookup("template", "test_pool.xml.j2") }}'
+ register: result_post
+ check_mode: true
+
+- name: "Ensure the {{ pool_info.name }} has been defined"
+ assert:
+ that:
+ - result_pre is changed
+ - result is changed
+ - result_post is not changed
+ - 'result.created == "{{ pool_info.name }}"'
+
+#
+# Activate storage pool
+#
+- name: "Activate {{ pool_info.name }} on check_mode(pre)"
+ community.libvirt.virt_pool:
+ state: active
+ name: "{{ pool_info.name }}"
+ register: result_pre
+ check_mode: true
+
+- name: "Activate {{ pool_info.name }}"
+ community.libvirt.virt_pool:
+ state: active
+ name: "{{ pool_info.name }}"
+ register: result
+
+- name: "Activate {{ pool_info.name }} on check_mode(post}"
+ community.libvirt.virt_pool:
+ state: active
+ name: "{{ pool_info.name }}"
+ register: result_post
+ check_mode: true
+
+- name: "Ensure the {{ pool_info.name }} has been active"
+ assert:
+ that:
+ - result_pre is changed
+ - result is changed and result.msg == 0
+ - result_post is not changed
+
+#
+# Deactivate storage pool
+#
+- name: "Dectivate {{ pool_info.name }} on check_mode(pre)"
+ community.libvirt.virt_pool:
+ state: inactive
+ name: "{{ pool_info.name }}"
+ register: result_pre
+ check_mode: true
+
+- name: "Dectivate {{ pool_info.name }}"
+ community.libvirt.virt_pool:
+ state: inactive
+ name: "{{ pool_info.name }}"
+ register: result
+
+- name: "Dectivate {{ pool_info.name }} on check_mode(post}"
+ community.libvirt.virt_pool:
+ state: inactive
+ name: "{{ pool_info.name }}"
+ register: result_post
+ check_mode: true
+
+- name: "Ensure the {{ pool_info.name }} has been inactive"
+ assert:
+ that:
+ - result_pre is changed
+ - result is changed and result.msg == 0
+ - result_post is not changed
+
+#
+# Undefine storage pool
+#
+- name: Delete "{{ pool_info.name }} on check_mode(pre)"
+ community.libvirt.virt_pool:
+ state: absent
+ name: "{{ pool_info.name }}"
+ register: result_pre
+ check_mode: true
+
+- name: Delete "{{ pool_info.name }}"
+ community.libvirt.virt_pool:
+ state: absent
+ name: "{{ pool_info.name }}"
+ register: result
+
+- name: Delete "{{ pool_info.name }} on check_mode(post)"
+ community.libvirt.virt_pool:
+ state: absent
+ name: "{{ pool_info.name }}"
+ register: result_post
+ check_mode: true
+
+- name: "Ensure the {{ pool_info.name }} has been deleted"
+ assert:
+ that:
+ - result_pre is changed
+ - result is changed and result.msg == 0
+ - result_post is not changed
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/main.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/main.yml
new file mode 100644
index 000000000..f6422b3c5
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+- include_vars: '{{ item }}'
+ with_first_found:
+ - "{{ ansible_distribution }}-{{ ansible_distribution_version}}.yml"
+ - "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml"
+ - "{{ ansible_distribution }}.yml"
+ - "default.yml"
+
+- block:
+ - name: Install libvirt packages
+ package:
+ name: "{{ virt_pool_packages }}"
+
+ - name: Start libvirt service
+ service:
+ name: libvirtd
+ state: started
+
+ - name: Test for a directory based pool
+ import_tasks: directory_based_pool.yml
+
+ always:
+ - name: Stop libvirt
+ service:
+ name: libvirtd
+ state: stopped
+
+ - name: Remove only the libvirt packages
+ package:
+ name: "{{ virt_pool_packages|select('match', '.*libvirt.*')|list }}"
+ state: absent
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/templates/test_pool.xml.j2 b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/templates/test_pool.xml.j2
new file mode 100644
index 000000000..3da24a50c
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/templates/test_pool.xml.j2
@@ -0,0 +1,11 @@
+<pool type='dir'>
+ <name>{{ pool_info.name }}</name>
+ <capacity unit='bytes'>0</capacity>
+ <allocation unit='bytes'>0</allocation>
+ <available unit='bytes'>0</available>
+ <source>
+ </source>
+ <target>
+ <path>{{ pool_info.path }}</path>
+ </target>
+</pool>
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-7.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-7.yml
new file mode 100644
index 000000000..1ccb2a18f
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-7.yml
@@ -0,0 +1,6 @@
+---
+virt_pool_packages:
+ - libvirt
+ - libvirt-daemon
+ - libvirt-python
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-8.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-8.yml
new file mode 100644
index 000000000..053c662bc
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/CentOS-8.yml
@@ -0,0 +1,8 @@
+---
+ansible_python_interpreter: /usr/libexec/platform-python
+
+virt_pool_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Debian.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Debian.yml
new file mode 100644
index 000000000..a55f4b238
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Debian.yml
@@ -0,0 +1,6 @@
+---
+virt_pool_packages:
+ - libvirt-daemon
+ - libvirt-daemon-system
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Fedora-34.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Fedora-34.yml
new file mode 100644
index 000000000..c95a35982
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Fedora-34.yml
@@ -0,0 +1,6 @@
+---
+virt_pool_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-7.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-7.yml
new file mode 100644
index 000000000..1ccb2a18f
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-7.yml
@@ -0,0 +1,6 @@
+---
+virt_pool_packages:
+ - libvirt
+ - libvirt-daemon
+ - libvirt-python
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-8.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-8.yml
new file mode 100644
index 000000000..322301e3c
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-8.yml
@@ -0,0 +1,9 @@
+---
+# RHEL 8/CentOS 8 only provides python-libvirt package for the default Python
+ansible_python_interpreter: /usr/libexec/platform-python
+
+virt_pool_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-9.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-9.yml
new file mode 100644
index 000000000..322301e3c
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/RedHat-9.yml
@@ -0,0 +1,9 @@
+---
+# RHEL 8/CentOS 8 only provides python-libvirt package for the default Python
+ansible_python_interpreter: /usr/libexec/platform-python
+
+virt_pool_packages:
+ - libvirt
+ - libvirt-daemon
+ - python3-libvirt
+ - python3-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.04.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.04.yml
new file mode 100644
index 000000000..bb27ffcdc
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.04.yml
@@ -0,0 +1,5 @@
+---
+virt_pool_packages:
+ - libvirt-daemon
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.10.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.10.yml
new file mode 100644
index 000000000..a55f4b238
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-18.10.yml
@@ -0,0 +1,6 @@
+---
+virt_pool_packages:
+ - libvirt-daemon
+ - libvirt-daemon-system
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-20.04.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-20.04.yml
new file mode 100644
index 000000000..a55f4b238
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/Ubuntu-20.04.yml
@@ -0,0 +1,6 @@
+---
+virt_pool_packages:
+ - libvirt-daemon
+ - libvirt-daemon-system
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/default.yml b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/default.yml
new file mode 100644
index 000000000..bb27ffcdc
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/integration/targets/virt_pool/vars/default.yml
@@ -0,0 +1,5 @@
+---
+virt_pool_packages:
+ - libvirt-daemon
+ - python-libvirt
+ - python-lxml
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt
new file mode 100644
index 000000000..f6584fe11
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.10.txt
@@ -0,0 +1,10 @@
+tests/unit/mock/path.py future-import-boilerplate
+tests/unit/mock/path.py metaclass-boilerplate
+tests/unit/mock/yaml_helper.py future-import-boilerplate
+tests/unit/mock/yaml_helper.py metaclass-boilerplate
+tests/unit/modules/cloud/misc/virt_net/conftest.py future-import-boilerplate
+tests/unit/modules/cloud/misc/virt_net/conftest.py metaclass-boilerplate
+tests/unit/modules/cloud/misc/virt_net/test_virt_net.py future-import-boilerplate
+tests/unit/modules/cloud/misc/virt_net/test_virt_net.py metaclass-boilerplate
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt
new file mode 100644
index 000000000..f6584fe11
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.11.txt
@@ -0,0 +1,10 @@
+tests/unit/mock/path.py future-import-boilerplate
+tests/unit/mock/path.py metaclass-boilerplate
+tests/unit/mock/yaml_helper.py future-import-boilerplate
+tests/unit/mock/yaml_helper.py metaclass-boilerplate
+tests/unit/modules/cloud/misc/virt_net/conftest.py future-import-boilerplate
+tests/unit/modules/cloud/misc/virt_net/conftest.py metaclass-boilerplate
+tests/unit/modules/cloud/misc/virt_net/test_virt_net.py future-import-boilerplate
+tests/unit/modules/cloud/misc/virt_net/test_virt_net.py metaclass-boilerplate
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.12.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.12.txt
new file mode 100644
index 000000000..50392e8e8
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.12.txt
@@ -0,0 +1,2 @@
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.13.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.13.txt
new file mode 100644
index 000000000..50392e8e8
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.13.txt
@@ -0,0 +1,2 @@
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.14.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.14.txt
new file mode 100644
index 000000000..50392e8e8
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.14.txt
@@ -0,0 +1,2 @@
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt b/ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt
new file mode 100644
index 000000000..f6584fe11
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/sanity/ignore-2.9.txt
@@ -0,0 +1,10 @@
+tests/unit/mock/path.py future-import-boilerplate
+tests/unit/mock/path.py metaclass-boilerplate
+tests/unit/mock/yaml_helper.py future-import-boilerplate
+tests/unit/mock/yaml_helper.py metaclass-boilerplate
+tests/unit/modules/cloud/misc/virt_net/conftest.py future-import-boilerplate
+tests/unit/modules/cloud/misc/virt_net/conftest.py metaclass-boilerplate
+tests/unit/modules/cloud/misc/virt_net/test_virt_net.py future-import-boilerplate
+tests/unit/modules/cloud/misc/virt_net/test_virt_net.py metaclass-boilerplate
+tests/utils/shippable/timing.py shebang
+tests/utils/shippable/check_matrix.py replace-urlopen
diff --git a/ansible_collections/community/libvirt/tests/unit/compat/__init__.py b/ansible_collections/community/libvirt/tests/unit/compat/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/compat/__init__.py
diff --git a/ansible_collections/community/libvirt/tests/unit/compat/builtins.py b/ansible_collections/community/libvirt/tests/unit/compat/builtins.py
new file mode 100644
index 000000000..f60ee6782
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/compat/builtins.py
@@ -0,0 +1,33 @@
+# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+#
+# Compat for python2.7
+#
+
+# One unittest needs to import builtins via __import__() so we need to have
+# the string that represents it
+try:
+ import __builtin__
+except ImportError:
+ BUILTINS = 'builtins'
+else:
+ BUILTINS = '__builtin__'
diff --git a/ansible_collections/community/libvirt/tests/unit/compat/mock.py b/ansible_collections/community/libvirt/tests/unit/compat/mock.py
new file mode 100644
index 000000000..0972cd2e8
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/compat/mock.py
@@ -0,0 +1,122 @@
+# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+'''
+Compat module for Python3.x's unittest.mock module
+'''
+import sys
+
+# Python 2.7
+
+# Note: Could use the pypi mock library on python3.x as well as python2.x. It
+# is the same as the python3 stdlib mock library
+
+try:
+ # Allow wildcard import because we really do want to import all of mock's
+ # symbols into this compat shim
+ # pylint: disable=wildcard-import,unused-wildcard-import
+ from unittest.mock import *
+except ImportError:
+ # Python 2
+ # pylint: disable=wildcard-import,unused-wildcard-import
+ try:
+ from mock import *
+ except ImportError:
+ print('You need the mock library installed on python2.x to run tests')
+
+
+# Prior to 3.4.4, mock_open cannot handle binary read_data
+if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
+ file_spec = None
+
+ def _iterate_read_data(read_data):
+ # Helper for mock_open:
+ # Retrieve lines from read_data via a generator so that separate calls to
+ # readline, read, and readlines are properly interleaved
+ sep = b'\n' if isinstance(read_data, bytes) else '\n'
+ data_as_list = [l + sep for l in read_data.split(sep)]
+
+ if data_as_list[-1] == sep:
+ # If the last line ended in a newline, the list comprehension will have an
+ # extra entry that's just a newline. Remove this.
+ data_as_list = data_as_list[:-1]
+ else:
+ # If there wasn't an extra newline by itself, then the file being
+ # emulated doesn't have a newline to end the last line remove the
+ # newline that our naive format() added
+ data_as_list[-1] = data_as_list[-1][:-1]
+
+ for line in data_as_list:
+ yield line
+
+ def mock_open(mock=None, read_data=''):
+ """
+ A helper function to create a mock to replace the use of `open`. It works
+ for `open` called directly or used as a context manager.
+
+ The `mock` argument is the mock object to configure. If `None` (the
+ default) then a `MagicMock` will be created for you, with the API limited
+ to methods or attributes available on standard file handles.
+
+ `read_data` is a string for the `read` methoddline`, and `readlines` of the
+ file handle to return. This is an empty string by default.
+ """
+ def _readlines_side_effect(*args, **kwargs):
+ if handle.readlines.return_value is not None:
+ return handle.readlines.return_value
+ return list(_data)
+
+ def _read_side_effect(*args, **kwargs):
+ if handle.read.return_value is not None:
+ return handle.read.return_value
+ return type(read_data)().join(_data)
+
+ def _readline_side_effect():
+ if handle.readline.return_value is not None:
+ while True:
+ yield handle.readline.return_value
+ for line in _data:
+ yield line
+
+ global file_spec
+ if file_spec is None:
+ import _io
+ file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
+
+ if mock is None:
+ mock = MagicMock(name='open', spec=open)
+
+ handle = MagicMock(spec=file_spec)
+ handle.__enter__.return_value = handle
+
+ _data = _iterate_read_data(read_data)
+
+ handle.write.return_value = None
+ handle.read.return_value = None
+ handle.readline.return_value = None
+ handle.readlines.return_value = None
+
+ handle.read.side_effect = _read_side_effect
+ handle.readline.side_effect = _readline_side_effect()
+ handle.readlines.side_effect = _readlines_side_effect
+
+ mock.return_value = handle
+ return mock
diff --git a/ansible_collections/community/libvirt/tests/unit/compat/unittest.py b/ansible_collections/community/libvirt/tests/unit/compat/unittest.py
new file mode 100644
index 000000000..98f08ad6a
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/compat/unittest.py
@@ -0,0 +1,38 @@
+# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+'''
+Compat module for Python2.7's unittest module
+'''
+
+import sys
+
+# Allow wildcard import because we really do want to import all of
+# unittests's symbols into this compat shim
+# pylint: disable=wildcard-import,unused-wildcard-import
+if sys.version_info < (2, 7):
+ try:
+ # Need unittest2 on python2.6
+ from unittest2 import *
+ except ImportError:
+ print('You need unittest2 installed on python2.6.x to run tests')
+else:
+ from unittest import *
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/__init__.py b/ansible_collections/community/libvirt/tests/unit/mock/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/mock/__init__.py
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/loader.py b/ansible_collections/community/libvirt/tests/unit/mock/loader.py
new file mode 100644
index 000000000..00a584127
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/mock/loader.py
@@ -0,0 +1,116 @@
+# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import os
+
+from ansible.errors import AnsibleParserError
+from ansible.parsing.dataloader import DataLoader
+from ansible.module_utils._text import to_bytes, to_text
+
+
+class DictDataLoader(DataLoader):
+
+ def __init__(self, file_mapping=None):
+ file_mapping = {} if file_mapping is None else file_mapping
+ assert type(file_mapping) == dict
+
+ super(DictDataLoader, self).__init__()
+
+ self._file_mapping = file_mapping
+ self._build_known_directories()
+ self._vault_secrets = None
+
+ def load_from_file(self, path, cache=True, unsafe=False):
+ path = to_text(path)
+ if path in self._file_mapping:
+ return self.load(self._file_mapping[path], path)
+ return None
+
+ # TODO: the real _get_file_contents returns a bytestring, so we actually convert the
+ # unicode/text it's created with to utf-8
+ def _get_file_contents(self, file_name):
+ file_name = to_text(file_name)
+ if file_name in self._file_mapping:
+ return (to_bytes(self._file_mapping[file_name]), False)
+ else:
+ raise AnsibleParserError("file not found: %s" % file_name)
+
+ def path_exists(self, path):
+ path = to_text(path)
+ return path in self._file_mapping or path in self._known_directories
+
+ def is_file(self, path):
+ path = to_text(path)
+ return path in self._file_mapping
+
+ def is_directory(self, path):
+ path = to_text(path)
+ return path in self._known_directories
+
+ def list_directory(self, path):
+ ret = []
+ path = to_text(path)
+ for x in (list(self._file_mapping.keys()) + self._known_directories):
+ if x.startswith(path):
+ if os.path.dirname(x) == path:
+ ret.append(os.path.basename(x))
+ return ret
+
+ def is_executable(self, path):
+ # FIXME: figure out a way to make paths return true for this
+ return False
+
+ def _add_known_directory(self, directory):
+ if directory not in self._known_directories:
+ self._known_directories.append(directory)
+
+ def _build_known_directories(self):
+ self._known_directories = []
+ for path in self._file_mapping:
+ dirname = os.path.dirname(path)
+ while dirname not in ('/', ''):
+ self._add_known_directory(dirname)
+ dirname = os.path.dirname(dirname)
+
+ def push(self, path, content):
+ rebuild_dirs = False
+ if path not in self._file_mapping:
+ rebuild_dirs = True
+
+ self._file_mapping[path] = content
+
+ if rebuild_dirs:
+ self._build_known_directories()
+
+ def pop(self, path):
+ if path in self._file_mapping:
+ del self._file_mapping[path]
+ self._build_known_directories()
+
+ def clear(self):
+ self._file_mapping = dict()
+ self._known_directories = []
+
+ def get_basedir(self):
+ return os.getcwd()
+
+ def set_vault_secrets(self, vault_secrets):
+ self._vault_secrets = vault_secrets
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/path.py b/ansible_collections/community/libvirt/tests/unit/mock/path.py
new file mode 100644
index 000000000..39b090996
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/mock/path.py
@@ -0,0 +1,5 @@
+from ansible_collections.ansible.libvirt.tests.unit.compat.mock import MagicMock
+from ansible.utils.path import unfrackpath
+
+
+mock_unfrackpath_noop = MagicMock(spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x)
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/procenv.py b/ansible_collections/community/libvirt/tests/unit/mock/procenv.py
new file mode 100644
index 000000000..96328184f
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/mock/procenv.py
@@ -0,0 +1,90 @@
+# (c) 2016, Matt Davis <mdavis@ansible.com>
+# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import sys
+import json
+
+from contextlib import contextmanager
+from io import BytesIO, StringIO
+from ansible_collections.ansible.libvirt.tests.unit.compat import unittest
+from ansible.module_utils.six import PY3
+from ansible.module_utils._text import to_bytes
+
+
+@contextmanager
+def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
+ """
+ context manager that temporarily masks the test runner's values for stdin and argv
+ """
+ real_stdin = sys.stdin
+ real_argv = sys.argv
+
+ if PY3:
+ fake_stream = StringIO(stdin_data)
+ fake_stream.buffer = BytesIO(to_bytes(stdin_data))
+ else:
+ fake_stream = BytesIO(to_bytes(stdin_data))
+
+ try:
+ sys.stdin = fake_stream
+ sys.argv = argv_data
+
+ yield
+ finally:
+ sys.stdin = real_stdin
+ sys.argv = real_argv
+
+
+@contextmanager
+def swap_stdout():
+ """
+ context manager that temporarily replaces stdout for tests that need to verify output
+ """
+ old_stdout = sys.stdout
+
+ if PY3:
+ fake_stream = StringIO()
+ else:
+ fake_stream = BytesIO()
+
+ try:
+ sys.stdout = fake_stream
+
+ yield fake_stream
+ finally:
+ sys.stdout = old_stdout
+
+
+class ModuleTestCase(unittest.TestCase):
+ def setUp(self, module_args=None):
+ if module_args is None:
+ module_args = {'_ansible_remote_tmp': '/tmp', '_ansible_keep_remote_files': False}
+
+ args = json.dumps(dict(ANSIBLE_MODULE_ARGS=module_args))
+
+ # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually
+ self.stdin_swap = swap_stdin_and_argv(stdin_data=args)
+ self.stdin_swap.__enter__()
+
+ def tearDown(self):
+ # unittest doesn't have a clean place to use a context manager, so we have to enter/exit manually
+ self.stdin_swap.__exit__(None, None, None)
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/vault_helper.py b/ansible_collections/community/libvirt/tests/unit/mock/vault_helper.py
new file mode 100644
index 000000000..dcce9c784
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/mock/vault_helper.py
@@ -0,0 +1,39 @@
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from ansible.module_utils._text import to_bytes
+
+from ansible.parsing.vault import VaultSecret
+
+
+class TextVaultSecret(VaultSecret):
+ '''A secret piece of text. ie, a password. Tracks text encoding.
+
+ The text encoding of the text may not be the default text encoding so
+ we keep track of the encoding so we encode it to the same bytes.'''
+
+ def __init__(self, text, encoding=None, errors=None, _bytes=None):
+ super(TextVaultSecret, self).__init__()
+ self.text = text
+ self.encoding = encoding or 'utf-8'
+ self._bytes = _bytes
+ self.errors = errors or 'strict'
+
+ @property
+ def bytes(self):
+ '''The text encoded with encoding, unless we specifically set _bytes.'''
+ return self._bytes or to_bytes(self.text, encoding=self.encoding, errors=self.errors)
diff --git a/ansible_collections/community/libvirt/tests/unit/mock/yaml_helper.py b/ansible_collections/community/libvirt/tests/unit/mock/yaml_helper.py
new file mode 100644
index 000000000..cc095fea1
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/mock/yaml_helper.py
@@ -0,0 +1,121 @@
+import io
+import yaml
+
+from ansible.module_utils.six import PY3
+from ansible.parsing.yaml.loader import AnsibleLoader
+from ansible.parsing.yaml.dumper import AnsibleDumper
+
+
+class YamlTestUtils(object):
+ """Mixin class to combine with a unittest.TestCase subclass."""
+ def _loader(self, stream):
+ """Vault related tests will want to override this.
+
+ Vault cases should setup a AnsibleLoader that has the vault password."""
+ return AnsibleLoader(stream)
+
+ def _dump_stream(self, obj, stream, dumper=None):
+ """Dump to a py2-unicode or py3-string stream."""
+ if PY3:
+ return yaml.dump(obj, stream, Dumper=dumper)
+ else:
+ return yaml.dump(obj, stream, Dumper=dumper, encoding=None)
+
+ def _dump_string(self, obj, dumper=None):
+ """Dump to a py2-unicode or py3-string"""
+ if PY3:
+ return yaml.dump(obj, Dumper=dumper)
+ else:
+ return yaml.dump(obj, Dumper=dumper, encoding=None)
+
+ def _dump_load_cycle(self, obj):
+ # Each pass though a dump or load revs the 'generation'
+ # obj to yaml string
+ string_from_object_dump = self._dump_string(obj, dumper=AnsibleDumper)
+
+ # wrap a stream/file like StringIO around that yaml
+ stream_from_object_dump = io.StringIO(string_from_object_dump)
+ loader = self._loader(stream_from_object_dump)
+ # load the yaml stream to create a new instance of the object (gen 2)
+ obj_2 = loader.get_data()
+
+ # dump the gen 2 objects directory to strings
+ string_from_object_dump_2 = self._dump_string(obj_2,
+ dumper=AnsibleDumper)
+
+ # The gen 1 and gen 2 yaml strings
+ self.assertEqual(string_from_object_dump, string_from_object_dump_2)
+ # the gen 1 (orig) and gen 2 py object
+ self.assertEqual(obj, obj_2)
+
+ # again! gen 3... load strings into py objects
+ stream_3 = io.StringIO(string_from_object_dump_2)
+ loader_3 = self._loader(stream_3)
+ obj_3 = loader_3.get_data()
+
+ string_from_object_dump_3 = self._dump_string(obj_3, dumper=AnsibleDumper)
+
+ self.assertEqual(obj, obj_3)
+ # should be transitive, but...
+ self.assertEqual(obj_2, obj_3)
+ self.assertEqual(string_from_object_dump, string_from_object_dump_3)
+
+ def _old_dump_load_cycle(self, obj):
+ '''Dump the passed in object to yaml, load it back up, dump again, compare.'''
+ stream = io.StringIO()
+
+ yaml_string = self._dump_string(obj, dumper=AnsibleDumper)
+ self._dump_stream(obj, stream, dumper=AnsibleDumper)
+
+ yaml_string_from_stream = stream.getvalue()
+
+ # reset stream
+ stream.seek(0)
+
+ loader = self._loader(stream)
+ # loader = AnsibleLoader(stream, vault_password=self.vault_password)
+ obj_from_stream = loader.get_data()
+
+ stream_from_string = io.StringIO(yaml_string)
+ loader2 = self._loader(stream_from_string)
+ # loader2 = AnsibleLoader(stream_from_string, vault_password=self.vault_password)
+ obj_from_string = loader2.get_data()
+
+ stream_obj_from_stream = io.StringIO()
+ stream_obj_from_string = io.StringIO()
+
+ if PY3:
+ yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
+ yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
+ else:
+ yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper, encoding=None)
+ yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper, encoding=None)
+
+ yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue()
+ yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue()
+
+ stream_obj_from_stream.seek(0)
+ stream_obj_from_string.seek(0)
+
+ if PY3:
+ yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
+ yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
+ else:
+ yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper, encoding=None)
+ yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper, encoding=None)
+
+ assert yaml_string == yaml_string_obj_from_stream
+ assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string
+ assert (yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string == yaml_string_stream_obj_from_stream ==
+ yaml_string_stream_obj_from_string)
+ assert obj == obj_from_stream
+ assert obj == obj_from_string
+ assert obj == yaml_string_obj_from_stream
+ assert obj == yaml_string_obj_from_string
+ assert obj == obj_from_stream == obj_from_string == yaml_string_obj_from_stream == yaml_string_obj_from_string
+ return {'obj': obj,
+ 'yaml_string': yaml_string,
+ 'yaml_string_from_stream': yaml_string_from_stream,
+ 'obj_from_stream': obj_from_stream,
+ 'obj_from_string': obj_from_string,
+ 'yaml_string_obj_from_string': yaml_string_obj_from_string}
diff --git a/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/__init__.py b/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/__init__.py
diff --git a/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/conftest.py b/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/conftest.py
new file mode 100644
index 000000000..68acada89
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/conftest.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright: (c) 2019, Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+import pytest
+
+from ansible_collections.community.libvirt.plugins.modules import virt_net
+
+from ansible_collections.community.libvirt.tests.unit.compat import mock
+
+
+virt_net.libvirt = None
+virt_net.HAS_VIRT = True
+
+
+class DummyNetwork():
+ def __init__(self, name, isActive=True):
+ self._name = name
+ self._isActive = isActive
+
+ def name(self):
+ return self._name
+
+ def isActive(self):
+ return self._isActive
+
+
+class DummyLibvirtConn():
+ def __init__(self):
+ self._network = [
+ DummyNetwork("inactive_net", isActive=False),
+ DummyNetwork("active_net", isActive=True)]
+
+ def listNetworks(self):
+ return [i.name() for i in self._network]
+
+ def networkLookupByName(self, name):
+ for i in self._network:
+ if i.name() == name:
+ return i
+
+ def listDefinedNetworks(self):
+ return []
+
+
+class DummyLibvirt():
+ VIR_ERR_NETWORK_EXIST = 'VIR_ERR_NETWORK_EXIST'
+
+ @classmethod
+ def open(cls, uri):
+ return DummyLibvirtConn()
+
+ class libvirtError(Exception):
+ def __init__(self):
+ self.error_code
+
+ def get_error_code(self):
+ return self.error_code
+
+
+@pytest.fixture
+def dummy_libvirt(monkeypatch):
+ monkeypatch.setattr(virt_net, 'libvirt', DummyLibvirt)
+ return DummyLibvirt
+
+
+@pytest.fixture
+def virt_net_obj(dummy_libvirt):
+ return virt_net.VirtNetwork('qemu:///nowhere', mock.MagicMock())
diff --git a/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/test_virt_net.py b/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/test_virt_net.py
new file mode 100644
index 000000000..a6133f9fb
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/unit/modules/cloud/misc/virt_net/test_virt_net.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright: (c) 2019, Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from ansible_collections.community.libvirt.tests.unit.compat import mock
+
+
+def test_virt_net_create_already_active(virt_net_obj, dummy_libvirt):
+ virt_net_obj.conn.create = mock.Mock()
+ assert virt_net_obj.create("active_net") is None
+ virt_net_obj.conn.create.assert_not_called()
+
+
+def test_virt_net_recreate(virt_net_obj, dummy_libvirt):
+ virt_net_obj.conn.create = mock.Mock()
+ dummy_libvirt.libvirtError.error_code = 'VIR_ERR_NETWORK_EXIST'
+ virt_net_obj.conn.create.side_effect = dummy_libvirt.libvirtError
+ assert virt_net_obj.create("active_net") is None
+
+
+def test_virt_stop_ignore_inactive(virt_net_obj):
+ virt_net_obj.conn.destroy = mock.Mock()
+ virt_net_obj.stop('inactive_net')
+ virt_net_obj.conn.destroy.assert_not_called()
+
+
+def test_virt_stop_active(virt_net_obj, monkeypatch):
+ virt_net_obj.conn.destroy = mock.Mock()
+ virt_net_obj.stop('active_net')
+ virt_net_obj.conn.destroy.assert_called_with('active_net')
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py b/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py
new file mode 100755
index 000000000..567181fc0
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/check_matrix.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python
+"""Verify the currently executing Shippable test matrix matches the one defined in the "shippable.yml" file."""
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import datetime
+import json
+import os
+import re
+import sys
+import time
+
+from ansible.module_utils.urls import open_url
+
+try:
+ from typing import NoReturn
+except ImportError:
+ NoReturn = None
+
+try:
+ # noinspection PyCompatibility
+ from urllib2 import urlopen # pylint: disable=ansible-bad-import-from
+except ImportError:
+ # noinspection PyCompatibility
+ from urllib.request import urlopen
+
+
+def main(): # type: () -> None
+ """Main entry point."""
+ repo_full_name = os.environ['REPO_FULL_NAME']
+ required_repo_full_name = 'ansible-collections/community.libvirt'
+
+ if repo_full_name != required_repo_full_name:
+ sys.stderr.write('Skipping matrix check on repo "%s" which is not "%s".\n' % (repo_full_name, required_repo_full_name))
+ return
+
+ with open('shippable.yml', 'rb') as yaml_file:
+ yaml = yaml_file.read().decode('utf-8').splitlines()
+
+ defined_matrix = [match.group(1) for match in [re.search(r'^ *- env: T=(.*)$', line) for line in yaml] if match and match.group(1) != 'none']
+
+ if not defined_matrix:
+ fail('No matrix entries found in the "shippable.yml" file.',
+ 'Did you modify the "shippable.yml" file?')
+
+ run_id = os.environ['SHIPPABLE_BUILD_ID']
+ sleep = 1
+ jobs = []
+
+ for attempts_remaining in range(4, -1, -1):
+ try:
+ jobs = json.loads(urlopen('https://api.shippable.com/jobs?runIds=%s' % run_id).read())
+
+ if not isinstance(jobs, list):
+ raise Exception('Shippable run %s data is not a list.' % run_id)
+
+ break
+ except Exception as ex:
+ if not attempts_remaining:
+ fail('Unable to retrieve Shippable run %s matrix.' % run_id,
+ str(ex))
+
+ sys.stderr.write('Unable to retrieve Shippable run %s matrix: %s\n' % (run_id, ex))
+ sys.stderr.write('Trying again in %d seconds...\n' % sleep)
+ time.sleep(sleep)
+ sleep *= 2
+
+ if len(jobs) != len(defined_matrix):
+ if len(jobs) == 1:
+ hint = '\n\nMake sure you do not use the "Rebuild with SSH" option.'
+ else:
+ hint = ''
+
+ fail('Shippable run %s has %d jobs instead of the expected %d jobs.' % (run_id, len(jobs), len(defined_matrix)),
+ 'Try re-running the entire matrix.%s' % hint)
+
+ actual_matrix = dict((job.get('jobNumber'), dict(tuple(line.split('=', 1)) for line in job.get('env', [])).get('T', '')) for job in jobs)
+ errors = [(job_number, test, actual_matrix.get(job_number)) for job_number, test in enumerate(defined_matrix, 1) if actual_matrix.get(job_number) != test]
+
+ if len(errors):
+ error_summary = '\n'.join('Job %s expected "%s" but found "%s" instead.' % (job_number, expected, actual) for job_number, expected, actual in errors)
+
+ fail('Shippable run %s has a job matrix mismatch.' % run_id,
+ 'Try re-running the entire matrix.\n\n%s' % error_summary)
+
+
+def fail(message, output): # type: (str, str) -> NoReturn
+ # Include a leading newline to improve readability on Shippable "Tests" tab.
+ # Without this, the first line becomes indented.
+ output = '\n' + output.strip()
+
+ timestamp = datetime.datetime.utcnow().replace(microsecond=0).isoformat()
+
+ # hack to avoid requiring junit-xml, which isn't pre-installed on Shippable outside our test containers
+ xml = '''
+<?xml version="1.0" encoding="utf-8"?>
+<testsuites disabled="0" errors="1" failures="0" tests="1" time="0.0">
+\t<testsuite disabled="0" errors="1" failures="0" file="None" log="None" name="ansible-test" skipped="0" tests="1" time="0" timestamp="%s" url="None">
+\t\t<testcase classname="timeout" name="timeout">
+\t\t\t<error message="%s" type="error">%s</error>
+\t\t</testcase>
+\t</testsuite>
+</testsuites>
+''' % (timestamp, message, output)
+
+ path = 'shippable/testresults/check-matrix.xml'
+ dir_path = os.path.dirname(path)
+
+ if not os.path.exists(dir_path):
+ os.makedirs(dir_path)
+
+ with open(path, 'w') as junit_fd:
+ junit_fd.write(xml.lstrip())
+
+ sys.stderr.write(message + '\n')
+ sys.stderr.write(output + '\n')
+
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/cloud.sh b/ansible_collections/community/libvirt/tests/utils/shippable/cloud.sh
new file mode 100755
index 000000000..d76c32282
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/cloud.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+cloud="${args[0]}"
+python="${args[1]}"
+group="${args[2]}"
+
+target="shippable/${cloud}/group${group}/"
+
+stage="${S:-prod}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote-terminate always --remote-stage "${stage}" \
+ --docker --python "${python}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/freebsd.sh b/ansible_collections/community/libvirt/tests/utils/shippable/freebsd.sh
new file mode 100755
index 000000000..cd3014cca
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/freebsd.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+platform="${args[0]}"
+version="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+stage="${S:-prod}"
+provider="${P:-default}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/linux.sh b/ansible_collections/community/libvirt/tests/utils/shippable/linux.sh
new file mode 100755
index 000000000..9cc2f966c
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/linux.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+image="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --docker "${image}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/osx.sh b/ansible_collections/community/libvirt/tests/utils/shippable/osx.sh
new file mode 100755
index 000000000..cd3014cca
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/osx.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+platform="${args[0]}"
+version="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+stage="${S:-prod}"
+provider="${P:-default}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/remote.sh b/ansible_collections/community/libvirt/tests/utils/shippable/remote.sh
new file mode 100755
index 000000000..cd3014cca
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/remote.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+platform="${args[0]}"
+version="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+stage="${S:-prod}"
+provider="${P:-default}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/rhel.sh b/ansible_collections/community/libvirt/tests/utils/shippable/rhel.sh
new file mode 100755
index 000000000..cd3014cca
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/rhel.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+platform="${args[0]}"
+version="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+stage="${S:-prod}"
+provider="${P:-default}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/sanity.sh b/ansible_collections/community/libvirt/tests/utils/shippable/sanity.sh
new file mode 100755
index 000000000..0c54a42c8
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/sanity.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+# shellcheck disable=SC2086
+ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
+ --docker \
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/shippable.sh b/ansible_collections/community/libvirt/tests/utils/shippable/shippable.sh
new file mode 100755
index 000000000..854ce08f7
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/shippable.sh
@@ -0,0 +1,206 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+ansible_version="${args[0]}"
+script="${args[1]}"
+
+function join {
+ local IFS="$1";
+ shift;
+ echo "$*";
+}
+
+# Ensure we can write other collections to this dir
+sudo chown "$(whoami)" "${PWD}/../../"
+
+test="$(join / "${args[@]:1}")"
+
+docker images ansible/ansible
+docker images quay.io/ansible/*
+docker ps
+
+for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^drydock/' -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do
+ docker rm -f "${container}" || true # ignore errors
+done
+
+docker ps
+
+if [ -d /home/shippable/cache/ ]; then
+ ls -la /home/shippable/cache/
+fi
+
+command -v python
+python -V
+
+function retry
+{
+ # shellcheck disable=SC2034
+ for repetition in 1 2 3; do
+ set +e
+ "$@"
+ result=$?
+ set -e
+ if [ ${result} == 0 ]; then
+ return ${result}
+ fi
+ echo "@* -> ${result}"
+ done
+ echo "Command '@*' failed 3 times!"
+ exit 1
+}
+
+command -v pip
+pip --version
+pip list --disable-pip-version-check
+if [ "${ansible_version}" == "devel" ]; then
+ retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
+else
+ retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
+fi
+
+export PATH="${PWD}/bin:${PATH}"
+if [ "${SHIPPABLE_BUILD_ID:-}" ]; then
+ export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
+ SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
+ TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/libvirt"
+ mkdir -p "${TEST_DIR}"
+ cp -aT "${SHIPPABLE_BUILD_DIR}" "${TEST_DIR}"
+ cd "${TEST_DIR}"
+else
+ # AZP
+ export ANSIBLE_COLLECTIONS_PATHS="$PWD/../../../"
+fi
+
+export PYTHONIOENCODING='utf-8'
+
+if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then
+ COVERAGE=yes
+ COMPLETE=yes
+fi
+
+if [ -n "${COVERAGE:-}" ]; then
+ # on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value
+ export COVERAGE="--coverage"
+elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then
+ # on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message
+ export COVERAGE="--coverage"
+else
+ # on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled)
+ export COVERAGE="--coverage-check"
+fi
+
+if [ -n "${COMPLETE:-}" ]; then
+ # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
+ export CHANGED=""
+elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then
+ # disable change detection triggered by having 'ci_complete' in the latest commit message
+ export CHANGED=""
+else
+ # enable change detection (default behavior)
+ export CHANGED="--changed"
+fi
+
+if [ "${IS_PULL_REQUEST:-}" == "true" ]; then
+ # run unstable tests which are targeted by focused changes on PRs
+ export UNSTABLE="--allow-unstable-changed"
+else
+ # do not run unstable tests outside PRs
+ export UNSTABLE=""
+fi
+
+# remove empty core/extras module directories from PRs created prior to the repo-merge
+find plugins -type d -empty -print -delete
+
+function cleanup
+{
+ # for complete on-demand coverage generate a report for all files with no coverage on the "sanity/5" job so we only have one copy
+ if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/5" ]; then
+ stub="--stub"
+ # trigger coverage reporting for stubs even if no other coverage data exists
+ mkdir -p tests/output/coverage/
+ else
+ stub=""
+ fi
+
+ if [ -d tests/output/coverage/ ]; then
+ if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then
+ process_coverage='yes' # process existing coverage files
+ elif [ "${stub}" ]; then
+ process_coverage='yes' # process coverage when stubs are enabled
+ else
+ process_coverage=''
+ fi
+
+ if [ "${process_coverage}" ]; then
+ # use python 3.7 for coverage to avoid running out of memory during coverage xml processing
+ # only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
+ virtualenv --python /usr/bin/python3.7 ~/ansible-venv
+ set +ux
+ . ~/ansible-venv/bin/activate
+ set -ux
+
+ # shellcheck disable=SC2086
+ ansible-test coverage xml --color -v --requirements --group-by command --group-by version ${stub:+"$stub"}
+ cp -a tests/output/reports/coverage=*.xml "$SHIPPABLE_RESULT_DIR/codecoverage/"
+
+ if [ "${ansible_version}" != "2.9" ]; then
+ # analyze and capture code coverage aggregated by integration test target
+ ansible-test coverage analyze targets generate -v "$SHIPPABLE_RESULT_DIR/testresults/coverage-analyze-targets.json"
+ fi
+
+ # upload coverage report to codecov.io only when using complete on-demand coverage
+ if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ]; then
+ for file in tests/output/reports/coverage=*.xml; do
+ flags="${file##*/coverage=}"
+ flags="${flags%-powershell.xml}"
+ flags="${flags%.xml}"
+ # remove numbered component from stub files when converting to tags
+ flags="${flags//stub-[0-9]*/stub}"
+ flags="${flags//=/,}"
+ flags="${flags//[^a-zA-Z0-9_,]/_}"
+
+ bash <(curl -s https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/codecov.sh) \
+ -f "${file}" \
+ -F "${flags}" \
+ -n "${test}" \
+ -t e27e1287-0583-48ee-8a1f-867be2b25b46 \
+ -X coveragepy \
+ -X gcov \
+ -X fix \
+ -X search \
+ -X xcode \
+ || echo "Failed to upload code coverage report to codecov.io: ${file}"
+ done
+ fi
+ fi
+ fi
+
+ if [ -d tests/output/junit/ ]; then
+ cp -aT tests/output/junit/ "$SHIPPABLE_RESULT_DIR/testresults/"
+ fi
+
+ if [ -d tests/output/data/ ]; then
+ cp -a tests/output/data/ "$SHIPPABLE_RESULT_DIR/testresults/"
+ fi
+
+ if [ -d tests/output/bot/ ]; then
+ cp -aT tests/output/bot/ "$SHIPPABLE_RESULT_DIR/testresults/"
+ fi
+}
+
+if [ "${SHIPPABLE_BUILD_ID:-}" ]; then trap cleanup EXIT; fi
+
+if [[ "${COVERAGE:-}" == "--coverage" ]]; then
+ timeout=60
+else
+ timeout=50
+fi
+
+ansible-test env --dump --show --timeout "${timeout}" --color -v
+
+if [ "${SHIPPABLE_BUILD_ID:-}" ]; then "tests/utils/shippable/check_matrix.py"; fi
+"tests/utils/shippable/${script}.sh" "${test}"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/timing.py b/ansible_collections/community/libvirt/tests/utils/shippable/timing.py
new file mode 100755
index 000000000..fb538271b
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/timing.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3.7
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import sys
+import time
+
+start = time.time()
+
+sys.stdin.reconfigure(errors='surrogateescape')
+sys.stdout.reconfigure(errors='surrogateescape')
+
+for line in sys.stdin:
+ seconds = time.time() - start
+ sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
+ sys.stdout.flush()
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/timing.sh b/ansible_collections/community/libvirt/tests/utils/shippable/timing.sh
new file mode 100755
index 000000000..77e257830
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/timing.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eu
+
+"$@" 2>&1 | "$(dirname "$0")/timing.py"
diff --git a/ansible_collections/community/libvirt/tests/utils/shippable/units.sh b/ansible_collections/community/libvirt/tests/utils/shippable/units.sh
new file mode 100755
index 000000000..4bf9e05c4
--- /dev/null
+++ b/ansible_collections/community/libvirt/tests/utils/shippable/units.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+if [[ "${COVERAGE:-}" == "--coverage" ]]; then
+ timeout=90
+else
+ timeout=30
+fi
+
+ansible-test env --timeout "${timeout}" --color -v
+
+# shellcheck disable=SC2086
+ansible-test units --color -v --docker default ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \