From 80a729ff181ac0bae4f0cdcb549019aea0e48eb4 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 13:48:56 +0400 Subject: [PATCH 01/24] add test --- Makefile | 25 ++++++++++++++----------- tests/molecule/default/converge.yml | 9 +++++++++ tests/molecule/default/molecule.yml | 15 +++++++++++++++ tests/molecule/default/prepare.yml | 10 ++++++++++ tests/molecule/default/verify.yml | 10 ++++++++++ 5 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 tests/molecule/default/converge.yml create mode 100644 tests/molecule/default/molecule.yml create mode 100644 tests/molecule/default/prepare.yml create mode 100644 tests/molecule/default/verify.yml diff --git a/Makefile b/Makefile index 77300e3..d26cc3e 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,29 @@ -ANSIBLE_VIRTUALENV ?= .venv -ANSIBLE_PYTHON := $(ANSIBLE_VIRTUALENV)/bin/python3 -ANSIBLE_PIP := $(ANSIBLE_PYTHON) -m pip +VIRTUALENV_VENV ?= .venv +VIRTUALENV_PYTHON := $(VIRTUALENV_VENV)/bin/python3 +VIRTUALENV_PIP := $(VIRTUALENV_PYTHON) -m pip .PHONY: help help: ## Show this help @egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' -$(ANSIBLE_VIRTUALENV): - python3 -m venv $(ANSIBLE_VIRTUALENV) - $(ANSIBLE_PYTHON) -m pip install -U pip setuptools wheel - $(ANSIBLE_PIP) install -U \ +$(VIRTUALENV_VENV): + python3 -m venv $(VIRTUALENV_VENV) + $(VIRTUALENV_PIP) install \ 'ansible-lint==6.16.1' \ 'pycodestyle==2.10.0' .PHONY: virtualenv -virtualenv: $(ANSIBLE_VIRTUALENV) ## Create local environment +virtualenv: $(VIRTUALENV_VENV) ## Create local environment .PHONY: lint lint: virtualenv ## Lint - $(ANSIBLE_VIRTUALENV)/bin/ansible-lint -v molecule_qemu - $(ANSIBLE_VIRTUALENV)/bin/pycodestyle molecule_qemu + $(VIRTUALENV_VENV)/bin/ansible-lint -v molecule_qemu + $(VIRTUALENV_VENV)/bin/pycodestyle molecule_qemu + +.PHONY: test +test: + $(VIRTUALENV_PIP) install -e . .PHONY: clean clean: ## Remove cache - rm -rf $(ANSIBLE_VIRTUALENV) build dist *.egg-info + rm -rf $(VIRTUALENV_VENV) build dist *.egg-info diff --git a/tests/molecule/default/converge.yml b/tests/molecule/default/converge.yml new file mode 100644 index 0000000..51e5d13 --- /dev/null +++ b/tests/molecule/default/converge.yml @@ -0,0 +1,9 @@ +--- +- 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: [] diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml new file mode 100644 index 0000000..da68f55 --- /dev/null +++ b/tests/molecule/default/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 + vm_network: vmnet-shared +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/default/prepare.yml b/tests/molecule/default/prepare.yml new file mode 100644 index 0000000..db0d725 --- /dev/null +++ b/tests/molecule/default/prepare.yml @@ -0,0 +1,10 @@ +--- +- name: Prepare + hosts: all + become: true + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: [] diff --git a/tests/molecule/default/verify.yml b/tests/molecule/default/verify.yml new file mode 100644 index 0000000..42689d7 --- /dev/null +++ b/tests/molecule/default/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 ae034225d5051eac4b84a875babfa7be40f990dc Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 13:53:55 +0400 Subject: [PATCH 02/24] add tests --- Makefile | 7 +++++-- tests/molecule/default/molecule.yml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d26cc3e..5262a70 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ -VIRTUALENV_VENV ?= .venv +MAKEFILE_DIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST)))) +VIRTUALENV_VENV ?= $(MAKEFILE_DIR)/.venv VIRTUALENV_PYTHON := $(VIRTUALENV_VENV)/bin/python3 VIRTUALENV_PIP := $(VIRTUALENV_PYTHON) -m pip +VIRTUALENV_MOLECULE := $(VIRTUALENV_VENV)/bin/molecule .PHONY: help help: ## Show this help @@ -21,8 +23,9 @@ lint: virtualenv ## Lint $(VIRTUALENV_VENV)/bin/pycodestyle molecule_qemu .PHONY: test -test: +test: virtualenv ## Test $(VIRTUALENV_PIP) install -e . + cd tests && $(VIRTUALENV_MOLECULE) test .PHONY: clean clean: ## Remove cache diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index da68f55..7783194 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-arm64.qcow2 image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: aarch64 - vm_network: vmnet-shared + ssh_port: 10000 provisioner: name: ansible verifier: From ff496fc4f83e28d8389a8d733a9773ec1a33405f Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 13:55:11 +0400 Subject: [PATCH 03/24] add tests ci --- .github/workflows/python-package.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 7843dfe..d3258d7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -40,6 +40,20 @@ jobs: - name: Lint with pycodestyle run: python -m pycodestyle molecule_qemu + tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Run tests + run: make test + build: runs-on: ubuntu-latest needs: [lint-ansible, lint-python] From e7ad1b3f5a69bcac3391519967816f559990aebe Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 13:59:32 +0400 Subject: [PATCH 04/24] move tests to x86 --- tests/molecule/default/molecule.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index 7783194..b889a44 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-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 + image_arch: x86_64 ssh_port: 10000 provisioner: name: ansible From eb7956fc595f78060cef28ec46f3b642f47f05f9 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:00:10 +0400 Subject: [PATCH 05/24] add qemu --- .github/workflows/python-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d3258d7..92f9d03 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -51,6 +51,9 @@ jobs: with: python-version: '3.x' + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Run tests run: make test From ab44bfc008cc6a2feebe11dda164488a1d0ae1b8 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:02:58 +0400 Subject: [PATCH 06/24] install mkisofs --- .github/workflows/python-package.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 92f9d03..2cf4701 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -54,6 +54,11 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v2 + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -yq --no-install-recommends mkisofs + - name: Run tests run: make test From 2a69c44a2be402697fa1e320b5f2690ade8a6a30 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:06:02 +0400 Subject: [PATCH 07/24] update docs --- README.md | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index f3fe46b..029818f 100644 --- a/README.md +++ b/README.md @@ -56,42 +56,36 @@ 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: 10001 - 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: 10000 - ssh_user: ubuntu + ssh_port: 10002 - 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: 10001 - ssh_user: ubuntu + ssh_port: 10003 - 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: 10002 - ssh_user: ubuntu + ssh_port: 10004 - 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: 10003 - ssh_user: ubuntu - - 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: 10004 - ssh_user: debian - - 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: 10005 - ssh_user: debian provisioner: name: ansible verifier: From ec4db6743fe73b423be093dadc5560ac5e784390 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:06:21 +0400 Subject: [PATCH 08/24] add qemu-img dep --- .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 2cf4701..1450ad8 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -57,7 +57,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -yq --no-install-recommends mkisofs + sudo apt-get install -yq --no-install-recommends mkisofs qemu-img - name: Run tests run: make test From c6f4e569f71bb9b950028d7f9dfd2fa3715983dc Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:07:18 +0400 Subject: [PATCH 09/24] fix package 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 1450ad8..e62cabb 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -57,7 +57,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -yq --no-install-recommends mkisofs qemu-img + sudo apt-get install -yq --no-install-recommends mkisofs qemu-utils - name: Run tests run: make test From 0150f6d26981a29f7484982422b3c6e395e2ecfa Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:09:58 +0400 Subject: [PATCH 10/24] add qemu --- .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 e62cabb..b300460 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -57,7 +57,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -yq --no-install-recommends mkisofs qemu-utils + sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86_64 qemu-utils - name: Run tests run: make test From 9fe7666ba86d99aa1aae38c0a9e32586e353ad29 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:11:08 +0400 Subject: [PATCH 11/24] remove qemu action --- .github/workflows/python-package.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b300460..06ed92a 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -51,9 +51,6 @@ jobs: with: python-version: '3.x' - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Install system dependencies run: | sudo apt-get update From 46e7913ebbf952f48171c729cd798736ecf9a0b7 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:13:08 +0400 Subject: [PATCH 12/24] fix package 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 06ed92a..2227778 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -54,7 +54,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86_64 qemu-utils + sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86 qemu-utils - name: Run tests run: make test From b7555b24703abc3283d1da4d7cc2aea58651fec5 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:15:00 +0400 Subject: [PATCH 13/24] rename job --- .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 2227778..611777e 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -40,7 +40,7 @@ jobs: - name: Lint with pycodestyle run: python -m pycodestyle molecule_qemu - tests: + test: runs-on: ubuntu-latest steps: From 04ffcc6bd093f551e9dc39504a24fe7f5c7d9ce6 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:18:27 +0400 Subject: [PATCH 14/24] reduce image resources --- tests/molecule/default/molecule.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index b889a44..c7bc81b 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -8,6 +8,8 @@ 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 + vm_memory: 512 + vm_disk: 1G ssh_port: 10000 provisioner: name: ansible From 310b0bc6375ff0bcdf018633b76a9e063d8784ab Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:20:46 +0400 Subject: [PATCH 15/24] increase 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 038ab3f..b124625 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: "{{ 150 * molecule_instances | length }}" search_regex: "OpenSSH" loop: "{{ molecule_instances }}" loop_control: From 3cec1de8837dde1f1cbdda78e3dfc2bccbe02cf9 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:28:58 +0400 Subject: [PATCH 16/24] increase 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 b124625..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: "{{ 150 * molecule_instances | length }}" + timeout: "{{ 600 * molecule_instances | length }}" search_regex: "OpenSSH" loop: "{{ molecule_instances }}" loop_control: From 0b1faa26648c4eacf5eb94f2d03b84bd039d5047 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 14:41:57 +0400 Subject: [PATCH 17/24] don't wait for ssh --- molecule_qemu/playbooks/create.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index 5e45734..52b2270 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -314,16 +314,16 @@ ### ssh ################################################################### - - name: Wait for SSH - ansible.builtin.wait_for: - host: "{{ molecule_instances_ipv4[item.name] }}" - port: "{{ item.ssh_port }}" - delay: 30 - timeout: "{{ 600 * molecule_instances | length }}" - search_regex: "OpenSSH" - loop: "{{ molecule_instances }}" - loop_control: - label: "{{ item.name }}" + # - name: Wait for SSH + # ansible.builtin.wait_for: + # host: "{{ molecule_instances_ipv4[item.name] }}" + # port: "{{ item.ssh_port }}" + # delay: 30 + # timeout: "{{ 60 * molecule_instances | length }}" + # search_regex: "OpenSSH" + # loop: "{{ molecule_instances }}" + # loop_control: + # label: "{{ item.name }}" ### molecule ############################################################## From f063220c5ed848bb538af5f73defdd6151629af1 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 18:03:42 +0400 Subject: [PATCH 18/24] remove ci test --- .github/workflows/python-package.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 611777e..7843dfe 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -40,25 +40,6 @@ 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 18022ba8f52fee4a70c7e4f4bb5022c7b5dedca6 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 18:16:26 +0400 Subject: [PATCH 19/24] reset ssh --- molecule_qemu/playbooks/create.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index 52b2270..038ab3f 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -314,16 +314,16 @@ ### ssh ################################################################### - # - name: Wait for SSH - # ansible.builtin.wait_for: - # host: "{{ molecule_instances_ipv4[item.name] }}" - # port: "{{ item.ssh_port }}" - # delay: 30 - # timeout: "{{ 60 * molecule_instances | length }}" - # search_regex: "OpenSSH" - # loop: "{{ molecule_instances }}" - # loop_control: - # label: "{{ item.name }}" + - name: Wait for SSH + ansible.builtin.wait_for: + host: "{{ molecule_instances_ipv4[item.name] }}" + port: "{{ item.ssh_port }}" + delay: 30 + timeout: "{{ 60 * molecule_instances | length }}" + search_regex: "OpenSSH" + loop: "{{ molecule_instances }}" + loop_control: + label: "{{ item.name }}" ### molecule ############################################################## From e0f5c106f7e1cf7f47c850598ecff8a2d9dc32c0 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 18:16:48 +0400 Subject: [PATCH 20/24] update image lists --- tests/molecule/default/molecule.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index c7bc81b..7d7dd4e 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -4,13 +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 + 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 - vm_memory: 512 - vm_disk: 1G - ssh_port: 10000 + ssh_port: 10001 provisioner: name: ansible verifier: From f9327a01d36a2f2ef9fc1635be9d24515de8dd36 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 18:37:56 +0400 Subject: [PATCH 21/24] update prepare for tests --- tests/molecule/default/prepare.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/molecule/default/prepare.yml b/tests/molecule/default/prepare.yml index db0d725..9b26ccf 100644 --- a/tests/molecule/default/prepare.yml +++ b/tests/molecule/default/prepare.yml @@ -2,9 +2,14 @@ - 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: [] + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 From 55122af67c8f0b12730791b5c105d2a4f8cf63a0 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 18:39:49 +0400 Subject: [PATCH 22/24] add template for prepare --- .../{{cookiecutter.scenario_name}}/prepare.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/molecule_qemu/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml b/molecule_qemu/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml index 3edf50e..0c87d10 100644 --- a/molecule_qemu/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml +++ b/molecule_qemu/cookiecutter/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml @@ -2,6 +2,7 @@ - name: Prepare hosts: all become: true + gather_facts: false {% raw -%} environment: @@ -9,4 +10,8 @@ https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" {%- endraw %} - tasks: [] + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 From 5119716a8a8397b6ac0c5edaf2567a401a8d9ab9 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 19:30:15 +0400 Subject: [PATCH 23/24] add ubuntu instances into test --- tests/molecule/default/molecule.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index 7d7dd4e..dfda17d 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -14,6 +14,26 @@ platforms: image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: x86_64 ssh_port: 10001 + - 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: 10002 + - 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: 10003 + - 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: 10004 + - 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: 10005 provisioner: name: ansible verifier: From a46fe5c1b03b11c3e8d5389ae298ca0c5c3a5a7a Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 20:24:33 +0400 Subject: [PATCH 24/24] increase tests suites number --- Makefile | 12 ++++++++- tests/.yamllint | 33 ++++++++++++++++++++++++ tests/molecule/default/molecule.yml | 25 ------------------ tests/molecule/user/converge.yml | 12 +++++++++ tests/molecule/user/molecule.yml | 20 ++++++++++++++ tests/molecule/user/prepare.yml | 15 +++++++++++ tests/molecule/user/verify.yml | 10 +++++++ tests/molecule/vmnet-shared/converge.yml | 12 +++++++++ tests/molecule/vmnet-shared/molecule.yml | 20 ++++++++++++++ tests/molecule/vmnet-shared/prepare.yml | 15 +++++++++++ tests/molecule/vmnet-shared/verify.yml | 10 +++++++ 11 files changed, 158 insertions(+), 26 deletions(-) create mode 100644 tests/.yamllint create mode 100644 tests/molecule/user/converge.yml create mode 100644 tests/molecule/user/molecule.yml create mode 100644 tests/molecule/user/prepare.yml create mode 100644 tests/molecule/user/verify.yml create mode 100644 tests/molecule/vmnet-shared/converge.yml create mode 100644 tests/molecule/vmnet-shared/molecule.yml create mode 100644 tests/molecule/vmnet-shared/prepare.yml create mode 100644 tests/molecule/vmnet-shared/verify.yml diff --git a/Makefile b/Makefile index 5262a70..c441a31 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,17 @@ lint: virtualenv ## Lint .PHONY: test test: virtualenv ## Test $(VIRTUALENV_PIP) install -e . - cd tests && $(VIRTUALENV_MOLECULE) test + cd tests && $(VIRTUALENV_MOLECULE) test -s default + +.PHONY: test-all +test-all: 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 .PHONY: clean clean: ## Remove cache diff --git a/tests/.yamllint b/tests/.yamllint new file mode 100644 index 0000000..8827676 --- /dev/null +++ b/tests/.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/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index dfda17d..7783194 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -9,31 +9,6 @@ platforms: 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: 10001 - - 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: 10002 - - 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: 10003 - - 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: 10004 - - 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: 10005 provisioner: name: ansible verifier: diff --git a/tests/molecule/user/converge.yml b/tests/molecule/user/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/user/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/user/molecule.yml b/tests/molecule/user/molecule.yml new file mode 100644 index 0000000..7d7dd4e --- /dev/null +++ b/tests/molecule/user/molecule.yml @@ -0,0 +1,20 @@ +--- +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: 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: 10001 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/user/prepare.yml b/tests/molecule/user/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/user/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/user/verify.yml b/tests/molecule/user/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/user/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/vmnet-shared/converge.yml b/tests/molecule/vmnet-shared/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/vmnet-shared/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/vmnet-shared/molecule.yml b/tests/molecule/vmnet-shared/molecule.yml new file mode 100644 index 0000000..74d5202 --- /dev/null +++ b/tests/molecule/vmnet-shared/molecule.yml @@ -0,0 +1,20 @@ +--- +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 + 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 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/vmnet-shared/prepare.yml b/tests/molecule/vmnet-shared/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/vmnet-shared/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/vmnet-shared/verify.yml b/tests/molecule/vmnet-shared/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/vmnet-shared/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