accessing a variable declared for host with {{ }} does not work

Hey guys,

If I have the following in an inventory file:

[somehostgroup]
somehost somevariable=1234

I can access the variable with:
${somevariable}

But I cannot access the variable with:
{{ somevariable }}

as I would expect. Is this expected?

Many thanks!
iordan

Hi,

which version of ansible are you using?

David

Hi David,

I'm using a package built from the devel branch a couple of days ago.
I.e. cutting edge.

Thanks!
iordan

This should be impossible as there is no legacy variable support on devel, and it’s a pretty basic declaration.

Can we see the task, template, output, etc?

– Michael

1) My inventory file:

[ec2hosts]
10.130.0.123 instance-id=i-01234567

2) My yaml file, delete-instance.yml that *works*, adapted from an
ansible example:

‘instance-id’ seems to be an invalid identifier for jinja because of the dash (‘-’) character. Take a look at: Try to rename your variable to ‘instance_id’ (replace dash ‘-’ with underscore ‘_’).

Yep, that would be it, good catch :slight_smile:

Hey,

Indeed, that does seem to be the case, thanks!

The not-so-important question of why it still worked with $() even
though that support shouldn't be there, but I'm not concerned.

Many thanks!
iordan