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

Using env in a molecule.yml isn't processed as it's marked as an array #3691

Closed
Bokazan opened this issue Oct 24, 2022 · 2 comments
Closed
Labels

Comments

@Bokazan
Copy link

Bokazan commented Oct 24, 2022

Issue Type

Using env in a molecule.yml isn't processed as it's marked as an array. Adding a - to the list doesn't solve it either.

Molecule and Ansible details

  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
molecule 4.0.2 using python 3.8 
    ansible:2.13.5
    delegated:4.0.2 from molecule
    docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0

Molecule installation method (one of):

  • pip3 using a cloudinit config

Ansible installation method (one of):

  • pip using a cloudinit config

Detail any linters or test runners used:

Desired Behavior

Before the latest patch, the molecule container was created fine and ansible ran fine on the created container.

Actual Behaviour

We are using an openldap container (docker.io/osixia/openldap:1.4.0) which requires several environment inputs:

env:
  LDAP_ORGANISATION: "blabla"
  LDAP_DOMAIN: "bla.local"
  LDAP_ADMIN_PASSWORD: "reallygoodpassword"
  LDAP_READONLY_USER: "true"
  LDAP_READONLY_USER_USERNAME: "bla_user"
  LDAP_READONLY_USER_PASSWORD: "reallygoodpassword"

When the run starts we see an error that this list isn't an array.

CRITICAL Failed to validate /default/molecule.yml

["{'LDAP_ORGANISATION': 'blabla', 'LDAP_DOMAIN': 'bla.local', 'LDAP_ADMIN_PASSWORD': 'reallygoodpassword', 'LDAP_READONLY_USER': 'true', 'LDAP_READONLY_USER_USERNAME': 'bla_user', 'LDAP_READONLY_USER_PASSWORD': 'reallygoodpassword'} is not of type 'array'"]

So we added a "-" in front:

env:
  - LDAP_ORGANISATION: "blabla"
  - LDAP_DOMAIN: "bla.local"
  - LDAP_ADMIN_PASSWORD: "reallygoodpassword"
  - LDAP_READONLY_USER: "true"
  - LDAP_READONLY_USER_USERNAME: "bla_user"
  - LDAP_READONLY_USER_PASSWORD: "reallygoodpassword"

The molecule run starts, however the container creation now fails with the error:

argument 'env' is of type <class 'list'> and we were unable to convert to dict: <class 'list'> cannot be converted to a dict

We also tried to put the env vars into a separate env.yml file, but this didn't work either.

@Bokazan Bokazan added the bug label Oct 24, 2022
@Bokazan
Copy link
Author

Bokazan commented Oct 25, 2022

Below is a sample of the molecule.yml file


dependency:
name: galaxy
lint: |
yamllint .
ansible-lint
driver:
name: docker
platforms:

  • &default_platform
    name: host1
    image: centos:7
    command: /sbin/init
    privileged: true
    networks:
    • name: site
  • name: ldaphost
    image: docker.io/osixia/openldap:1.4.0
    pre_build_image: true
    networks:
    • name: site
      env:
      LDAP_ORGANISATION: "blabla"
      LDAP_DOMAIN: "bla.local"
      LDAP_ADMIN_PASSWORD: "reallygoodpassword"
      LDAP_READONLY_USER: "true"
      LDAP_READONLY_USER_USERNAME: "bla_user"
      LDAP_READONLY_USER_PASSWORD: "reallygoodpassword"
      volumes:
    • ${MOLECULE_SCENARIO_DIRECTORY}/ldap-mock/:/container/service/slapd/assets/config/bootstrap/ldif/custom/
      groups:
    • ldap
      provisioner:
      name: ansible
      inventory:
      group_vars:
      all:
      site: test
      verifier:
      name: ansible
      scenario:
      test_sequence:
    • dependency
    • lint
    • cleanup
    • destroy
    • syntax
    • create
    • prepare
    • converge
    • side_effect
    • idempotence
    • verify
    • cleanup
    • destroy

@zhan9san
Copy link
Contributor

It may fixed by #3690

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants