Search code examples
ansibletest-kitchen

Ansible + Test Kitchen: passing Array data into dependent module


I am trying to set up Ansible + Test Kitchen to test a Galaxy module for Sonatype Nexus. In order to do this, I want a dependency on geerlingguy.java and I'd like to override the default Java version by passing an array java_packages: ['java-1.8.0-openjdk'].

The doco for role dependencies states:

Role dependencies allow you to automatically pull in other roles when using a role. Role dependencies are stored in the meta/main.yml file contained within the role directory. This file should contain a list of roles and parameters to insert before the specified role, such as the following in an example roles/myapp/meta/main.yml

Examples of how to pass in scalar data follow, but no example of array or hash data follows.

I tried this two ways:

---
dependencies:
  - { role: geerlingguy.java,
      java_packages: ['java-1.8.0-openjdk'] }

also all on one line:

---
dependencies:
  - { role: geerlingguy.java, java_packages: ['java-1.8.0-openjdk'] }

In this case the java_packages seems to be ignored and the default of Java 1.7.0 is used.

I also tried this:

---
dependencies:
  - { role: geerlingguy.java,
      java_packages: 
        - java-1.8.0-openjdk }

This leads to a syntax error being emitted.

Is it even possible to pass in Array data as I'm trying to do while using Test Kitchen?


Solution

  • I was able to get this to work another way, using extra_vars in .kitchen.yml:

      extra_vars:
        java_packages: ['java-1.8.0-openjdk']