Driver vagrant does not provide a schema.
zerchevack opened this issue · 5 comments
Hello,
I try to run a simple molecule test but the creation fail with the bellow output
I think the vagrant instance is not create and this is the reason of ansible failed but i don't know why the "Create" playbook skip all tasks.
WARNING Driver vagrant does not provide a schema.
INFO default scenario test matrix: dependency, create, prepare
INFO Performing prerun with role_name_check=0...
INFO Using ~/.ansible/roles/mycompagny/linux_administration symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO Running default > dependency
WARNING Skipping, missing the requirements file.
WARNING Skipping, missing the requirements file.
INFO Running default > create
PLAY [Create] ******************************************************************
TASK [Populate instance config dict] *******************************************
skipping: [localhost]
TASK [Convert instance config dict to a list] **********************************
skipping: [localhost]
TASK [Dump instance config] ****************************************************
skipping: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=0 skipped=3 rescued=0 ignored=0
INFO Running default > prepare
PLAY [Prepare] *****************************************************************
TASK [Gather system info] ******************************************************
fatal: [instance]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname instance: Name or service not known", "unreachable": true}
PLAY RECAP *********************************************************************
instance : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
CRITICAL Ansible return code was 4, command was: ansible-playbook --inventory ~/.cache/molecule/my-app/default/inventory --skip-tags molecule-notest,notest ~/test-molecule/molecule-venv/lib/python3.10/site-packages/molecule_plugins/vagrant/playbooks/prepare.yml
My molecule.yml file :
name: galaxy
driver:
name: vagrant
provider:
name: libvirt
platforms:
- name: instance
box: generic/debian12
provisioner:
name: ansible
log: true
scenario:
name: default
verifier:
name: ansible
My converge file :
- name: Converge
hosts: all
gather_facts: false
tasks:
- name: Replace this task with one that validates your content
setup:
register: facts
- name: Show facts
debug:
var: facts
My pip module installed :
Package Version
------------------------- --------
ansible 8.4.0
ansible-compat 4.1.10
ansible-core 2.15.4
attrs 23.1.0
bracex 2.4
cffi 1.16.0
click 8.1.7
click-help-colors 0.9.2
cryptography 41.0.4
distro 1.8.0
enrich 1.2.7
Jinja2 3.1.2
jsonschema 4.19.1
jsonschema-specifications 2023.7.1
libvirt-python 9.8.0
markdown-it-py 3.0.0
MarkupSafe 2.1.3
mdurl 0.1.2
molecule 6.0.2
molecule-plugins 23.5.0
packaging 23.2
pip 22.0.2
pluggy 1.3.0
pycparser 2.21
Pygments 2.16.1
python-vagrant 1.0.0
PyYAML 6.0.1
referencing 0.30.2
resolvelib 1.0.1
rich 13.6.0
rpds-py 0.10.3
selinux 0.3.0
setuptools 59.6.0
subprocess-tee 0.4.1
wcmatch 8.5
wheel 0.37.1
My molecule version :
ansible:2.15.4
azure:23.5.0 from molecule_plugins
containers:23.5.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
default:6.0.2 from molecule
docker:23.5.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
ec2:23.5.0 from molecule_plugins
gce:23.5.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
podman:23.5.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
vagrant:23.5.0 from molecule_plugins
Could you you help me ?
Have you an idea ?
Thanks
Hi,
You should set more things for your vagrant box on your molecule.yml
file.
- Memory
- CPU
- Network and IP adresse configuration
For IP I use : 192.168.10.42
but chose apropriate one for your tests ;)
---
role_name_check: 1
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: libvirt
type: libvirt
options:
memory: 192
cpus: 2
platforms:
- name: instance
box: generic/debian12
interfaces:
- auto_config: true
network_name: private_network
type: static
ip: 192.168.10.42
groups:
- molecule_vm
provisioner:
name: ansible
log: true
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: ansible
Related: #175
@apatard This is my Response to #175
So since the docker plugin does not yet provide schema like the vagrant my only options are:
1. Ignore until a schema is provided 2. learn what schema actually is and contribute to the project
Did I miss anything?
there's a 3rd option:
- create a venv
- install ansible/molecule/-plugins in it
- take the schema from I gave you and put it into your venv
- test to check if it's fine
- report here and if fine, I'll try to open a PR soon-ish
@apatard This is my Response to #175
So since the docker plugin does not yet provide schema like the vagrant my only options are:1. Ignore until a schema is provided 2. learn what schema actually is and contribute to the project
Did I miss anything?
there's a 3rd option:
- create a venv
- install ansible/molecule/-plugins in it
- take the schema from I gave you and put it into your venv
- test to check if it's fine
- report here and if fine, I'll try to open a PR soon-ish
I got the same error as this issue is about and when I tried manually adding the json inside venv under vagrant/schema/driver.json
it didn't pick it up. Looking around a in molecule delegated driver I conclude that a the following needed to be defined in end of driver.py
:
def schema_file(self):
return os.path.join(os.path.dirname(__file__), "schema", "driver.json")
After adding it I do not get WARNING Driver vagrant does not provide a schema.
anymore. I also tested to add something wrong to see the validation is actually working (notvalid: true
) and seems fine since I got the following error:
CRITICAL Failed to validate ##REDACTED##/extensions/molecule/default/molecule.yml
["Additional properties are not allowed ('notvalid' was unexpected)"]
Versions I was using when testing this:
molecule 24.9.0 using python 3.11
ansible:2.17.4
azure:23.5.3 from molecule_plugins
containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
default:24.9.0 from molecule
docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
ec2:23.5.3 from molecule_plugins
gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
vagrant:23.5.3 from molecule_plugins