From 3f2ec818b427ec4ed27d1d850381d29a141e1030 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 04:51:47 +0400 Subject: [PATCH 01/24] Revert "remove ci test" This reverts commit f063220c5ed848bb538af5f73defdd6151629af1. --- .github/workflows/python-package.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7843dfe..611777e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -40,6 +40,25 @@ jobs: - name: Lint with pycodestyle run: python -m pycodestyle molecule_qemu + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86 qemu-utils + + - name: Run tests + run: make test + build: runs-on: ubuntu-latest needs: [lint-ansible, lint-python] From f2b2a80a1f9bd4e6df58c6466b5a7b0096384c93 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 04:52:23 +0400 Subject: [PATCH 02/24] update name --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 611777e..3ac9357 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -56,7 +56,7 @@ jobs: sudo apt-get update sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86 qemu-utils - - name: Run tests + - name: Run test run: make test build: From d9b3668aec2b7949e9df503d172f37f7af2e26e3 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 04:55:22 +0400 Subject: [PATCH 03/24] use amd64 image --- tests/molecule/default/molecule.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index 7783194..a3bbeb4 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -4,11 +4,11 @@ dependency: driver: name: molecule-qemu platforms: - - name: debian-bullseye-arm64 - image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + - name: debian-bullseye-amd64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS - image_arch: aarch64 - ssh_port: 10000 + image_arch: x86_64 + ssh_port: 10001 provisioner: name: ansible verifier: From aae3d046b63c19136c7ef02774767d7ea93690fa Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 04:58:35 +0400 Subject: [PATCH 04/24] change port --- tests/molecule/default/molecule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index a3bbeb4..353003b 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -8,7 +8,7 @@ platforms: image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 - ssh_port: 10001 + ssh_port: 2022 provisioner: name: ansible verifier: From 5d7759a58cca589b4a2853769fa136c54954bf32 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 05:04:18 +0400 Subject: [PATCH 05/24] change port --- tests/molecule/default/molecule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index 353003b..504c24f 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -8,7 +8,7 @@ platforms: image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 - ssh_port: 2022 + ssh_port: 443 provisioner: name: ansible verifier: From ae25420c4635c9eabe2e923c9670c518cc99f335 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 05:07:15 +0400 Subject: [PATCH 06/24] change port --- tests/molecule/default/molecule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index 504c24f..e514504 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -8,7 +8,7 @@ platforms: image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 - ssh_port: 443 + ssh_port: 3306 provisioner: name: ansible verifier: From 552feff3ba9f55737780488e93842ee097df90da Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 05:10:14 +0400 Subject: [PATCH 07/24] extra wait --- molecule_qemu/playbooks/create.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index 038ab3f..feaa3ac 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -319,7 +319,7 @@ host: "{{ molecule_instances_ipv4[item.name] }}" port: "{{ item.ssh_port }}" delay: 30 - timeout: "{{ 60 * molecule_instances | length }}" + timeout: "{{ 6000 * molecule_instances | length }}" search_regex: "OpenSSH" loop: "{{ molecule_instances }}" loop_control: From 374ad650458ef32178c7fc2cbe051212d1f508fd Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 11:09:33 +0400 Subject: [PATCH 08/24] increase ssh wait timeout --- molecule_qemu/playbooks/create.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index feaa3ac..5e45734 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -319,7 +319,7 @@ host: "{{ molecule_instances_ipv4[item.name] }}" port: "{{ item.ssh_port }}" delay: 30 - timeout: "{{ 6000 * molecule_instances | length }}" + timeout: "{{ 600 * molecule_instances | length }}" search_regex: "OpenSSH" loop: "{{ molecule_instances }}" loop_control: From a557f7cf4fe33b345470619215303a7086f52d28 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:06:08 +0400 Subject: [PATCH 09/24] update port --- tests/molecule/default/molecule.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index e514504..353003b 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -8,7 +8,7 @@ platforms: image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 - ssh_port: 3306 + ssh_port: 2022 provisioner: name: ansible verifier: From 50f029032ac8544fb03c2642f330d752221ef289 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:10:52 +0400 Subject: [PATCH 10/24] update tests --- .github/workflows/python-package.yml | 2 +- Makefile | 16 ++++++++++------ tests/molecule/debian-amd64/converge.yml | 12 ++++++++++++ tests/molecule/debian-amd64/molecule.yml | 15 +++++++++++++++ tests/molecule/debian-amd64/prepare.yml | 15 +++++++++++++++ tests/molecule/debian-amd64/verify.yml | 10 ++++++++++ tests/molecule/debian-arm64/converge.yml | 12 ++++++++++++ tests/molecule/debian-arm64/molecule.yml | 15 +++++++++++++++ tests/molecule/debian-arm64/prepare.yml | 15 +++++++++++++++ tests/molecule/debian-arm64/verify.yml | 10 ++++++++++ tests/molecule/default/molecule.yml | 6 +++--- 11 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 tests/molecule/debian-amd64/converge.yml create mode 100644 tests/molecule/debian-amd64/molecule.yml create mode 100644 tests/molecule/debian-amd64/prepare.yml create mode 100644 tests/molecule/debian-amd64/verify.yml create mode 100644 tests/molecule/debian-arm64/converge.yml create mode 100644 tests/molecule/debian-arm64/molecule.yml create mode 100644 tests/molecule/debian-arm64/prepare.yml create mode 100644 tests/molecule/debian-arm64/verify.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 3ac9357..d452330 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -57,7 +57,7 @@ jobs: sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86 qemu-utils - name: Run test - run: make test + run: make test-amd64 build: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index c441a31..aab7c6b 100644 --- a/Makefile +++ b/Makefile @@ -22,18 +22,22 @@ lint: virtualenv ## Lint $(VIRTUALENV_VENV)/bin/ansible-lint -v molecule_qemu $(VIRTUALENV_VENV)/bin/pycodestyle molecule_qemu -.PHONY: test -test: virtualenv ## Test +.PHONY: test-amd64 +test-amd64: virtualenv ## Test $(VIRTUALENV_PIP) install -e . - cd tests && $(VIRTUALENV_MOLECULE) test -s default + cd tests && $(VIRTUALENV_MOLECULE) test -s default-amd64 -.PHONY: test-all -test-all: virtualenv ## Test +.PHONY: test-arm64 +test-arm64: virtualenv ## Test + $(VIRTUALENV_PIP) install -e . + cd tests && $(VIRTUALENV_MOLECULE) test -s default-arm64 + +.PHONY: test-network +test-network: virtualenv ## Test $(VIRTUALENV_PIP) install -e . cd tests && \ $(VIRTUALENV_MOLECULE) destroy || true && \ $(VIRTUALENV_MOLECULE) reset && \ - $(VIRTUALENV_MOLECULE) test -s default && \ $(VIRTUALENV_MOLECULE) test -s user && \ $(VIRTUALENV_MOLECULE) test -s vmnet-shared diff --git a/tests/molecule/debian-amd64/converge.yml b/tests/molecule/debian-amd64/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/debian-amd64/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/debian-amd64/molecule.yml b/tests/molecule/debian-amd64/molecule.yml new file mode 100644 index 0000000..353003b --- /dev/null +++ b/tests/molecule/debian-amd64/molecule.yml @@ -0,0 +1,15 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: debian-bullseye-amd64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: x86_64 + ssh_port: 2022 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/debian-amd64/prepare.yml b/tests/molecule/debian-amd64/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/debian-amd64/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/debian-amd64/verify.yml b/tests/molecule/debian-amd64/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/debian-amd64/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/tests/molecule/debian-arm64/converge.yml b/tests/molecule/debian-arm64/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/debian-arm64/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/debian-arm64/molecule.yml b/tests/molecule/debian-arm64/molecule.yml new file mode 100644 index 0000000..b90f85f --- /dev/null +++ b/tests/molecule/debian-arm64/molecule.yml @@ -0,0 +1,15 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + ssh_port: 2022 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/debian-arm64/prepare.yml b/tests/molecule/debian-arm64/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/debian-arm64/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/debian-arm64/verify.yml b/tests/molecule/debian-arm64/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/debian-arm64/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index 353003b..b90f85f 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -4,10 +4,10 @@ dependency: driver: name: molecule-qemu platforms: - - name: debian-bullseye-amd64 - image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS - image_arch: x86_64 + image_arch: aarch64 ssh_port: 2022 provisioner: name: ansible From d5f98ddf1968a65b1af4ec9640ea3f17cec97599 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:16:00 +0400 Subject: [PATCH 11/24] rename tests --- .github/workflows/python-package.yml | 2 +- Makefile | 20 +++---------------- .../converge.yml | 0 .../molecule.yml | 0 .../prepare.yml | 0 .../verify.yml | 0 .../converge.yml | 0 .../{user => network-user}/molecule.yml | 0 .../prepare.yml | 0 .../{debian-arm64 => network-user}/verify.yml | 0 .../{user => platform-amd64}/converge.yml | 0 .../molecule.yml | 0 .../{user => platform-amd64}/prepare.yml | 0 .../{user => platform-amd64}/verify.yml | 0 .../converge.yml | 0 .../molecule.yml | 0 .../prepare.yml | 0 .../verify.yml | 0 18 files changed, 4 insertions(+), 18 deletions(-) rename tests/molecule/{debian-amd64 => network-shared}/converge.yml (100%) rename tests/molecule/{vmnet-shared => network-shared}/molecule.yml (100%) rename tests/molecule/{debian-amd64 => network-shared}/prepare.yml (100%) rename tests/molecule/{debian-amd64 => network-shared}/verify.yml (100%) rename tests/molecule/{debian-arm64 => network-user}/converge.yml (100%) rename tests/molecule/{user => network-user}/molecule.yml (100%) rename tests/molecule/{debian-arm64 => network-user}/prepare.yml (100%) rename tests/molecule/{debian-arm64 => network-user}/verify.yml (100%) rename tests/molecule/{user => platform-amd64}/converge.yml (100%) rename tests/molecule/{debian-amd64 => platform-amd64}/molecule.yml (100%) rename tests/molecule/{user => platform-amd64}/prepare.yml (100%) rename tests/molecule/{user => platform-amd64}/verify.yml (100%) rename tests/molecule/{vmnet-shared => platform-arm64}/converge.yml (100%) rename tests/molecule/{debian-arm64 => platform-arm64}/molecule.yml (100%) rename tests/molecule/{vmnet-shared => platform-arm64}/prepare.yml (100%) rename tests/molecule/{vmnet-shared => platform-arm64}/verify.yml (100%) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d452330..9374577 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -57,7 +57,7 @@ jobs: sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86 qemu-utils - name: Run test - run: make test-amd64 + run: make test-platform-amd64 build: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index aab7c6b..339f2de 100644 --- a/Makefile +++ b/Makefile @@ -22,24 +22,10 @@ lint: virtualenv ## Lint $(VIRTUALENV_VENV)/bin/ansible-lint -v molecule_qemu $(VIRTUALENV_VENV)/bin/pycodestyle molecule_qemu -.PHONY: test-amd64 -test-amd64: virtualenv ## Test +.PHONY: test-% +test-%: virtualenv ## Test molecule scenario $(VIRTUALENV_PIP) install -e . - cd tests && $(VIRTUALENV_MOLECULE) test -s default-amd64 - -.PHONY: test-arm64 -test-arm64: virtualenv ## Test - $(VIRTUALENV_PIP) install -e . - cd tests && $(VIRTUALENV_MOLECULE) test -s default-arm64 - -.PHONY: test-network -test-network: virtualenv ## Test - $(VIRTUALENV_PIP) install -e . - cd tests && \ - $(VIRTUALENV_MOLECULE) destroy || true && \ - $(VIRTUALENV_MOLECULE) reset && \ - $(VIRTUALENV_MOLECULE) test -s user && \ - $(VIRTUALENV_MOLECULE) test -s vmnet-shared + cd tests && $(VIRTUALENV_MOLECULE) test -s $* .PHONY: clean clean: ## Remove cache diff --git a/tests/molecule/debian-amd64/converge.yml b/tests/molecule/network-shared/converge.yml similarity index 100% rename from tests/molecule/debian-amd64/converge.yml rename to tests/molecule/network-shared/converge.yml diff --git a/tests/molecule/vmnet-shared/molecule.yml b/tests/molecule/network-shared/molecule.yml similarity index 100% rename from tests/molecule/vmnet-shared/molecule.yml rename to tests/molecule/network-shared/molecule.yml diff --git a/tests/molecule/debian-amd64/prepare.yml b/tests/molecule/network-shared/prepare.yml similarity index 100% rename from tests/molecule/debian-amd64/prepare.yml rename to tests/molecule/network-shared/prepare.yml diff --git a/tests/molecule/debian-amd64/verify.yml b/tests/molecule/network-shared/verify.yml similarity index 100% rename from tests/molecule/debian-amd64/verify.yml rename to tests/molecule/network-shared/verify.yml diff --git a/tests/molecule/debian-arm64/converge.yml b/tests/molecule/network-user/converge.yml similarity index 100% rename from tests/molecule/debian-arm64/converge.yml rename to tests/molecule/network-user/converge.yml diff --git a/tests/molecule/user/molecule.yml b/tests/molecule/network-user/molecule.yml similarity index 100% rename from tests/molecule/user/molecule.yml rename to tests/molecule/network-user/molecule.yml diff --git a/tests/molecule/debian-arm64/prepare.yml b/tests/molecule/network-user/prepare.yml similarity index 100% rename from tests/molecule/debian-arm64/prepare.yml rename to tests/molecule/network-user/prepare.yml diff --git a/tests/molecule/debian-arm64/verify.yml b/tests/molecule/network-user/verify.yml similarity index 100% rename from tests/molecule/debian-arm64/verify.yml rename to tests/molecule/network-user/verify.yml diff --git a/tests/molecule/user/converge.yml b/tests/molecule/platform-amd64/converge.yml similarity index 100% rename from tests/molecule/user/converge.yml rename to tests/molecule/platform-amd64/converge.yml diff --git a/tests/molecule/debian-amd64/molecule.yml b/tests/molecule/platform-amd64/molecule.yml similarity index 100% rename from tests/molecule/debian-amd64/molecule.yml rename to tests/molecule/platform-amd64/molecule.yml diff --git a/tests/molecule/user/prepare.yml b/tests/molecule/platform-amd64/prepare.yml similarity index 100% rename from tests/molecule/user/prepare.yml rename to tests/molecule/platform-amd64/prepare.yml diff --git a/tests/molecule/user/verify.yml b/tests/molecule/platform-amd64/verify.yml similarity index 100% rename from tests/molecule/user/verify.yml rename to tests/molecule/platform-amd64/verify.yml diff --git a/tests/molecule/vmnet-shared/converge.yml b/tests/molecule/platform-arm64/converge.yml similarity index 100% rename from tests/molecule/vmnet-shared/converge.yml rename to tests/molecule/platform-arm64/converge.yml diff --git a/tests/molecule/debian-arm64/molecule.yml b/tests/molecule/platform-arm64/molecule.yml similarity index 100% rename from tests/molecule/debian-arm64/molecule.yml rename to tests/molecule/platform-arm64/molecule.yml diff --git a/tests/molecule/vmnet-shared/prepare.yml b/tests/molecule/platform-arm64/prepare.yml similarity index 100% rename from tests/molecule/vmnet-shared/prepare.yml rename to tests/molecule/platform-arm64/prepare.yml diff --git a/tests/molecule/vmnet-shared/verify.yml b/tests/molecule/platform-arm64/verify.yml similarity index 100% rename from tests/molecule/vmnet-shared/verify.yml rename to tests/molecule/platform-arm64/verify.yml From 7ce5dd3975abfa6c34de674104005334a41e6284 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:22:27 +0400 Subject: [PATCH 12/24] add os-tests --- tests/molecule/network-shared/molecule.yml | 10 +++++----- tests/molecule/network-user/molecule.yml | 10 +++++----- .../molecule/os-debian-bullseye/converge.yml | 12 +++++++++++ .../molecule/os-debian-bullseye/molecule.yml | 20 +++++++++++++++++++ tests/molecule/os-debian-bullseye/prepare.yml | 15 ++++++++++++++ tests/molecule/os-debian-bullseye/verify.yml | 10 ++++++++++ tests/molecule/os-ubuntu-focal/converge.yml | 12 +++++++++++ tests/molecule/os-ubuntu-focal/molecule.yml | 20 +++++++++++++++++++ tests/molecule/os-ubuntu-focal/prepare.yml | 15 ++++++++++++++ tests/molecule/os-ubuntu-focal/verify.yml | 10 ++++++++++ tests/molecule/os-ubuntu-jammy/converge.yml | 12 +++++++++++ tests/molecule/os-ubuntu-jammy/molecule.yml | 20 +++++++++++++++++++ tests/molecule/os-ubuntu-jammy/prepare.yml | 15 ++++++++++++++ tests/molecule/os-ubuntu-jammy/verify.yml | 10 ++++++++++ 14 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 tests/molecule/os-debian-bullseye/converge.yml create mode 100644 tests/molecule/os-debian-bullseye/molecule.yml create mode 100644 tests/molecule/os-debian-bullseye/prepare.yml create mode 100644 tests/molecule/os-debian-bullseye/verify.yml create mode 100644 tests/molecule/os-ubuntu-focal/converge.yml create mode 100644 tests/molecule/os-ubuntu-focal/molecule.yml create mode 100644 tests/molecule/os-ubuntu-focal/prepare.yml create mode 100644 tests/molecule/os-ubuntu-focal/verify.yml create mode 100644 tests/molecule/os-ubuntu-jammy/converge.yml create mode 100644 tests/molecule/os-ubuntu-jammy/molecule.yml create mode 100644 tests/molecule/os-ubuntu-jammy/prepare.yml create mode 100644 tests/molecule/os-ubuntu-jammy/verify.yml diff --git a/tests/molecule/network-shared/molecule.yml b/tests/molecule/network-shared/molecule.yml index 74d5202..1e3d3ce 100644 --- a/tests/molecule/network-shared/molecule.yml +++ b/tests/molecule/network-shared/molecule.yml @@ -4,16 +4,16 @@ dependency: driver: name: molecule-qemu platforms: - - name: debian-bullseye-arm64 - image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 - image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS - image_arch: aarch64 - vm_network: vmnet-shared - name: debian-bullseye-amd64 image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 vm_network: vmnet-shared + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + vm_network: vmnet-shared provisioner: name: ansible verifier: diff --git a/tests/molecule/network-user/molecule.yml b/tests/molecule/network-user/molecule.yml index 7d7dd4e..27d0757 100644 --- a/tests/molecule/network-user/molecule.yml +++ b/tests/molecule/network-user/molecule.yml @@ -4,15 +4,15 @@ dependency: driver: name: molecule-qemu platforms: - - name: debian-bullseye-arm64 - image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 - image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS - image_arch: aarch64 - ssh_port: 10000 - name: debian-bullseye-amd64 image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 + ssh_port: 10000 + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 ssh_port: 10001 provisioner: name: ansible diff --git a/tests/molecule/os-debian-bullseye/converge.yml b/tests/molecule/os-debian-bullseye/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/os-debian-bullseye/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/os-debian-bullseye/molecule.yml b/tests/molecule/os-debian-bullseye/molecule.yml new file mode 100644 index 0000000..27d0757 --- /dev/null +++ b/tests/molecule/os-debian-bullseye/molecule.yml @@ -0,0 +1,20 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: debian-bullseye-amd64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: x86_64 + ssh_port: 10000 + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + ssh_port: 10001 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/os-debian-bullseye/prepare.yml b/tests/molecule/os-debian-bullseye/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/os-debian-bullseye/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/os-debian-bullseye/verify.yml b/tests/molecule/os-debian-bullseye/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/os-debian-bullseye/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/tests/molecule/os-ubuntu-focal/converge.yml b/tests/molecule/os-ubuntu-focal/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/os-ubuntu-focal/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/os-ubuntu-focal/molecule.yml b/tests/molecule/os-ubuntu-focal/molecule.yml new file mode 100644 index 0000000..3c06a7f --- /dev/null +++ b/tests/molecule/os-ubuntu-focal/molecule.yml @@ -0,0 +1,20 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: ubuntu-focal-amd64 + image: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img + image_checksum: sha256:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS + image_arch: x86_64 + ssh_port: 10000 + - name: ubuntu-focal-arm64 + image: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img + image_checksum: sha256:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS + image_arch: aarch64 + ssh_port: 10001 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/os-ubuntu-focal/prepare.yml b/tests/molecule/os-ubuntu-focal/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/os-ubuntu-focal/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/os-ubuntu-focal/verify.yml b/tests/molecule/os-ubuntu-focal/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/os-ubuntu-focal/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/tests/molecule/os-ubuntu-jammy/converge.yml b/tests/molecule/os-ubuntu-jammy/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/os-ubuntu-jammy/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/os-ubuntu-jammy/molecule.yml b/tests/molecule/os-ubuntu-jammy/molecule.yml new file mode 100644 index 0000000..2f204ce --- /dev/null +++ b/tests/molecule/os-ubuntu-jammy/molecule.yml @@ -0,0 +1,20 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: ubuntu-jammy-amd64 + image: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img + image_checksum: sha256:https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS + image_arch: x86_64 + ssh_port: 10000 + - name: ubuntu-jammy-arm64 + image: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img + image_checksum: sha256:https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS + image_arch: aarch64 + ssh_port: 10001 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/os-ubuntu-jammy/prepare.yml b/tests/molecule/os-ubuntu-jammy/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/os-ubuntu-jammy/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/os-ubuntu-jammy/verify.yml b/tests/molecule/os-ubuntu-jammy/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/os-ubuntu-jammy/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true From 60b703be55339300f889004c68d5761d99320eb5 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:25:36 +0400 Subject: [PATCH 13/24] add tests --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 339f2de..1a93fe7 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,15 @@ test-%: virtualenv ## Test molecule scenario $(VIRTUALENV_PIP) install -e . cd tests && $(VIRTUALENV_MOLECULE) test -s $* +.PHONY: test-network +test-network: test-network-shared test-network-user ## Test network + +.PHONY: test-os +test-os: test-os-debian-bullseye test-os-ubuntu-focal test-os-ubuntu-jammy ## Test OS + +.PHONY: test-platform +test-platform: test-platform-amd64 test-platform-arm64 ## Test platform + .PHONY: clean clean: ## Remove cache rm -rf $(VIRTUALENV_VENV) build dist *.egg-info From 1ffdfd56c17c293db04a67a32257586a7c679a42 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:33:16 +0400 Subject: [PATCH 14/24] add default test --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1a93fe7..71b96fc 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,13 @@ lint: virtualenv ## Lint $(VIRTUALENV_VENV)/bin/ansible-lint -v molecule_qemu $(VIRTUALENV_VENV)/bin/pycodestyle molecule_qemu +.PHONY: test ## Test +test: + $(VIRTUALENV_PIP) install -e . + cd tests && $(VIRTUALENV_MOLECULE) test + .PHONY: test-% -test-%: virtualenv ## Test molecule scenario +test-%: virtualenv $(VIRTUALENV_PIP) install -e . cd tests && $(VIRTUALENV_MOLECULE) test -s $* From b325d7380111670696c97436ec602bdfef8032dc Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:34:37 +0400 Subject: [PATCH 15/24] add test dependency for build --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 9374577..6581011 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -61,7 +61,7 @@ jobs: build: runs-on: ubuntu-latest - needs: [lint-ansible, lint-python] + needs: [lint-ansible, lint-python, test] steps: - uses: actions/checkout@v3 From 04d6f5da7efc96eb8d8357b61c33ea59d3caff5f Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:41:57 +0400 Subject: [PATCH 16/24] claim support for ubuntu 22.04 --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a1e11d..6427899 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # `molecule-qemu` -The development of the Molecule QEMU driver was motivated by the author's choice of the Apple M1 as their primary development machine. He wanted to test Ansible roles on the Apple M1 but preferred not to rely on `Docker` for testing due to challenges with Docker's `systemd` support. Author never liked to install supplementary software such as `Vagrant` and `VirtualBox` on development machine. Author is aware of `libvirt` and `virt-manager` but their complexity and the lack of support was frustrating. +The development of the Molecule `QEMU` driver was motivated by the author's choice of the Apple M1 as their primary development machine. He wanted to test Ansible roles on the Apple M1 but preferred not to rely on `Docker` for testing due to challenges with Docker's `systemd` support. Author never liked to install supplementary software such as `Vagrant` and `VirtualBox` on development machine. Author is aware of `libvirt` and `virt-manager` but their complexity and the lack of support was frustrating. Supported platforms: * MacOS 13.x (aaarch64) +* Ubuntu 22.04 LTS (x86_64) Support guest OS: * Ubuntu 20.04 LTS (aarch64, x86_64) @@ -24,6 +25,12 @@ Install QEMU and CDRTools on macOS: brew install qemu cdrtools ``` +Install QEMU on Ubuntu: + +```bash +apt-get install mkisofs qemu-system-x86 qemu-utils +``` + ## Network modes Network mode is selected by setting `vm_network` in `molecule.yml`. Supported modes are: `user` and `vmnet-shared`. Default mode is `user`. All modes are mutually exclusive. From 7ae08160b9a93c9ca4cbf8aa9a07a60c0f34e2b3 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:42:52 +0400 Subject: [PATCH 17/24] update platforms list --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6427899..ac589ae 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ The development of the Molecule `QEMU` driver was motivated by the author's choice of the Apple M1 as their primary development machine. He wanted to test Ansible roles on the Apple M1 but preferred not to rely on `Docker` for testing due to challenges with Docker's `systemd` support. Author never liked to install supplementary software such as `Vagrant` and `VirtualBox` on development machine. Author is aware of `libvirt` and `virt-manager` but their complexity and the lack of support was frustrating. Supported platforms: -* MacOS 13.x (aaarch64) -* Ubuntu 22.04 LTS (x86_64) +* MacOS 13.x (arm64) +* Ubuntu 22.04 LTS (amd64) Support guest OS: -* Ubuntu 20.04 LTS (aarch64, x86_64) -* Ubuntu 22.04 LTS (aarch64, x86_64) -* Debian 11 (aarch64, x86_64) +* Debian 11 (arm64, amd64) +* Ubuntu 20.04 LTS (arm64, amd64) +* Ubuntu 22.04 LTS (arm64, amd64) Support of other platforms and guest OS is possible, but not tested. Please, open an issue if you want to add support for other platforms. From 9bae1a2559c990c308b3df23ca16e8a643bcb0f9 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:44:43 +0400 Subject: [PATCH 18/24] update readme --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac589ae..9208a02 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The development of the Molecule `QEMU` driver was motivated by the author's choi Supported platforms: * MacOS 13.x (arm64) -* Ubuntu 22.04 LTS (amd64) +* Ubuntu 22.04 LTS (amd64) (tested on GitHub Actions) Support guest OS: * Debian 11 (arm64, amd64) @@ -13,6 +13,10 @@ Support guest OS: Support of other platforms and guest OS is possible, but not tested. Please, open an issue if you want to add support for other platforms. +Supported network modes: +* `user` - QEMU's user networking mode +* `vmnet-shared` - QEMU's `vmnet-shared` networking mode (MacOS only) + ## Usage ```bash @@ -33,8 +37,6 @@ apt-get install mkisofs qemu-system-x86 qemu-utils ## Network modes -Network mode is selected by setting `vm_network` in `molecule.yml`. Supported modes are: `user` and `vmnet-shared`. Default mode is `user`. All modes are mutually exclusive. - ### `user` network mode This is the default network mode. It uses QEMU's user networking mode. From f90b8cb15a8e9cfbec1c52bf0cf9a021e375e5d8 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:46:04 +0400 Subject: [PATCH 19/24] update readme --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9208a02..36f1bf1 100644 --- a/README.md +++ b/README.md @@ -128,20 +128,24 @@ verifier: name: ansible ``` -# Cloud Images +# Cloud Images URLs + +For convenience, here are the URLs for the cloud images used in the examples above. + +## [Debian](https://cloud.debian.org/images/cloud/) +* https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + * https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 + * https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 ## [Ubuntu](https://cloud-images.ubuntu.com/) -* https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img -* https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img * https://cloud-images.ubuntu.com/focal/current/SHA256SUMS -* https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img -* https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img + * https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img + * https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img * https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS + * https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img + * https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img + -## [Debian](https://cloud.debian.org/images/cloud/) -* https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 -* https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 -* https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS # Reference From 81cb962db863767321619782f9f4bb8dd285101d Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:48:19 +0400 Subject: [PATCH 20/24] link tests as examples --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 36f1bf1..9201876 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ Mode is selected by setting `vm_network: vmnet-shared` in `molecule.yml`. # Examples +See [tests](https://github.com/andreygubarev/molecule-qemu/tree/main/tests/molecule) for more examples. + ## Example scenario ```bash molecule init scenario default --driver-name molecule-qemu --verifier-name testinfra From e4fa5f8d37217f2ff3c313e366bfcfa2405c32d6 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:51:40 +0400 Subject: [PATCH 21/24] refactor quick start --- README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9201876..dbfaef0 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,21 @@ Supported network modes: * `user` - QEMU's user networking mode * `vmnet-shared` - QEMU's `vmnet-shared` networking mode (MacOS only) -## Usage +## Quick start +Install `molecule-qemu` python package: ```bash pip install molecule-qemu ``` +Create a new Molecule scenario using `molecule init` command: + +```bash +molecule init scenario default --driver-name molecule-qemu --verifier-name testinfra +``` + +### Dependencies + Install QEMU and CDRTools on macOS: ```bash @@ -53,11 +62,6 @@ Mode is selected by setting `vm_network: vmnet-shared` in `molecule.yml`. See [tests](https://github.com/andreygubarev/molecule-qemu/tree/main/tests/molecule) for more examples. -## Example scenario -```bash -molecule init scenario default --driver-name molecule-qemu --verifier-name testinfra -``` - ## Example `molecule.yml` for `user` network mode ```yaml From 01fd3e569cfc3da8c94d464c82167acc0e80940a Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:52:37 +0400 Subject: [PATCH 22/24] add platforms --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index dbfaef0..b5b74c7 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,17 @@ Create a new Molecule scenario using `molecule init` command: molecule init scenario default --driver-name molecule-qemu --verifier-name testinfra ``` +Edit `molecule.yml` and add platforms: + +```yaml +platforms: + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + ssh_port: 2022 +``` + ### Dependencies Install QEMU and CDRTools on macOS: From 9e190cd76136ad2acf9121974faef993484ad592 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 12:58:26 +0400 Subject: [PATCH 23/24] rework samples and examples --- README.md | 72 +++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index b5b74c7..67ccaf7 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,24 @@ molecule init scenario default --driver-name molecule-qemu --verifier-name testi Edit `molecule.yml` and add platforms: ```yaml +--- +dependency: + name: galaxy +driver: + name: molecule-qemu platforms: - name: debian-bullseye-arm64 image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: aarch64 - ssh_port: 2022 + vm_network: vmnet-shared +provisioner: + name: ansible + inventory: + host_vars: + debian-bullseye-arm64: {} +verifier: + name: testinfra ``` ### Dependencies @@ -61,26 +73,37 @@ apt-get install mkisofs qemu-system-x86 qemu-utils This is the default network mode. It uses QEMU's user networking mode. -Mode is selected by setting `vm_network: user` in `molecule.yml`. +Mode is selected by setting `vm_network: user` in `molecule.yml`. Example: + +```yaml +- name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + ssh_port: 2022 +``` ### `vmnet-shared` network mode This mode uses QEMU's `vmnet-shared` networking mode. It requires `vmnet.framework` to be installed on the host. This mode is only supported on MacOS. It requires *passwordless* `sudo` access for current user. -Mode is selected by setting `vm_network: vmnet-shared` in `molecule.yml`. +Mode is selected by setting `vm_network: vmnet-shared` in `molecule.yml`. Example: + +```yaml +- name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + vm_network: vmnet-shared +``` # Examples See [tests](https://github.com/andreygubarev/molecule-qemu/tree/main/tests/molecule) for more examples. -## Example `molecule.yml` for `user` network mode +## Sample platforms configuration ```yaml ---- -dependency: - name: galaxy -driver: - name: molecule-qemu platforms: - name: debian-bullseye-arm64 image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 @@ -112,37 +135,6 @@ platforms: image_checksum: sha256:https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS image_arch: x86_64 ssh_port: 10005 -provisioner: - name: ansible -verifier: - name: ansible -``` - -## Example `molecule.yml` for `vmnet-shared` network mode - -```yaml ---- -dependency: - name: galaxy -driver: - name: molecule-qemu -platforms: - - name: ubuntu-1 - image: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img - image_checksum: sha256:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS - image_arch: aarch64 - ssh_user: ubuntu - vm_network: vmnet-shared - - name: ubuntu-2 - image: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img - image_checksum: sha256:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS - image_arch: x86_64 # default - ssh_user: ubuntu - vm_network: vmnet-shared -provisioner: - name: ansible -verifier: - name: ansible ``` # Cloud Images URLs From 5e3604e3a1a47f6e2beda6b85f37c3a0b4890956 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Sat, 17 Jun 2023 13:01:33 +0400 Subject: [PATCH 24/24] update docs about user mode --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 67ccaf7..dbe47df 100644 --- a/README.md +++ b/README.md @@ -73,13 +73,14 @@ apt-get install mkisofs qemu-system-x86 qemu-utils This is the default network mode. It uses QEMU's user networking mode. -Mode is selected by setting `vm_network: user` in `molecule.yml`. Example: +Mode is selected by setting `vm_network: user` in `molecule.yml`. This is the default mode. SSH port is forwarded to the host and must be unique for each platform (use `ssh_port` option to set it). Example: ```yaml - name: debian-bullseye-arm64 image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: aarch64 + vm_network: user # this is the default ssh_port: 2022 ```