1

I couldn't run the molecule test command as it throws below error, while I can run individual commands without any errors ( Also provided --debug o/p below)

[701] Role info should contain platforms
/root/.config/pip/molecule-testing/meta/main.yml:1
{'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

[703] Should change default metadata: author
/root/.config/pip/molecule-testing/meta/main.yml:1
{'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

[703] Should change default metadata: description
/root/.config/pip/molecule-testing/meta/main.yml:1
{'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

[703] Should change default metadata: company
/root/.config/pip/molecule-testing/meta/main.yml:1...

however if I run below commands it works perfectly. So, can anyone points out why whole test is failing, what should I do?

  1. molecule create
  2. molecule list
Validation completed successfully.
Instance Name    Driver Name    Provisioner Name    Scenario Name    Created    Converged
---------------  -------------  ------------------  ---------------  ---------  -----------
instance         docker         ansible             default          true       false

  1. molecule converge
Validation completed successfully.
--> Test matrix

└── default
    ├── dependency
    ├── create
    ├── prepare
    └── converge

--> Scenario: 'default'
--> Action: 'dependency'
Skipping, missing the requirements file.
--> Scenario: 'default'
--> Action: 'create'
Skipping, instances already created.
--> Scenario: 'default'
--> Action: 'prepare'
Skipping, prepare playbook not configured.
--> Scenario: 'default'
--> Action: 'converge'

    PLAY [Converge] ****************************************************************

    TASK [Gathering Facts] *********************************************************
    ok: [instance]

    TASK [molecule-testing : Molecule Hello World!] ********************************
    ok: [instance] => {
        "msg": "Hello, World!"
    }

    PLAY RECAP *********************************************************************
    instance                   : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

  1. molecule list
 molecule list
--> Validating schema /root/.config/pip/molecule-testing/molecule/default/molecule.yml.
Validation completed successfully.
Instance Name    Driver Name    Provisioner Name    Scenario Name    Created    Converged
---------------  -------------  ------------------  ---------------  ---------  -----------
instance         docker         ansible             default          true       true
  1. molecule destroy
  2. molecule list
--> Validating schema /root/.config/pip/molecule-testing/molecule/default/molecule.yml.
Validation completed successfully.
Instance Name    Driver Name    Provisioner Name    Scenario Name    Created    Converged
---------------  -------------  ------------------  ---------------  ---------  -----------
instance         docker         ansible             default          true       false

folder structure looks like this

.
├── defaults
│   └── main.yml
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── molecule
│   └── default
│       ├── Dockerfile.j2
│       ├── INSTALL.rst
│       ├── molecule.yml
│       ├── playbook.yml
│       └── tests
│           ├── test_default.py
│           └── test_default.pyc
├── README.md
├── tasks
│   └── main.yml
└── vars
    └── main.yml

molecule.yml file is

---
dependency:
  name: galaxy
driver:
  name: docker
lint:
  name: yamllint
platforms:
  - name: instance
    image: centos:7
    privileged: true
    command: /sbin/init
    volume_mounts:
        - "/sys/fs/cgroup:/sys/fs/cgroup:ro"
provisioner:
  name: ansible
  lint:
    name: ansible-lint
scenario:
  name: default

tasks\main.yml -->

---
# tasks file for molecule-testing
- name: Molecule Hello World!
  debug:
    msg: Hello, World!

version of molecule and ansible are as follow

molecule --version
molecule, version 2.22

ansible --version
ansible 2.8.4
 config file = None
 configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
 ansible python module location = /root/molecule_ansible2.7/lib/python2.7/site-packages/ansible
 executable location = /root/molecule_ansible2.7/bin/ansible
 python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

docker images

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/centos    7                   67fa590cfc1c        4 weeks ago         202 MB

sample output of molecule --debug test is


DEBUG: COMMAND
/root/molecule_ansible2.7/bin/ansible-lint -v --exclude=/root/.cache/molecule/molecule-testing/default /root/.config/pip/molecule-testing/molecule/default/playbook.yml

    Examining /root/.config/pip/molecule-testing/molecule/default/playbook.yml of type playbook
    Examining /root/.config/pip/molecule-testing/tasks/main.yml of type tasks
    Examining /root/.config/pip/molecule-testing/handlers/main.yml of type handlers
    Examining /root/.config/pip/molecule-testing/meta/main.yml of type meta
    [701] Role info should contain platforms
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: author
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: description
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: company
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

    [703] Should change default metadata: license
    /root/.config/pip/molecule-testing/meta/main.yml:1
    {'meta/main.yml': {'__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'dependencies': [], u'galaxy_info': {u'description': u'your description', u'license': u'license (GPLv2, CC-BY, etc)', u'author': u'your name', u'company': u'your company (optional)', u'galaxy_tags': [], '__line__': 2, '__file__': u'/root/.config/pip/molecule-testing/meta/main.yml', u'min_ansible_version': 1.2}, '__line__': 1}}

An error occurred during the test sequence action: 'lint'. Cleaning up.
change198
  • 1,647
  • 3
  • 21
  • 60

1 Answers1

1

TLDR;

These are errors/good practices reported by ansible-lint that you should fix. You can run the lint stage by its own by simply launching molecule lint.

From your current output, you only need to add some info in meta/main.yml in your role.

What is happening exactly

Each molecule command (e.g. converge, create, destroy, test...) launches a series of steps (a sequence) on your role. You can see the list of steps in the output of the command as in the following example taken from your question when you ran converge:

└── default
    ├── dependency
    ├── create
    ├── prepare
    └── converge

Those sequences are configured by default but can be customized in molecule.yml in your scenario directory. You can have a look at a customization on an open source role I maintain if you are interested in the subject.

By default, a converge sequence does not contain a lint stage. So you can run your test playbook without having to verify everything.

On the other hand, the test sequence includes all of the following steps:

└── default
    ├── lint
    ├── dependency
    ├── cleanup
    ├── destroy
    ├── syntax
    ├── create
    ├── prepare
    ├── converge
    ├── idempotence
    ├── side_effect
    ├── verify
    ├── cleanup
    └── destroy

As you can see, the first is lint, which (by default again) should run yamllint on all your yml files, followed by ansible-lint on your role and test playbook and finally flake8 on your python files (testinfra tests, custom modules, custom plugin filters...).

Your full test fails because the best practice checker ansible-lint is reporting problems that you should fix. From what I can see they are quite trivial and should go away with a couple lines in your meta/main.yml

Zeitounator
  • 38,476
  • 7
  • 53
  • 66