Customised molecule kubernetes doesn't work for molecule version 6.0.3 #4360
Unanswered
kiranashav
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have upgraded our molecule version from 4.0.0 to 6.0.3 and the molecule commands are not working.
We were able to execute all the molecule commands using version 4.0.0 and were able to launch pods on kubernetes. But with 6.0.3 we're not sure what changes need to be made
here's the customized tree structure
`tree molecule_kubernetes molecule_kubernetes ├── cookiecutter │ ├── cookiecutter.json │ └── {{cookiecutter.molecule_directory}} │ └── {{cookiecutter.scenario_name}} │ ├── collections.yml │ ├── converge.yml │ ├── LICENSE │ ├── molecule.yml │ └── README.md ├── driver.py ├── init.py ├── playbooks │ ├── create.yml │ └── destroy.yml └── pycache ├── driver.cpython-39.pyc └── init.cpython-39.pyc 5 directories, 12 files
Customized molecule.yml which was working for version 4.0.0
cat molecule.yml
`
dependency:
{%- if cookiecutter.dependency_name == 'galaxy' %}
name: shell
command: |
# build and install current collection and its dependencies
if test -f "../../galaxy.yml"; then
ansible-galaxy collection build ../.. --output-path $MOLECULE_EPHEMERAL_DIRECTORY --force
ansible-galaxy collection install $$(ls -1 $MOLECULE_EPHEMERAL_DIRECTORY/*.tar.gz) --force
fi
# install scenario role dependencies
if test -f "$MOLECULE_SCENARIO_DIRECTORY/requirements.yml"; then
ansible-galaxy role install -r $MOLECULE_SCENARIO_DIRECTORY/requirements.yml
fi
# install scenario collection dependencies
if test -f "$MOLECULE_SCENARIO_DIRECTORY/collections.yml"; then
ansible-galaxy collection install -r $MOLECULE_SCENARIO_DIRECTORY/collections.yml
fi
{%- else %}
name: {{ cookiecutter.dependency_name }}
{%- endif %}
driver:
name: kubernetes
namespace: ${BUILD_KUBERNETES_NAMESPACE:-molecule}
resources:
requests:
cpu: 500m
memory: 1Gi
#shares:
- name: ${BUILD_TAG}-{{ cookiecutter.role_name|replace('', '-') }}-{{ cookiecutter.scenario_name|replace('', '-') }}
mountPath: /path/to/your/shared/folder
storageClass: managed-nfs-storage
size: 10Mi
templates:
centos7:
image: abc.com/abf-centos7-init:latest
mountHostEntitlements: true
nodeSelector:
kubernetes.com/distribution: redhat7
#kubernetes.com/storage: 'true'
centos8:
image: abc.com/abf-centos8-init:latest
mountHostEntitlements: true
nodeSelector:
kubernetes.com/distribution: redhat8
#kubernetes.com/storage: 'true'
rhel7:
image: abc.com/abf-rhel7-init:latest
nodeSelector:
kubernetes.com/distribution: redhat7
#kubernetes.com/storage: 'true'
rhel8:
image: abc.com/abf-rhel8-init:latest
nodeSelector:
kubernetes.com/distribution: redhat8
#kubernetes.com/storage: 'true'
platforms:
)|lower }}
inherit_from: rhel8
prerun: false
provisioner:
name: ansible
inventory:
group_vars:
all:
stage: molecule
verifier:
name: {{ cookiecutter.verifier_name }}
(ansible-2.14.18)
`
Customized driver.py
`
import os
from molecule import logger, util
from molecule.api import Driver
from molecule.util import sysexit_with_message
from ansible_compat.ports import cache
log = logger.get_logger(name)
class Kubernetes(Driver):
def init(self, config=None):
super(Kubernetes, self).init(config)
self._name = "kubernetes"
(ansible-2.14.18)
`
Customized Collections.yml
`
collections:
version: '>=1.1.1,<2.0.0'
version: '>=1.0.0,<2.0.0'
`
Error:
WARNING Driver kubernetes does not provide a schema.
CRITICAL Failed to validate /home/monitoring/roles/prometheus/molecule/default/molecule.yml
["'kubernetes' is not one of ['azure', 'ec2', 'delegated', 'docker', 'containers', 'openstack', 'podman', 'vagrant', 'digitalocean', 'gce', 'libvirt', 'lxd', 'molecule-', 'molecule_', 'custom-', 'custom_']"]
molecule drivers
╶────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╴
default
kubernetes
molecule --version
molecule 6.0.3 using python 3.9
ansible:2.14.18
default:6.0.3 from molecule
kubernetes:0.7.2.dev2 from molecule_kubernetes
Beta Was this translation helpful? Give feedback.
All reactions