From 788d2a56d87cb758ae3be48fd5637897bf0e153a Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Thu, 16 Apr 2020 09:56:15 +0200 Subject: [PATCH 01/15] modify lvm pool 'logical' keyword --- templates/pool.xml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pool.xml.j2 b/templates/pool.xml.j2 index 0a368b8..a680150 100644 --- a/templates/pool.xml.j2 +++ b/templates/pool.xml.j2 @@ -7,7 +7,7 @@ {{ item.source }} {% if item.type == 'lvm2' %} - + {% endif %} {% endif %} From 1ccf88143f8a02247d4486b426ce015094a7311b Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Thu, 16 Apr 2020 11:21:54 +0200 Subject: [PATCH 02/15] modify lvm pool 'logical' keyword --- templates/pool.xml.j2 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/pool.xml.j2 b/templates/pool.xml.j2 index a680150..cd3ef3b 100644 --- a/templates/pool.xml.j2 +++ b/templates/pool.xml.j2 @@ -1,4 +1,8 @@ +{% if item.type == 'lvm2' %} + +{% else %} +{% endif %} {{ item.name }} {% if 'capacity' in item %} {{ item.capacity }} @@ -7,7 +11,7 @@ {{ item.source }} {% if item.type == 'lvm2' %} - + {% endif %} {% endif %} From 5636580f4d8ae18149ff7d0396bc94ceb371a176 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 21 Apr 2020 23:12:33 +0200 Subject: [PATCH 03/15] permit to use existing lvm --- README.md | 2 +- requirements.yml | 6 ++++++ tasks/pools.yml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 requirements.yml diff --git a/README.md b/README.md index 4972a67..1dd79b0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ should be a dict containing the following items: - `owner` The owner of the pool. (only `dir`) - `group` The group of the pool. (only `dir`) - `source` The name of the volume group. (only `lvm2`) -- `pvs` A list of physical volumes the volume group consists of. (only `lvm2`) +- `pvs` A list of physical volumes the volume group consists of. (only `lvm2`). N.B. if specified, the lvg will be created on top of the PVS, otherwise the lv should have been created before. `libvirt_host_networks` is a list of networks to define and start. Each item should be a dict containing the following items: diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..bb31ec7 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,6 @@ +--- +roles: + # Install a role from Ansible Galaxy. + - name: tcharl.ansible_manage_lvm + source: https://galaxy.ansible.com + path: ../community diff --git a/tasks/pools.yml b/tasks/pools.yml index 68fad86..e3946f0 100644 --- a/tasks/pools.yml +++ b/tasks/pools.yml @@ -14,7 +14,7 @@ lvg: vg: "{{ item.source }}" pvs: "{{ item.pvs }}" - when: item.type == "lvm2" + when: item.type == "lvm2" and item.pvs is defined with_items: "{{ libvirt_host_pools }}" become: True From 701335821006f9d60b6bd73bd8ee7e8170bf8684 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 21 Apr 2020 23:13:05 +0200 Subject: [PATCH 04/15] remove unrequired requirement --- requirements.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 requirements.yml diff --git a/requirements.yml b/requirements.yml deleted file mode 100644 index bb31ec7..0000000 --- a/requirements.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -roles: - # Install a role from Ansible Galaxy. - - name: tcharl.ansible_manage_lvm - source: https://galaxy.ansible.com - path: ../community From a21720a44927a048b56169bd0762f7d1dd244006 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 12 May 2020 13:48:20 +0200 Subject: [PATCH 05/15] molecule test --- .github/workflows/molecule.yml | 51 ++++++++++++++++++ .gitignore | 1 + .travis.yml | 56 +++++++++----------- .yamllint | 33 ++++++++++++ handlers/main.yml | 1 + molecule/default/Vagrantfile | 18 +++++++ molecule/default/converge.yml | 71 ++++++++++++++++++++++++++ molecule/default/molecule.yml | 39 ++++++++++++++ molecule/default/tests/conftest.py | 21 ++++++++ molecule/default/tests/test_default.py | 13 +++++ molecule/kvm/Vagrantfile | 18 +++++++ molecule/kvm/converge.yml | 71 ++++++++++++++++++++++++++ molecule/kvm/molecule.yml | 36 +++++++++++++ molecule/kvm/tests/conftest.py | 21 ++++++++ molecule/kvm/tests/test_default.py | 13 +++++ requirements.yml | 5 ++ tasks/pools.yml | 8 +++ tasks/post-install-Debian.yml | 2 +- 18 files changed, 445 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/molecule.yml create mode 100644 .gitignore create mode 100644 .yamllint create mode 100644 molecule/default/Vagrantfile create mode 100644 molecule/default/converge.yml create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/tests/conftest.py create mode 100644 molecule/default/tests/test_default.py create mode 100644 molecule/kvm/Vagrantfile create mode 100644 molecule/kvm/converge.yml create mode 100644 molecule/kvm/molecule.yml create mode 100644 molecule/kvm/tests/conftest.py create mode 100644 molecule/kvm/tests/test_default.py create mode 100644 requirements.yml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml new file mode 100644 index 0000000..a95f5dd --- /dev/null +++ b/.github/workflows/molecule.yml @@ -0,0 +1,51 @@ +--- +# This is a basic workflow to help you get started with Actions +name: Molecule + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + pull_request: + branches: + - master + - tags/* + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + lint: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: install lint prerequisite + run: | + sudo apt-get update + sudo apt -y install python3-setuptools ansible-lint vagrant + + - name: Install molecule + run: | + sudo apt update + sudo apt -y install python3-setuptools python3 python3-pip + sudo pip3 install wheel + sudo pip3 install molecule testinfra yamllint ansible-lint flake8 molecule-vagrant + + - name: molecule lint + run: | + molecule lint + + requirements: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - name: install prereq + run: | + ansible-galaxy role install -r requirements.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81dc40e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/__pychache__ diff --git a/.travis.yml b/.travis.yml index dcafe13..c5a9ae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,27 @@ --- -language: python -python: "2.7" - -# Use the new container infrastructure -sudo: false - -# Install ansible -addons: - apt: - packages: - - python-pip - -install: - # Install ansible - - pip install ansible ansible-lint - - # Check ansible version - - ansible --version - # Create ansible.cfg with correct roles_path - - printf '[defaults]\nroles_path=../' >ansible.cfg +dist: bionic - # Compensate for repo name being different to the role - - ln -s $(pwd) ../stackhpc.libvirt-host - -script: - # Run Ansible lint against the role - - ansible-lint tasks/main.yml - - # Basic role syntax check - - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ +language: python +python: + - "3.8" + +before_install: + - | + sudo apt -y install bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev + + - | + wget https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb + sudo apt -y install ./vagrant_2.2.7_x86_64.deb + sudo vagrant plugin install vagrant-libvirt + + - | + sudo apt-get -y purge python3-openssl && sudo apt-get -y autoremove + sudo apt-get update && sudo apt-get install -y ca-certificates curl gcc iproute2 python3 python3-dev sudo + curl -skL https://bootstrap.pypa.io/get-pip.py | sudo -H python3 + sudo pip3 install wheel + sudo pip3 install netaddr python-vagrant yamllint testinfra flake8 + sudo pip3 install ansible ansible-lint + sudo pip3 install -I molecule molecule-vagrant + +script: travis_wait 30 sudo molecule test --scenario-name kvm \ No newline at end of file diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..8827676 --- /dev/null +++ b/.yamllint @@ -0,0 +1,33 @@ +--- +# Based on ansible-lint config +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + colons: + max-spaces-after: -1 + level: error + commas: + max-spaces-after: -1 + level: error + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + max: 3 + level: error + hyphens: + level: error + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable + truthy: disable diff --git a/handlers/main.yml b/handlers/main.yml index 8193fde..32e2fcc 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -4,4 +4,5 @@ service: name: libvirtd state: restarted + enabled: yes become: true diff --git a/molecule/default/Vagrantfile b/molecule/default/Vagrantfile new file mode 100644 index 0000000..313756f --- /dev/null +++ b/molecule/default/Vagrantfile @@ -0,0 +1,18 @@ +Vagrant.configure(2) do |config| + config.vm.provider :libvirt do |libvirt| + libvirt.memory = "512" + libvirt.cpus = 1 + libvirt.driver = "kvm" + libvirt.graphics_type = 'none' + end + + config.vm.box = "fedora/31-cloud-base" + config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.define "myvm" do |myvm| +# myvm.vm.network :public_network, +# :dev => "virbr0", +# :mode => "bridge", +# :type => "bridge" + end +end \ No newline at end of file diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml new file mode 100644 index 0000000..6c2a90f --- /dev/null +++ b/molecule/default/converge.yml @@ -0,0 +1,71 @@ +--- +- name: Converge + hosts: all + vars: + manage_lvm: true + lvm_groups: + - vgname: libvirtpool + disks: + - /dev/sdb1 + create: true + lvnames: [] + users_group_list: + - name: libvirt + systemusers_user_list: + - name: libvirt + group: libvirt + groups: wheel + libvirt_host_pools: + - name: libvirt_vg + type: lvm2 + source: libvirtpool + libvirt_host_networks: + - name: ansible-virtualization-bridge + mode: bridge + bridge: bridge0 + tasks: + - name: "Include ansible-role-libvirt-host" + include_role: + name: "ansible-role-libvirt-host" + + - name: "Post converge - Install vagrant" + package: + name: + - qemu + - libvirt + - ruby-devel + - gcc + - qemu-kvm + - libxml2-devel + - libxslt-devel + - libguestfs-tools-c + - vagrant + - daemonize + state: present + become: true + + - name: Start libvirtd + service: + name: libvirtd + state: started + become: true + + - name: Copy vagrant file + copy: + src: Vagrantfile + dest: /home/vagrant/Vagrantfile + owner: vagrant + group: vagrant + mode: '0644' + + - name: Execute Vagrant as daemon + command: + cmd: "daemonize -e /home/vagrant/myvmerr.log -o /home/vagrant/myvm.log -c /home/vagrant /usr/bin/vagrant up --provider=libvirt" + chdir: /home/vagrant + creates: /home/vagrant/myvm.log + + - name: Wait until the string "auth" is in the vagrant log + wait_for: + path: /home/vagrant/myvm.log + search_regex: auth + timeout: 1000 \ No newline at end of file diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..b439512 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,39 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml + roles-path: ../community +driver: + name: vagrant + provider: + name: virtualbox + +lint: yamllint . && flake8 && ansible-lint --exclude=meta +platforms: + - name: Fedora-Molecule-Virtualization + box: fedora/31-cloud-base + memory: 8000 + cpus: 4 + provider_raw_config_args: + - "customize ['modifyvm', :id, '--nested-hw-virt', 'on']" + provider_override_args: + - "persistent_storage.enabled = true" + - "persistent_storage.location = 'molecule-virtualization.vdi'" + - "persistent_storage.size = 100" + - "persistent_storage.mount = false" + - "persistent_storage.diskdevice = '/dev/sdb'" + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../..:../../../community +verifier: + name: testinfra + env: + PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning" + options: + v: 1 diff --git a/molecule/default/tests/conftest.py b/molecule/default/tests/conftest.py new file mode 100644 index 0000000..7bd2743 --- /dev/null +++ b/molecule/default/tests/conftest.py @@ -0,0 +1,21 @@ +"""PyTest Fixtures.""" +from __future__ import absolute_import +import os +import pytest + + +def pytest_runtest_setup(item): + """Run tests only when under molecule with testinfra installed.""" + try: + import testinfra + except ImportError: + pytest.skip("Test requires testinfra", allow_module_level=True) + if "MOLECULE_INVENTORY_FILE" in os.environ: + pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ["MOLECULE_INVENTORY_FILE"] + ).get_hosts("all") + else: + pytest.skip( + "Test should run only from inside molecule.", + allow_module_level=True + ) diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py new file mode 100644 index 0000000..c574fe8 --- /dev/null +++ b/molecule/default/tests/test_default.py @@ -0,0 +1,13 @@ +"""Role testing files using testinfra.""" + + +def test_vagrant_machine_is_fully_up(host): + command = """cat myvm.log | grep -c 'myvm: SSH auth method: private key'""" + cmd = host.run(command) + assert '1' in cmd.stdout + + +def test_vagrant_machine_is_running(host): + command = r"""vagrant status | egrep -c 'myvm\s*running\s\(libvirt\)'""" + cmd = host.run(command) + assert '1' in cmd.stdout diff --git a/molecule/kvm/Vagrantfile b/molecule/kvm/Vagrantfile new file mode 100644 index 0000000..313756f --- /dev/null +++ b/molecule/kvm/Vagrantfile @@ -0,0 +1,18 @@ +Vagrant.configure(2) do |config| + config.vm.provider :libvirt do |libvirt| + libvirt.memory = "512" + libvirt.cpus = 1 + libvirt.driver = "kvm" + libvirt.graphics_type = 'none' + end + + config.vm.box = "fedora/31-cloud-base" + config.vm.synced_folder ".", "/vagrant", disabled: true + + config.vm.define "myvm" do |myvm| +# myvm.vm.network :public_network, +# :dev => "virbr0", +# :mode => "bridge", +# :type => "bridge" + end +end \ No newline at end of file diff --git a/molecule/kvm/converge.yml b/molecule/kvm/converge.yml new file mode 100644 index 0000000..136a643 --- /dev/null +++ b/molecule/kvm/converge.yml @@ -0,0 +1,71 @@ +--- +- name: Converge + hosts: all + vars: + manage_lvm: true + lvm_groups: + - vgname: libvirtpool + disks: + - /dev/vdb + create: true + lvnames: [] + users_group_list: + - name: libvirt + systemusers_user_list: + - name: libvirt + group: libvirt + groups: wheel + libvirt_host_pools: + - name: libvirt_vg + type: lvm2 + source: libvirtpool + libvirt_host_networks: + - name: ansible-virtualization-bridge + mode: bridge + bridge: bridge0 + tasks: + - name: "Include ansible-virtualization" + include_role: + name: "ansible-virtualization" + + - name: "Post converge - Install vagrant" + package: + name: + - qemu + - libvirt + - ruby-devel + - gcc + - qemu-kvm + - libxml2-devel + - libxslt-devel + - libguestfs-tools-c + - vagrant + - daemonize + state: present + become: true + + - name: Start libvirtd + service: + name: libvirtd + state: started + become: true + + - name: Copy vagrant file + copy: + src: Vagrantfile + dest: /home/vagrant/Vagrantfile + owner: vagrant + group: vagrant + mode: '0644' + + - name: Execute Vagrant as daemon + command: + cmd: "daemonize -e /home/vagrant/myvmerr.log -o /home/vagrant/myvm.log -c /home/vagrant /usr/bin/vagrant up --provider=libvirt" + chdir: /home/vagrant + creates: /home/vagrant/myvm.log + + - name: Wait until the string "auth" is in the vagrant log + wait_for: + path: /home/vagrant/myvm.log + search_regex: auth + timeout: 1800 \ No newline at end of file diff --git a/molecule/kvm/molecule.yml b/molecule/kvm/molecule.yml new file mode 100644 index 0000000..7c5dd16 --- /dev/null +++ b/molecule/kvm/molecule.yml @@ -0,0 +1,36 @@ +--- +dependency: + name: galaxy + options: + role-file: requirements.yml + roles-path: ../community +driver: + name: vagrant + provider: + name: libvirt +lint: yamllint . && flake8 && ansible-lint --exclude=meta +platforms: + - name: Fedora-Molecule-virtualization + box: fedora/31-cloud-base + cpus: 2 + memory: 2048 + provider_raw_config_args: + - "storage :file, :size => '1G', :device => 'vdb'" +provisioner: + name: ansible + config_options: + defaults: + forks: 20 + ssh_connection: + pipelining: true + ssh_args: -o ControlMaster=auto -o ControlPersist=600s + env: + ANSIBLE_ROLES_PATH: ../../..:../../../community +verifier: + name: testinfra + env: + PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning" + options: + v: 1 +scenario: + name: kvm diff --git a/molecule/kvm/tests/conftest.py b/molecule/kvm/tests/conftest.py new file mode 100644 index 0000000..7bd2743 --- /dev/null +++ b/molecule/kvm/tests/conftest.py @@ -0,0 +1,21 @@ +"""PyTest Fixtures.""" +from __future__ import absolute_import +import os +import pytest + + +def pytest_runtest_setup(item): + """Run tests only when under molecule with testinfra installed.""" + try: + import testinfra + except ImportError: + pytest.skip("Test requires testinfra", allow_module_level=True) + if "MOLECULE_INVENTORY_FILE" in os.environ: + pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ["MOLECULE_INVENTORY_FILE"] + ).get_hosts("all") + else: + pytest.skip( + "Test should run only from inside molecule.", + allow_module_level=True + ) diff --git a/molecule/kvm/tests/test_default.py b/molecule/kvm/tests/test_default.py new file mode 100644 index 0000000..c574fe8 --- /dev/null +++ b/molecule/kvm/tests/test_default.py @@ -0,0 +1,13 @@ +"""Role testing files using testinfra.""" + + +def test_vagrant_machine_is_fully_up(host): + command = """cat myvm.log | grep -c 'myvm: SSH auth method: private key'""" + cmd = host.run(command) + assert '1' in cmd.stdout + + +def test_vagrant_machine_is_running(host): + command = r"""vagrant status | egrep -c 'myvm\s*running\s\(libvirt\)'""" + cmd = host.run(command) + assert '1' in cmd.stdout diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..32eef5e --- /dev/null +++ b/requirements.yml @@ -0,0 +1,5 @@ +--- +roles: + - name: tcharl.ansible_manage_lvm + source: https://galaxy.ansible.com + path: ../community diff --git a/tasks/pools.yml b/tasks/pools.yml index e3946f0..f4d041a 100644 --- a/tasks/pools.yml +++ b/tasks/pools.yml @@ -1,4 +1,12 @@ --- +- name: Include lvm role to create VG + include_role: + name: tcharl.ansible_manage_lvm + when: > + manage_lvm is defined and + manage_lvm and + libvirt_host_pools | map(attribute='type') | select('match', '^lvm2$') | join(',') | length > 0 + - name: Ensure libvirt dir storage pool directories exist file: path: "{{ item.path }}" diff --git a/tasks/post-install-Debian.yml b/tasks/post-install-Debian.yml index 0e5bfaf..03f1b00 100644 --- a/tasks/post-install-Debian.yml +++ b/tasks/post-install-Debian.yml @@ -21,7 +21,7 @@ insertafter: '^#libvirtd_opts=' regexp: '^libvirtd_opts=' line: "libvirtd_opts={{ libvirt_host_libvirtd_args }}" - condition: "{{ libvirt_host_libvirtd_args != '' }}" + condition: "{{ libvirt_host_libvirtd_args | length > 0 }}" vars: libvirt_env_path: "{{ '/etc/default/libvirt-bin' if libvirt_bin_stat.stat.exists else '/etc/default/libvirtd' }}" tags: vars From 4f7ef8df827d2afcb92c8cce9860ed94783beba2 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 12 May 2020 13:49:49 +0200 Subject: [PATCH 06/15] disable idempotence tests --- molecule/default/molecule.yml | 14 ++++++++++++++ molecule/kvm/molecule.yml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index b439512..61aec64 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -37,3 +37,17 @@ verifier: PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning" options: v: 1 + test_sequence: + - lint + - dependency + - cleanup + - destroy + - syntax + - create + - prepare + - converge + # - idempotence + - side_effect + - verify + - cleanup + - destroy diff --git a/molecule/kvm/molecule.yml b/molecule/kvm/molecule.yml index 7c5dd16..d0e45c7 100644 --- a/molecule/kvm/molecule.yml +++ b/molecule/kvm/molecule.yml @@ -34,3 +34,17 @@ verifier: v: 1 scenario: name: kvm + test_sequence: + - lint + - dependency + - cleanup + - destroy + - syntax + - create + - prepare + - converge + # - idempotence + - side_effect + - verify + - cleanup + - destroy From 366749ded01fac4feb40d11a0a6e7ba1b6dd3c64 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 12 May 2020 13:59:36 +0200 Subject: [PATCH 07/15] fix kvm role --- molecule/kvm/converge.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/molecule/kvm/converge.yml b/molecule/kvm/converge.yml index 136a643..49eb79e 100644 --- a/molecule/kvm/converge.yml +++ b/molecule/kvm/converge.yml @@ -24,9 +24,9 @@ mode: bridge bridge: bridge0 tasks: - - name: "Include ansible-virtualization" + - name: "Include ansible-role-libvirt-host" include_role: - name: "ansible-virtualization" + name: "ansible-role-libvirt-host" - name: "Post converge - Install vagrant" package: From 075a7c770b8f992e018ec1fe534abf038b688568 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Tue, 12 May 2020 20:36:24 +0200 Subject: [PATCH 08/15] remove redundant volume group task --- README.md | 12 +++++++----- molecule/default/converge.yml | 5 ++--- .../conftest.cpython-38-pytest-5.4.1.pyc | Bin 0 -> 975 bytes .../test_default.cpython-38-pytest-5.4.1.pyc | Bin 0 -> 1415 bytes molecule/kvm/converge.yml | 3 +-- tasks/pools.yml | 8 -------- 6 files changed, 10 insertions(+), 18 deletions(-) create mode 100644 molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc create mode 100644 molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc diff --git a/README.md b/README.md index 1dd79b0..f8c4dac 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ installed. Dependencies ------------ -None +* [The LVM role](https://github.com/mrlesmithjr/ansible-manage-lvm) You can install it using `ansible-galaxy install -r requirements.yml --roles-p ../community` Example Playbook ---------------- @@ -91,6 +91,11 @@ Example Playbook hosts: all roles: - role: stackhpc.libvirt-host + lvm_groups: # see according properties on [The LVM role](https://github.com/mrlesmithjr/ansible-manage-lvm) + - vgname: libvirtvg + disks: + - /dev/sdb1 + create: true libvirt_host_pools: - name: my-pool type: dir @@ -101,10 +106,7 @@ Example Playbook group: my-group - name: lvm_pool type: lvm2 - source: vg1 - target: /dev/vg1 - pvs: - - /dev/sda3 + source: libvirtvg libvirt_host_networks: - name: br-example mode: bridge diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 6c2a90f..3118f78 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,11 +4,10 @@ vars: manage_lvm: true lvm_groups: - - vgname: libvirtpool + - vgname: libvirt_vg disks: - /dev/sdb1 create: true - lvnames: [] users_group_list: - name: libvirt systemusers_user_list: @@ -18,7 +17,7 @@ libvirt_host_pools: - name: libvirt_vg type: lvm2 - source: libvirtpool + source: libvirt_vg libvirt_host_networks: - name: ansible-virtualization-bridge mode: bridge diff --git a/molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0468951250da06f9d3e87cd94a4625858809fb78 GIT binary patch literal 975 zcmZ8fO>Yx15Vf66vb#+`s47*JIIOq@so6h(P*Igil}cLm1KK@cZDWUQ>Rkuh+mHxu zT)A=J*d96Ye|+V{U*J#}Z`y#c+fIRd?5(^K>sc9p&i(I4-7*I zVwe$ubCMA3?lnpRz(MW#II5D#6t#Og{p&r z21bUAYOLmfKLgbZRFHGT8pa#duNvz710FR-%^TmnSz`;`;+udqZ?PdXELN(&{=;8J zfOIf>c3c*b0opo}g_uT@Aupn`U|dDH6ue&w9!)Ycta7qqpwcKSv`K~FtfQQc-fXjy zt@yh#1KEEwPeJ=SWXcK6C4)*-@M|uT&6kG<-QBZ;F5U0F>h?|#k1y!n{z2E)AbIw* zs-}ms6f9D}uHrRNGIz)s;|pS)_L2=8_llQY+ON9XRZ1$`7*Acqdip9GTOze>^5QyE zvat2iWI`t^DO9@zQh-r#l`OxQzo8-Uw82|$=ukpq?CJtz?r0P1WrpXf4)VVtwF<{C z5ua(Uble}NN@P5jilv2#cO~QTi7Zv0>-b2dW*}7_OReL3_-zGk-WJ&j$Jf(}*7M+83QVmK?CX0^Z69t{H v!NO&m555pSSKLyi0;sDTy$Zc**gs~iLVY%$k>_rvbPJ3J8ho^lKtb&f+kPMP literal 0 HcmV?d00001 diff --git a/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d41e228c08b55d0d1db5c85ecff9861cb2db377e GIT binary patch literal 1415 zcmdT^O^+Nk5ViYzCdon~saj1l@B z{o@N@{0N%42f)z`am)jWXTi{iRTLnMs(6-Q#6uqah-N8|c>;aLgJU#FFW&fENkObI zwyYOqUP@s|YrMVX=9*3afZ*t;fCQd@8CWT_$I#4E0FHayp-a@^HSPl*^kEl#jr*tz zyXY+G<1RKo+2AtdVHeLaANYB&j(`Jujd^V2%Vdqt67vOcX&0=q{%Y`oRR`erGb5Op zJPmK5KH(|Px}?Nlr#1ucs7u%Q2mC$eC_;S*E$$SwYUkYTx0z8|;Fz-r$Srn|GSk-H9P(O}zPF zV#eR?4D#VX-Jh7Lv0Sxw+`F)-_$Hi%u*k!G2k_w89y3O0J4`>E7*8H<#xB%t?ULeLU=5s`?YHm3A-ExzZK0RD9b=Rx=BpP3EGdGS;QAVZ~~$6S(EsHNVw1 z`M2Gb!8=zy_qLvG(08v6-rFGkD#Ur#&tXf?NlYb_e z^)Yf~OwMXko=S0`L9Pd~JUuV9J@5(U6);6BMb5>XwbJJP(9D2zM@^fR8}v-i*+Roc zv|`1wtOYF%owri1Xxl_y$}a&R9N{sJP=YcL(h<6j_K zir~b&1@fz*^iRymo!t?iO!l>ZWOV2u_TY7(eeLU!hp~ri9&UN?x4VVcz;d?-1^>&b z@3!)*|NGEygLg7=DWzN$l)CIMk?Wg2_$zcUd7MbjRsESTo$C g_HnOdI^;a0n|)9z4qE!izjekxa#5I}7f_b`2{qP^?EnA( literal 0 HcmV?d00001 diff --git a/molecule/kvm/converge.yml b/molecule/kvm/converge.yml index 49eb79e..2522b21 100644 --- a/molecule/kvm/converge.yml +++ b/molecule/kvm/converge.yml @@ -4,11 +4,10 @@ vars: manage_lvm: true lvm_groups: - - vgname: libvirtpool + - vgname: libvirt_vg disks: - /dev/vdb create: true - lvnames: [] users_group_list: - name: libvirt systemusers_user_list: diff --git a/tasks/pools.yml b/tasks/pools.yml index f4d041a..522d0dd 100644 --- a/tasks/pools.yml +++ b/tasks/pools.yml @@ -18,14 +18,6 @@ with_items: "{{ libvirt_host_pools }}" become: True -- name: Ensure libvirt lvm2 storage pool directories exist - lvg: - vg: "{{ item.source }}" - pvs: "{{ item.pvs }}" - when: item.type == "lvm2" and item.pvs is defined - with_items: "{{ libvirt_host_pools }}" - become: True - - name: Ensure libvirt storage pools are defined virt_pool: name: "{{ item.name }}" From 8253f8a888eefac68f45ffd8b4c3a629eaeaeaaa Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 13 May 2020 11:58:18 +0200 Subject: [PATCH 09/15] remove py cache --- molecule/default/converge.yml | 2 +- .../conftest.cpython-38-pytest-5.4.1.pyc | Bin 975 -> 0 bytes .../test_default.cpython-38-pytest-5.4.1.pyc | Bin 1415 -> 0 bytes molecule/kvm/converge.yml | 4 ++-- 4 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc delete mode 100644 molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 3118f78..696663d 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -15,7 +15,7 @@ group: libvirt groups: wheel libvirt_host_pools: - - name: libvirt_vg + - name: libvirtpool type: lvm2 source: libvirt_vg libvirt_host_networks: diff --git a/molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc deleted file mode 100644 index 0468951250da06f9d3e87cd94a4625858809fb78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 975 zcmZ8fO>Yx15Vf66vb#+`s47*JIIOq@so6h(P*Igil}cLm1KK@cZDWUQ>Rkuh+mHxu zT)A=J*d96Ye|+V{U*J#}Z`y#c+fIRd?5(^K>sc9p&i(I4-7*I zVwe$ubCMA3?lnpRz(MW#II5D#6t#Og{p&r z21bUAYOLmfKLgbZRFHGT8pa#duNvz710FR-%^TmnSz`;`;+udqZ?PdXELN(&{=;8J zfOIf>c3c*b0opo}g_uT@Aupn`U|dDH6ue&w9!)Ycta7qqpwcKSv`K~FtfQQc-fXjy zt@yh#1KEEwPeJ=SWXcK6C4)*-@M|uT&6kG<-QBZ;F5U0F>h?|#k1y!n{z2E)AbIw* zs-}ms6f9D}uHrRNGIz)s;|pS)_L2=8_llQY+ON9XRZ1$`7*Acqdip9GTOze>^5QyE zvat2iWI`t^DO9@zQh-r#l`OxQzo8-Uw82|$=ukpq?CJtz?r0P1WrpXf4)VVtwF<{C z5ua(Uble}NN@P5jilv2#cO~QTi7Zv0>-b2dW*}7_OReL3_-zGk-WJ&j$Jf(}*7M+83QVmK?CX0^Z69t{H v!NO&m555pSSKLyi0;sDTy$Zc**gs~iLVY%$k>_rvbPJ3J8ho^lKtb&f+kPMP diff --git a/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc deleted file mode 100644 index d41e228c08b55d0d1db5c85ecff9861cb2db377e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1415 zcmdT^O^+Nk5ViYzCdon~saj1l@B z{o@N@{0N%42f)z`am)jWXTi{iRTLnMs(6-Q#6uqah-N8|c>;aLgJU#FFW&fENkObI zwyYOqUP@s|YrMVX=9*3afZ*t;fCQd@8CWT_$I#4E0FHayp-a@^HSPl*^kEl#jr*tz zyXY+G<1RKo+2AtdVHeLaANYB&j(`Jujd^V2%Vdqt67vOcX&0=q{%Y`oRR`erGb5Op zJPmK5KH(|Px}?Nlr#1ucs7u%Q2mC$eC_;S*E$$SwYUkYTx0z8|;Fz-r$Srn|GSk-H9P(O}zPF zV#eR?4D#VX-Jh7Lv0Sxw+`F)-_$Hi%u*k!G2k_w89y3O0J4`>E7*8H<#xB%t?ULeLU=5s`?YHm3A-ExzZK0RD9b=Rx=BpP3EGdGS;QAVZ~~$6S(EsHNVw1 z`M2Gb!8=zy_qLvG(08v6-rFGkD#Ur#&tXf?NlYb_e z^)Yf~OwMXko=S0`L9Pd~JUuV9J@5(U6);6BMb5>XwbJJP(9D2zM@^fR8}v-i*+Roc zv|`1wtOYF%owri1Xxl_y$}a&R9N{sJP=YcL(h<6j_K zir~b&1@fz*^iRymo!t?iO!l>ZWOV2u_TY7(eeLU!hp~ri9&UN?x4VVcz;d?-1^>&b z@3!)*|NGEygLg7=DWzN$l)CIMk?Wg2_$zcUd7MbjRsESTo$C g_HnOdI^;a0n|)9z4qE!izjekxa#5I}7f_b`2{qP^?EnA( diff --git a/molecule/kvm/converge.yml b/molecule/kvm/converge.yml index 2522b21..1e5fced 100644 --- a/molecule/kvm/converge.yml +++ b/molecule/kvm/converge.yml @@ -15,9 +15,9 @@ group: libvirt groups: wheel libvirt_host_pools: - - name: libvirt_vg + - name: libvirtpool type: lvm2 - source: libvirtpool + source: libvirt_vg libvirt_host_networks: - name: ansible-virtualization-bridge mode: bridge From 1073181d681c95ad101b011ac65592bcb87cd5bb Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 13 May 2020 17:10:27 +0200 Subject: [PATCH 10/15] idempotence --- handlers/main.yml | 3 +-- molecule/default/converge.yml | 6 ------ molecule/default/molecule.yml | 14 -------------- .../conftest.cpython-38-pytest-5.4.1.pyc | Bin 0 -> 975 bytes .../test_default.cpython-38-pytest-5.4.1.pyc | Bin 0 -> 1415 bytes molecule/kvm/converge.yml | 6 ------ molecule/kvm/molecule.yml | 14 -------------- tasks/config.yml | 12 +++++------- 8 files changed, 6 insertions(+), 49 deletions(-) create mode 100644 molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc create mode 100644 molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc diff --git a/handlers/main.yml b/handlers/main.yml index 32e2fcc..d55203a 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -4,5 +4,4 @@ service: name: libvirtd state: restarted - enabled: yes - become: true + become: True diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 696663d..1d032e9 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -43,12 +43,6 @@ state: present become: true - - name: Start libvirtd - service: - name: libvirtd - state: started - become: true - - name: Copy vagrant file copy: src: Vagrantfile diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 61aec64..b439512 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -37,17 +37,3 @@ verifier: PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning" options: v: 1 - test_sequence: - - lint - - dependency - - cleanup - - destroy - - syntax - - create - - prepare - - converge - # - idempotence - - side_effect - - verify - - cleanup - - destroy diff --git a/molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/conftest.cpython-38-pytest-5.4.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0468951250da06f9d3e87cd94a4625858809fb78 GIT binary patch literal 975 zcmZ8fO>Yx15Vf66vb#+`s47*JIIOq@so6h(P*Igil}cLm1KK@cZDWUQ>Rkuh+mHxu zT)A=J*d96Ye|+V{U*J#}Z`y#c+fIRd?5(^K>sc9p&i(I4-7*I zVwe$ubCMA3?lnpRz(MW#II5D#6t#Og{p&r z21bUAYOLmfKLgbZRFHGT8pa#duNvz710FR-%^TmnSz`;`;+udqZ?PdXELN(&{=;8J zfOIf>c3c*b0opo}g_uT@Aupn`U|dDH6ue&w9!)Ycta7qqpwcKSv`K~FtfQQc-fXjy zt@yh#1KEEwPeJ=SWXcK6C4)*-@M|uT&6kG<-QBZ;F5U0F>h?|#k1y!n{z2E)AbIw* zs-}ms6f9D}uHrRNGIz)s;|pS)_L2=8_llQY+ON9XRZ1$`7*Acqdip9GTOze>^5QyE zvat2iWI`t^DO9@zQh-r#l`OxQzo8-Uw82|$=ukpq?CJtz?r0P1WrpXf4)VVtwF<{C z5ua(Uble}NN@P5jilv2#cO~QTi7Zv0>-b2dW*}7_OReL3_-zGk-WJ&j$Jf(}*7M+83QVmK?CX0^Z69t{H v!NO&m555pSSKLyi0;sDTy$Zc**gs~iLVY%$k>_rvbPJ3J8ho^lKtb&f+kPMP literal 0 HcmV?d00001 diff --git a/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d41e228c08b55d0d1db5c85ecff9861cb2db377e GIT binary patch literal 1415 zcmdT^O^+Nk5ViYzCdon~saj1l@B z{o@N@{0N%42f)z`am)jWXTi{iRTLnMs(6-Q#6uqah-N8|c>;aLgJU#FFW&fENkObI zwyYOqUP@s|YrMVX=9*3afZ*t;fCQd@8CWT_$I#4E0FHayp-a@^HSPl*^kEl#jr*tz zyXY+G<1RKo+2AtdVHeLaANYB&j(`Jujd^V2%Vdqt67vOcX&0=q{%Y`oRR`erGb5Op zJPmK5KH(|Px}?Nlr#1ucs7u%Q2mC$eC_;S*E$$SwYUkYTx0z8|;Fz-r$Srn|GSk-H9P(O}zPF zV#eR?4D#VX-Jh7Lv0Sxw+`F)-_$Hi%u*k!G2k_w89y3O0J4`>E7*8H<#xB%t?ULeLU=5s`?YHm3A-ExzZK0RD9b=Rx=BpP3EGdGS;QAVZ~~$6S(EsHNVw1 z`M2Gb!8=zy_qLvG(08v6-rFGkD#Ur#&tXf?NlYb_e z^)Yf~OwMXko=S0`L9Pd~JUuV9J@5(U6);6BMb5>XwbJJP(9D2zM@^fR8}v-i*+Roc zv|`1wtOYF%owri1Xxl_y$}a&R9N{sJP=YcL(h<6j_K zir~b&1@fz*^iRymo!t?iO!l>ZWOV2u_TY7(eeLU!hp~ri9&UN?x4VVcz;d?-1^>&b z@3!)*|NGEygLg7=DWzN$l)CIMk?Wg2_$zcUd7MbjRsESTo$C g_HnOdI^;a0n|)9z4qE!izjekxa#5I}7f_b`2{qP^?EnA( literal 0 HcmV?d00001 diff --git a/molecule/kvm/converge.yml b/molecule/kvm/converge.yml index 1e5fced..60243af 100644 --- a/molecule/kvm/converge.yml +++ b/molecule/kvm/converge.yml @@ -43,12 +43,6 @@ state: present become: true - - name: Start libvirtd - service: - name: libvirtd - state: started - become: true - - name: Copy vagrant file copy: src: Vagrantfile diff --git a/molecule/kvm/molecule.yml b/molecule/kvm/molecule.yml index d0e45c7..7c5dd16 100644 --- a/molecule/kvm/molecule.yml +++ b/molecule/kvm/molecule.yml @@ -34,17 +34,3 @@ verifier: v: 1 scenario: name: kvm - test_sequence: - - lint - - dependency - - cleanup - - destroy - - syntax - - create - - prepare - - converge - # - idempotence - - side_effect - - verify - - cleanup - - destroy diff --git a/tasks/config.yml b/tasks/config.yml index 52fc2f3..c4a6519 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -7,7 +7,7 @@ insertafter: '^#unix_sock_dir =' regexp: '^unix_sock_dir =' line: unix_sock_dir = "{{ libvirt_host_socket_dir }}" - become: true + become: True when: libvirt_host_socket_dir | length > 0 notify: restart libvirt @@ -18,25 +18,23 @@ owner: root group: root mode: 0755 - become: true + become: True when: libvirt_host_socket_dir | length > 0 - name: Process lineinfile rules lineinfile: "{{ rule.args }}" - become: true + become: True loop: "{{ libvirt_host_lineinfile_extra_rules | default([]) }}" loop_control: loop_var: rule when: rule.condition - notify: - - restart libvirt + notify: restart libvirt - name: Flush handlers meta: flush_handlers - name: Ensure the libvirt daemon is started and enabled - service: + systemd: name: libvirtd state: started - enabled: yes become: True From eb095478abb6b16c4d9996c7d301f97a9fca0053 Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 13 May 2020 19:19:57 +0200 Subject: [PATCH 11/15] tests on autostart and active --- handlers/main.yml | 9 +++++++ .../test_default.cpython-38-pytest-5.4.1.pyc | Bin 1415 -> 3073 bytes molecule/default/tests/test_default.py | 24 ++++++++++++++++++ molecule/kvm/tests | 1 + molecule/kvm/tests/conftest.py | 21 --------------- molecule/kvm/tests/test_default.py | 13 ---------- tasks/pools.yml | 9 +------ 7 files changed, 35 insertions(+), 42 deletions(-) create mode 120000 molecule/kvm/tests delete mode 100644 molecule/kvm/tests/conftest.py delete mode 100644 molecule/kvm/tests/test_default.py diff --git a/handlers/main.yml b/handlers/main.yml index d55203a..ba772b5 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -5,3 +5,12 @@ name: libvirtd state: restarted become: True + +- name: Ensure libvirt storage pools are active + virt_pool: + name: "{{ item.name }}" + state: active + uri: "{{ libvirt_host_uri | default(omit, true) }}" + with_items: "{{ libvirt_host_pools }}" + become: True + diff --git a/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc b/molecule/default/tests/__pycache__/test_default.cpython-38-pytest-5.4.1.pyc index d41e228c08b55d0d1db5c85ecff9861cb2db377e..82ee39e72aa2e651914890004230e7f57a4ef15f 100644 GIT binary patch delta 638 zcmZqYZj|5(<>lq-)Z7zyie(~~3}etlbt6^w6pj{#D9#kl6fPjmmBO9E1EjfAcvJX* zG*1dsFoP!l#<)c+le?Ms#l|WWm!{+^lw}qbXDAfp=jZ6=WEPhw=;|is3KS_x%*;{H%~Q}e268e|6H~w(Lm($Ly(qOnK{r`JJuWf1B(p44WpV?H zotQ{TYH>+C$msaY;`ri{#G;ba6oJY2S!5X%CU-C&jEW+~2^PdUp)$1?Y`>HQiv5YD zCHYV{h=JXp2y#PA46+;YQcI{E3ZlYbR{%{$3IrLj1C&4xh>Rq`0VIckq&TweNI{?k uasit%0|SF5?_?&{Z~+A%vq%v{D1iv&$)T)jA_71r3o{3U5CaDr3<3bOv%D+- delta 63 zcmZpaXy@h%<>lqtx?x7#6vl~MGK@wO)s0x0f*CZ~H`Xm;VbbKBoWLE Date: Wed, 13 May 2020 19:25:39 +0200 Subject: [PATCH 12/15] activate network --- handlers/main.yml | 13 +++++++++++++ tasks/networks.yml | 9 +-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index ba772b5..a903730 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -5,6 +5,7 @@ name: libvirtd state: restarted become: True + listen: restart libvirt - name: Ensure libvirt storage pools are active virt_pool: @@ -13,4 +14,16 @@ uri: "{{ libvirt_host_uri | default(omit, true) }}" with_items: "{{ libvirt_host_pools }}" become: True + listen: Ensure libvirt storage pools are active + +- name: Ensure libvirt networks are active + virt_net: + name: "{{ item.name }}" + state: active + uri: "{{ libvirt_host_uri | default(omit, true) }}" + with_items: "{{ libvirt_host_networks }}" + become: True + listen: Ensure libvirt networks are active + + diff --git a/tasks/networks.yml b/tasks/networks.yml index 3c74095..cc1aeb3 100644 --- a/tasks/networks.yml +++ b/tasks/networks.yml @@ -7,14 +7,7 @@ uri: "{{ libvirt_host_uri | default(omit, true) }}" with_items: "{{ libvirt_host_networks }}" become: True - -- name: Ensure libvirt networks are active - virt_net: - name: "{{ item.name }}" - state: active - uri: "{{ libvirt_host_uri | default(omit, true) }}" - with_items: "{{ libvirt_host_networks }}" - become: True + notify: Ensure libvirt networks are active - name: Ensure libvirt networks are started on boot virt_net: From c2953b9c3f29d2e851936d82dd6f54eeb46bfa1a Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 13 May 2020 19:28:11 +0200 Subject: [PATCH 13/15] activate network and pools in handlers --- handlers/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index a903730..da56086 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -24,6 +24,3 @@ with_items: "{{ libvirt_host_networks }}" become: True listen: Ensure libvirt networks are active - - - From 6284463c1edddf176cf72e6f736ac1c541b3987a Mon Sep 17 00:00:00 2001 From: Charlie Mordant Date: Wed, 13 May 2020 19:31:22 +0200 Subject: [PATCH 14/15] lint --- molecule/default/tests/test_default.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py index 98e8214..902d821 100644 --- a/molecule/default/tests/test_default.py +++ b/molecule/default/tests/test_default.py @@ -14,24 +14,28 @@ def test_vagrant_machine_is_running(host): def test_pool_is_started(host): - command = r""" sudo virsh pool-list --all | cut -d " " -f 5 | tail -n +3 | head -n +1 | egrep -c '^active$'""" + command = r""" sudo virsh pool-list --all | + cut -d " " -f 5 | tail -n +3 | head -n +1 | egrep -c '^active$'""" cmd = host.run(command) assert '1' in cmd.stdout def test_pool_is_autostarted(host): - command = r""" sudo virsh pool-list --all | cut -d " " -f 8 | tail -n +3 | head -n +1 | egrep -c '^yes$'""" + command = r""" sudo virsh pool-list --all | + cut -d " " -f 8 | tail -n +3 | head -n +1 | egrep -c '^yes$'""" cmd = host.run(command) assert '1' in cmd.stdout def test_net_is_started(host): - command = r""" sudo virsh net-list --all | cut -d " " -f 5 | tail -n +3 | head -n +1 | egrep -c '^active$'""" + command = r""" sudo virsh net-list --all | + cut -d " " -f 5 | tail -n +3 | head -n +1 | egrep -c '^active$'""" cmd = host.run(command) assert '1' in cmd.stdout def test_net_is_autostarted(host): - command = r""" sudo virsh net-list --all | cut -d " " -f 8 | tail -n +3 | head -n +1 | egrep -c '^yes$'""" + command = r""" sudo virsh net-list --all | + cut -d " " -f 8 | tail -n +3 | head -n +1 | egrep -c '^yes$'""" cmd = host.run(command) assert '1' in cmd.stdout From c36f6cef2cb5e944bd60128ffbb04e03ea26d86d Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 18 Jun 2020 19:19:13 +0100 Subject: [PATCH 15/15] Increase travis timeout --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c5a9ae8..e8389f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,4 @@ before_install: sudo pip3 install ansible ansible-lint sudo pip3 install -I molecule molecule-vagrant -script: travis_wait 30 sudo molecule test --scenario-name kvm \ No newline at end of file +script: travis_wait 60 sudo molecule test --scenario-name kvm