Variable substitution problem in task name

Hi,

I have a problem with the Variable substitution in task name, like:

  • name: VPC | Write public subnets id to ‘{{ vpc_name }}’_vpc_info.yml file
    local_action: shell echo “{{ item.id }}” > ./vars/{{ item.resource_tags.Name }}.yml
    with_items: vpc.subnets

But when I run this playbook, it gave me the result like this:

TASK: [VPC | Write public subnets id to ‘{{ vpc_name }}’_vpc_info.yml file] ***

changed: [localhost → 127.0.0.1] => (item={u’resource_tags’: {u’Name’: u’tendo_public_subnet’}, u’cidr’: u’172.25.10.0/24’, u’az’: u’ap-southeast-2a’, u’id’: u’subnet-947bbce3’})
changed: [localhost → 127.0.0.1] => (item={u’resource_tags’: {u’Name’: u’tendo_private_subnet’}, u’cidr’: u’172.25.20.0/24’, u’az’: u’ap-southeast-2b’, u’id’: u’subnet-5be23b3e’})

instead it should give result like this, which i expect:

TASK: [VPC | Write public subnets id to tendo_vpc_info.yml file] ***

changed: [localhost → 127.0.0.1] => (item={u’resource_tags’: {u’Name’: u’tendo_public_subnet’}, u’cidr’: u’172.25.10.0/24’, u’az’: u’ap-southeast-2a’, u’id’: u’subnet-947bbce3’})
changed: [localhost → 127.0.0.1] => (item={u’resource_tags’: {u’Name’: u’tendo_private_subnet’}, u’cidr’: u’172.25.20.0/24’, u’az’: u’ap-southeast-2b’, u’id’: u’subnet-5be23b3e’})

Can somebody point me that where I am making mistake? Thanks

No solution but only a confirmation that I see thisas well, at least
in some cases while in other cases the variable is substituted in the
task name.
Regards Mirko

Hi Arbab,

That’s just the way Ansible works, the ‘- name’ item is not parsed for variable substitution. That’s pissed me off too.

This is a known bug in 1.8, it should work for variables that are in
scope (non inventory/host).