Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to molecule v3 checklist #2560

Closed
ssbarnea opened this issue Feb 17, 2020 · 20 comments · Fixed by #2575
Closed

Migrating to molecule v3 checklist #2560

ssbarnea opened this issue Feb 17, 2020 · 20 comments · Fixed by #2575
Assignees
Labels
Milestone

Comments

@ssbarnea
Copy link
Member

ssbarnea commented Feb 17, 2020

How to migrate to molecule v3 (3.0a9 or newer)

Only delegated, docker and podman providers are ready, so if you use others, delay till they are updated or preferably give a hand with that.

  • remove scenario.name from molecule.yaml, from now on, only folder name determines the scenario name
  • remove lint: sections from molecule.yaml or replace them with newer syntax from documentation
  • if you use testinfra, add it as a pip dependency, is no longer installed by default
  • if you use linters, you need to add them as pip dependencies
  • (optional) rename playbook.yml to converge.yml to avoid a deprecation message

Known regressions with v3

  • TBH

When not to migrate to v3

If you use one of:

  • non-core providers like Azure, EC2, DigitalOcean, GCE, HetznerCloud, Linode, LXD, OpenStack or Vagrant, you probably do want to delay migration until they are updated. Keep in mind that as well as molecule, they are fully community supported, so if nobody steps in to help, they will be affected by bit rot and become unusable.

  • you are using goss verifier which was removed. It can still be re-implemented as a plugin, if anyone is willing to help.

@ssbarnea ssbarnea added the bug label Feb 17, 2020
@ssbarnea ssbarnea self-assigned this Feb 17, 2020
@ssbarnea ssbarnea added this to the 3.0 milestone Feb 17, 2020
@ssbarnea ssbarnea pinned this issue Feb 17, 2020
@ssbarnea ssbarnea added docs and removed bug labels Feb 17, 2020
@zeitounator
Copy link
Contributor

@ssbarnea. Shouldn't playbook.yml be renamed to converge.yml? I guess it's a typo...

@ssbarnea
Copy link
Member Author

ssbarnea commented Feb 19, 2020

@zeitounator Thanks, fixed. That is the proof that most people TLDR, really happy to get corrections.

@geerlingguy
Copy link
Contributor

Can you add a little more detail to the lint: section? E.g. maybe a link to the relevant documentation page(s)?

@hswong3i
Copy link
Contributor

@ssbarnea as per ansible-community/molecule-plugins#63, could I give a hand for molecule-vagrant?

@SirUli
Copy link

SirUli commented Feb 20, 2020

@ssbarnea The "lint" - example from the documentation with ansible-lint leads to errors, could you elaborate a little on this? Behaviour before was that if a role doesn't contain any playbook.yml then it at least verified the playbook.yml in the molecule directory of the scenario (at least that is my impression).

So configuration as this:

lint: |
    yamllint .
    ansible-lint
    flake8

ansible-lint now just shows the help since it doesn't get any parameters (this example is from a role that doesn't have a playbook.yml in the root directory). Before assuming anything: How is that planned to be? Thanks in advance!

@geerlingguy
Copy link
Contributor

geerlingguy commented Feb 20, 2020

Heh, I just started seeing new failures today as Molecule 3.0 arrived and I install via pip install molecule:

ERROR: Failed to pre-validate.

{'lint': ['must be of string type']}

Luckily for this project I already had the updated molecule.yml ready to go, but it looks like I'll need to quickly get my other projects up to speed to prevent a CI-pocalypse! See fix: https://github.com/ansible-collections/kubernetes/pull/32/files

Note that a quick fix if you don't want Molecule 3 yet (e.g. wait to migrate your tests to it), change your pip install to:

pip3 install molecule===2.22

mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing ansible-lint and molecule-inspec explicitly.
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml

Fixes: #6211
mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing ansible-lint and molecule-inspec explicitly.
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml

Fixes: #6211
mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing ansible-lint and molecule-inspec explicitly.
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml
4. Resolve some lint errors

Fixes: #6211
mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing molecule-inspec, now a separate package.
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml
4. Resolve some lint errors

Fixes: #6211
mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing molecule-inspec, now a separate package.
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml
4. Resolve some lint errors

fixes: #6211
mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing molecule-inspec and ansible-lint
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml
4. Resolve some lint errors

fixes: #6211
@mrlesmithjr
Copy link

I too am getting hammered with issues from v3 today! As @geerlingguy mentioned, CI nightmare but all is good. Working through numerous projects as well.

jobcespedes added a commit to jobcespedes/multienv that referenced this issue Feb 20, 2020
jobcespedes added a commit to jobcespedes/multienv that referenced this issue Feb 20, 2020
jobcespedes added a commit to jobcespedes/multienv that referenced this issue Feb 20, 2020
mikedep333 added a commit to mikedep333/pulp_installer that referenced this issue Feb 20, 2020
Solution:

Follow molecule 3.0 migration guide:
ansible/molecule#2560

Implementation includes:
1. Installing molecule-inspec and ansible-lint
2. Reworking lint sections of molecule.yml files
3. Renaming playbook.yml symlinks to converge.yml
4. Resolve some lint errors

fixes: #6211
@geerlingguy
Copy link
Contributor

Here's the script I used to convert all my active geerlingguy.* roles: https://gist.github.com/geerlingguy/19aace82f94b2d07a0dfb23db7345a57 (just posting in case anyone else wants a quick example and has a bunch of roles to use—it is not a generic script in any way).

