playing a role multiple time with variable

Hi all,

I created a tomcat role to create a tomcat instance.
And I’m wondering what is the best way to pass the instance parameters to it ?

My playbook looks like :

You will be able to do things like {{ instance.http_port }}

hum,

It doesn’t seem to work…
In template I get empty field
and in tasks I have the following error:

TASK: [Create instance user] **************************************************
failed: [146.159.230.242] => {“failed”: true, “item”: “”, “name”: “jira”, “rc”: 3}
msg: useradd: invalid user ID ‘{{instance.uid}}’

with the following task:

  • name: Create instance user
    user: name=$instance uid={{ instance.uid }} groups=tomcat home={{ instance.home }}/{{ instance }} system=yes

What am I doing wrong then ?

thanks

Oh, got it.

In this case the parameterized role is a string, ‘myinstance1’, which is causing the problem.

It might not work, in which case I’ll have to make some changes, but I suppose you may wish to try:

instance: ${myinstance1}

Which should be sufficient to reference the other variable.

I don’t recall offhand if this will fly:

instance: "{{ myinstance1 }}

If you are just going to apply a list of all defined instances, you might just want to have one tomcat role instead, and have it use “with_items” on the instances list variable, and loop through them inside the role instead.

This might be easier.

Many thanks !

Now I see my mistake…

Julien,