Hello,
I am trying to make a hello world type testing with Molecule. But it seems that the Molecule documentation is outdated.
https://molecule.readthedocs.io/en/latest/
https://molecule.readthedocs.io/en/latest/installation.html has instructions from Ubuntu 16.x. But not 20.x or 22.x.
"pip is the only supported installation method." - is this still true?
"It is highly recommended that you install molecule in a virtual environment." - is this still true?
Then the documentation goes on to talk about installing like this:
python3 -m pip install --user "molecule"
I followed the documentation further, created a new role:
molecule init role acme.my_new_role --driver-name docker
cd my_new_role/
cd molecule/default/
molecule test
CRITICAL 'molecule/default/molecule.yml' glob failed. Exiting.
give this error.
What steps did I miss or do wrongly?
I am willing to send a pull request to fix the documentation. But I need to know what are the recommended ways of installing molecule and working instructions to setup a new role and test with Molecule.
-
Sudheer
Hi,
In my experience, the molecule commands need to be executed at the root of the role, therefore you should omit the second cd command:
cd my_new_role/
molecule test
should work
Regards,
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d4d16073-40e2-9549-5d18-05dbf8dcc95b%40sudheer.net.
I made some progress by adding a task in tasks.yml. It was empty before. Also edited molecule.yml.
tasks.main:
---
# tasks file for my_new_role
- name: install
apt:
name:
- apache2
update_cache: "yes"
molecule/default/molecule.yml:
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu
image: geerlingguy/docker-ubuntu2204-ansible
command: ${MOLECULE_DOCKER_COMMAND:-""}
dockerfile: Dockerfile
pre_build_image: false
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .
molecule converge throws this error:
TASK [Gathering Facts]
*********************************************************
fatal: [ubuntu]: UNREACHABLE! => {"changed": false, "msg":
"Failed to create temporary directory. In some cases, you may have
been able to authenticate and did not have permissions on the
target directory. Consider changing the remote tmp path in
ansible.cfg to a path rooted in \"/tmp\", for more error
information use -vvv. Failed command was: ( umask 77 &&
mkdir -p \"` echo ~/.ansible/tmp `\"&& mkdir \"` echo
~/.ansible/tmp/ansible-tmp-1663563273.2016175-665108-50502074545094
`\" && echo
ansible-tmp-1663563273.2016175-665108-50502074545094=\"` echo
~/.ansible/tmp/ansible-tmp-1663563273.2016175-665108-50502074545094
`\" ), exited with result 1", "unreachable": true}
Where am I supposed to set this flag?
-
Sudheer
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3e0a0af8-49e0-0f8c-92a7-4be487c69968%40cityscoot.eu.
Not sure why you need the other settings, but this works:
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu
image: geerlingguy/docker-ubuntu2204-ansible
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .
Regards,
Antuelle78
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1fb6404b-c9f2-1dac-b5a6-2783706c1db2%40sudheer.net.
If that works for you, then something is probably wrong with my environment.
I have used the same file that you mention. I still get the same error as before.
Somehow, molecule and Ansible do not seem to correctly set privileges on the container.
Failed to create temporary directory. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1663599793.08011-676381-54041244190778 `\" && echo ansible-tmp-1663599793.08011-676381-54041244190778=\"` echo ~/.ansible/tmp/ansible-tmp-1663599793.08011-676381-54041244190778 `\
exited with result 1", "unreachable": true
-
Sudheer
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cf15ab4a-8638-aa62-93e9-bce34a6b5f4d%40cityscoot.eu.
Could you post your other files please?
I could use that to compare file or maybe run your files without
changes and see what could be the issue.
Thanks.
-
Sudheer
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cf15ab4a-8638-aa62-93e9-bce34a6b5f4d%40cityscoot.eu.
I got it to work. The culprit was the `command`. I removed the line and it works now.
Thank you.
-
Sudheer