@juanje
Copy link

juanje commented Apr 19, 2020

@ssbarnea I found the same issue here. I don't know if new behavior from ansible-lint, but you need to pass a playbook or path, otherwise it will fail.
As @SirUli mentioned before, it will show the help, but also it will exit with 1, which raise the error from the set -e:

$ molecule lint
--> Test matrix
    
└── default
    ├── dependency
    └── lint
[...]

Dependency completed successfully.
--> Scenario: 'default'
--> Action: 'lint'
--> Executing: set -e
yamllint .
ansible-lint
Usage: ansible-lint [options] playbook.yml [playbook2 ...]

Options:
  --version             show program's version number and exit
[...]
  -c C                  Specify configuration file to use.  Defaults to
                        ".ansible-lint"
ERROR: Lint failed: Command 'set -e
yamllint .
ansible-lint
' returned non-zero exit status 1.: Command 'set -e
yamllint .
ansible-lint
' returned non-zero exit status 1.

You can test it:

$ ansible-lint
Usage: ansible-lint [options] playbook.yml [playbook2 ...]

Options:
  --version             show program's version number and exit
[...]
  -c C                  Specify configuration file to use.  Defaults to
                        ".ansible-lint"
$ echo $?
1

I found that if you put a dot as the PATH (like in the yamllint) it works as expected. So, this instead of the current version at the templates and documentation:

lint: |
  set -e
  yamllint .
  ansible-lint .

I tested this on several roles with the following versions:

  • molecule: 3.0.2
  • ansible-lint: 4.1.0

@juanje
Copy link

juanje commented Apr 19, 2020

Sorry, I didn't realize that there was a superior version with this change reverted.
I just update the package to the version 4.2.0 and worked just fine without the dot.
Sorry for the noise and thanks for your hard work.

@ssbarnea
Copy link
Member Author

@juanje I added #2659 to address this.

jobcespedes added a commit to jobcespedes/cookiecutter-ansible-role that referenced this issue Apr 22, 2020
@decentral1se
Copy link
Contributor

molecule-hetznercloud plugin supports molecule 3.x now.

jobcespedes added a commit to jobcespedes/dockerfile_builder that referenced this issue May 4, 2020
jobcespedes added a commit to jobcespedes/dockerfile_builder that referenced this issue May 4, 2020
@ssbarnea ssbarnea unpinned this issue Jun 30, 2020
DrMeosch pushed a commit to DrMeosch/ansible-role-docker that referenced this issue Jul 24, 2020
lerwys added a commit to lnls-sirius/lnls-ansible that referenced this issue Sep 4, 2020
@malodie
Copy link
Contributor

malodie commented Sep 25, 2020

With the updated syntax, the docker container run in the documentation no longer works.
If this issue needs to be moved to the docker container itself, I can certainly comment there.

docker run --rm -it \ -v "$(pwd)":/tmp/$(basename "${PWD}"):ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -w /tmp/$(basename "${PWD}") \ quay.io/ansible/molecule:latest \ molecule test ERROR: Failed to validate. {'lint': ['must be of dict type']}

https://molecule.readthedocs.io/en/latest/examples.html

I'm finding that no matter what I try, nothing works under the lint, since it isn't qualifying as the dict type.

The docker container also doesn't recognize 'ansible' as a verifier.

This is my molecule.yml file. Ignore the extra ` at the end, it wouldn't format as code:

dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: genericansible
    image: retr0h/centos7-systemd-ansible:latest
    privileged: True
    command: /usr/sbin/init
lint: |
  set -e
  yamllint .
  ansible-lint
provisioner:
  name: ansible
verifier:
  name: ansible```

turingbeing added a commit to turingbeing/ansible-role-rhel7-stig that referenced this issue Nov 16, 2020
klyse added a commit to Innoactive/ansible-innoactive-portal-role that referenced this issue Mar 12, 2021
klyse added a commit to Innoactive/ansible-innoactive-portal-backup-role that referenced this issue Mar 12, 2021
onap-github pushed a commit to onap/oom-offline-installer that referenced this issue Apr 21, 2021
In 3.x.x version family of Molecule the 'playbook.yml' file
for 'converge' action has changed to 'converge.yml'.

Ref.: ansible/molecule#2560

Change-Id: I8710ebd5710237be138f2aff8943d6c949058dbd
Issue-ID: OOM-2722
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
onap-github pushed a commit to onap/oom-offline-installer that referenced this issue Apr 21, 2021
In Molecule 3.x.x it's no longer needed, scenario name is assumed
from its directory name.

Ref.: ansible/molecule#2560

Change-Id: I3b25dae499d4f40851ac3fe0183ee7ab913b7dd7
Issue-ID: OOM-2722
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
onap-github pushed a commit to onap/oom-offline-installer that referenced this issue Apr 22, 2021
In 3.x.x version family of Molecule the 'playbook.yml' file
for 'converge' action has changed to 'converge.yml'.

Ref.: ansible/molecule#2560

Change-Id: I8710ebd5710237be138f2aff8943d6c949058dbd
Issue-ID: OOM-2722
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
onap-github pushed a commit to onap/oom-offline-installer that referenced this issue Apr 22, 2021
In Molecule 3.x.x it's no longer needed, scenario name is assumed
from its directory name.

Ref.: ansible/molecule#2560

Change-Id: I3b25dae499d4f40851ac3fe0183ee7ab913b7dd7
Issue-ID: OOM-2722
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants