Attempting to combine sub_items and when for application deployment

26 views
Skip to first unread message

Lyle Dietz

unread,
Jan 20, 2015, 2:01:56 AM1/20/15
to ansible...@googlegroups.com
I'm trying to deploy specific Java EE EARs to a host based on what groups that host is in.

Each EAR goes in to it's own deployable directory because we're running each application component in it's own container.

What I have is:

  - name: Copy EAR
    copy:
      src: "{{ maven }}/au/com/company/{{ item.1.name }}/{{ item.1.version }}/{{ item.1.name }}-{{ item.1.version }}.ear"
      dest: /opt/company/{{ item.0.name }}/deployments/{{ item.1.name }}.ear
    with_subelements:
    - deployables
    - ears
    when: item.0.name in group_names


with the variables file containing:

maven: "{{ lookup('env', 'HOME') }}/.m2/repository"

deployables:
  - application: catalogue
    ears:
    - { name: 'catalogue-ear',         version: '0.2.0-SNAPSHOT' }


which gives the error:

  fatal: [local-int] => error while evaluating conditional: item.0.name in group_names

What I had hoped would happen is if this host is in the catalogue group then the catalogue EAR would be copied in to the specified directory.

Is the 'in' operator not supported here, or am I missing something really obvious? Is there a better way to do this?

Thanks,

Lyle

James Martin

unread,
Jan 20, 2015, 1:58:12 PM1/20/15
to ansible...@googlegroups.com
What does your group_names variable look like?

Lyle Dietz

unread,
Jan 20, 2015, 6:15:14 PM1/20/15
to ansible...@googlegroups.com
For that machine it should be ['catalogue', 'catalogue-db', 'feeds-db', 'fulfilment', 'fulfilment-db', 'ungrouped'].

I don't know why 'ungrouped' ends up on there, it isn't something I added, but I see it appear in earlier steps.

Lyle Dietz

unread,
Jan 20, 2015, 10:52:36 PM1/20/15
to ansible...@googlegroups.com
Classic PEBKAC. It should have been item.0.application instead of item.0.name.

Amazing how easily you figure things out when you spend time away from them.
Reply all
Reply to author
Forward
0 new messages