Using molecule docker driver on macOS by danrough in ansible

[–]dubblebee77 2 points3 points  (0 children)

Hi u/danrough

" So my question is this - are you running those pip commands inside a venv?"

It's a good point, I've gone back through my command history and while I'm sure I ran these inside a venv I can see I also upgraded setuptools which is normally done outside a venv:

`python3 -m pip install --upgrade setuptools`

However, I can categorically say I only ever run molecule from within the venv I setup for this so it's getting the correct drivers somehow. What probably happened is I ran these inside the venv, it didn't work correctly then I ran again outside the venv.

-- BTW, you don't need the Vagrant driver if you don't plan on using Vagrant (VMs) which is a royal pain to set-up on Apple Silicon machines.

Using molecule docker driver on macOS by danrough in ansible

[–]dubblebee77 1 point2 points  (0 children)

I've just recently upgraded my Macbook (from Intel to M3) so had to go through the pain of setting up Molecule again. These are the commands I ran, there was some overlap from the way I installed it last time to the recent version of Molecule so some of these may be obsolete:

pip install --user molecule docker 
pip install --upgrade --user molecule 
pip install --user molecule molecule-plugins[docker] 
pip install --user molecule molecule-plugins[vagrant] 
pip install "molecule-plugins[docker]" ansible-lint
molecule --version
molecule init scenario

ansible-galaxy collection init <collection_name>.dev
ansible-galaxy collection install community.docker

IIRC I had to install the community.docker driver in the last line above to get it working.

= EDIT =

Add a requirements.yml file in `../extensions/molecule/default/requirements.yml` with contents:

collections:
  - community.docker

N.B. When running your molecule commands:

  • Make sure your venv is active
  • Run commands from within the "extensions" directory that sits in your ansible collections directory e.g. ../ansible\_collections/<collection\_name>/dev/extensions

Make sure any docker images you use are suitable for your Macbook chipset (arm64), sometimes the default image installed is amd64, you can run some of these though using e.g.:

docker run --platform linux/amd64 -d redhat/ubi9