Skip to content

Instantly share code, notes, and snippets.

@jseguillon
Last active February 8, 2021 20:56
Show Gist options
  • Save jseguillon/85572a366be475c0486337782818ab16 to your computer and use it in GitHub Desktop.
Save jseguillon/85572a366be475c0486337782818ab16 to your computer and use it in GitHub Desktop.
Molecule : from docker to kubevirt
goto venv : pip install
curl + patch apply
re-install deps
create sa
launch test pod
ssh
launch test
From 9915740f74b3928a5df44b6934c2441b482d787f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=ABl=20S=C3=A9guillon?= <joel.seguillon@gmail.com>
Date: Mon, 8 Feb 2021 21:53:11 +0100
Subject: [PATCH] goto kubevirt
---
molecule/default/converge.yml | 1 +
molecule/default/molecule.yml | 11 ++++-------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml
index ee65197..54bc65f 100644
--- a/molecule/default/converge.yml
+++ b/molecule/default/converge.yml
@@ -1,6 +1,7 @@
---
- name: Converge
hosts: all
+ become: yes
vars:
nginx_use_ppa: true
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
index 7490710..253fb4f 100644
--- a/molecule/default/molecule.yml
+++ b/molecule/default/molecule.yml
@@ -2,15 +2,12 @@
dependency:
name: galaxy
driver:
- name: docker
+ name: kubevirt
platforms:
- name: instance
- image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
- command: ${MOLECULE_DOCKER_COMMAND:-""}
- volumes:
- - /sys/fs/cgroup:/sys/fs/cgroup:ro
- privileged: true
- pre_build_image: true
+ image: "${MOLECULE_DISTRO:-quay.io/jseguillon/kubevirt-images:centos-7-x86_64-genericcloud-2009}"
+
+
provisioner:
name: ansible
playbooks:
--
2.17.1
# Dockerfile
FROM python:3.9
RUN python3 -m pip install ansible molecule molecule-kubevirt && \
ansible-galaxy collection install community.crypto && \
ansible-galaxy collection install
# Need to copy twice the source code : once for the test, once for the code we test
COPY molecule /molecule
COPY . /molecule/default/roles/geerlingguy.nginx
---
apiVersion: v1
kind: Pod
metadata:
name: molecule
labels:
app: molecule
spec:
serviceAccountName: molecule-kubevirt
containers:
- name: molecule
image: my-registry/molecule_kubevirt_runner:latest
imagePullPolicy: IfNotPresent
command: [ "molecule", "test" ]
env:
- name: PY_COLORS
value: '1'
- name: ANSIBLE_FORCE_COLOR
value: '1'
restartPolicy: Never
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: molecule-kubevirt
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: molecule-kubevirt
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubevirt.io:edit
subjects:
- kind: ServiceAccount
name: molecule-kubevirt
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: molecule-kubevirt-sec
rules:
- apiGroups:
- ""
resources:
- services
verbs: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: molecule-kubevirt-sec
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: molecule-kubevirt-sec
subjects:
- kind: ServiceAccount
name: molecule-kubevirt
namespace: default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment