ansible-community / molecule-plugins

Collection on molecule plugins
MIT License
115 stars 75 forks source link

Allow volumes in platforms to be list of dict #167

Open isuftin opened 2 years ago

isuftin commented 2 years ago

Issue Type

Molecule and Ansible details

ansible --version && molecule --version
ansible [core 2.12.10]
  config file = /Users/isuftin/.ansible.cfg
  configured module search path = ['/Users/isuftin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/isuftin/.pyenv/versions/3.9.10/envs/development/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/isuftin/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/isuftin/.pyenv/versions/development/bin/ansible
  python version = 3.9.10 (main, Jan 31 2022, 16:09:50) [Clang 12.0.0 (clang-1200.0.32.29)]
  jinja version = 3.1.2
  libyaml = True

molecule 4.0.3 using python 3.9 
    ansible:2.12.10
    delegated:4.0.3 from molecule
    docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
    ec2:0.4 from molecule_ec2
    vagrant:1.0.0 from molecule_vagrant

Molecule installation method (one of):

Ansible installation method (one of):

Detail any linters or test runners used:

Desired Behavior

The Molecule EC2 driver uses the amazon.aws.ec2_instance module to drive machine creation. This means that if we specify volumes in a platform, it should be a list of dict, not a list of string. The latest release of Molecule mandates that volumes be a list of strings as per https://raw.githubusercontent.com/ansible-community/molecule/main/src/molecule/data/molecule.json

This breaks us being able to use the Molecule EC2 driver.

The desired behavior is to not break on the unexpected volumes param type

Actual Behaviour

Example platform:

platforms:
  - name: my-platform
    region: us-west-2
    vpc_id: vpc-xxxxxx
    vpc_subnet_id: subnet-xxxxxx
    instance_type: t3a.medim
    security_groups:
      - sg-xxxxxxxx
    aws_iam_role: xxxxxxxxx
    volumes:
      - device_name: /dev/sda1
        ebs:
          volume_size: 250
          delete_on_termination: 'true'
      - device_name: /dev/sdb
        ebs:
          volume_size: 30
          delete_on_termination: 'true'
    image: ami-xxxxxxx
    key_inject_method: ec2
molecule list

molecule lint -s CRITICAL Failed to validate /path/to/my/role/molecule/aws-marketplace-centos7-ec2/molecule.yml

["{'device_name': '/dev/sda1', 'ebs': {'volume_size': 250, 'delete_on_termination': 'true'}} is not of type 'string'"]
isuftin commented 2 years ago

Seems like this was also an issue in Molecule 4.0.2.

4.0.1 works as expected

rsicart commented 1 year ago

Same problem here.

Do you know how can be fixed?

Thanks in advance.

isuftin commented 1 year ago

@rsicart - Unfortunately I've not found any workaround for this. The only way I can figure to make this is to hard-code the EBS volumes into create.yml :(