" Unable to look up a name or access an attribute in template string" when use conditional check

Got error for every run after upgrade to 2.3.1.0**:**

root@aaaaaaaaaansible:~/nexkek# ansible --version
ansible 2.3.1.0
config file = /root/nexkek/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]

fatal: [192.168.1.36]: FAILED! => {
“failed”: true,
“msg”: “The conditional check ‘inventory_hostname in groups.cent6local or inventory_hostname in groups.cent7local or inventory_hostname in groups.ubuntulocal’ failed. The error was: error while evaluating conditional (inventory_hostname in groups.cent6local or inventory_hostname in groups.cent7local or inventory_hostname in groups.ubuntulocal): Unable to look up a name or access an attribute in template string ({% if inventory_hostname in groups.cent6local or inventory_hostname in groups.cent7local or inventory_hostname in groups.ubuntulocal %} True {% else %} False {% endif %}).\nMake sure your variable name does not contain invalid characters like ‘-’: argument of type ‘StrictUndefined’ is not iterable\n\nThe error appears to have been in ‘/root/nexkek/includes/io_start.yml’: line 7, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n ignore_errors: yes\n- debug: var=vdbench.stdout_lines\n ^ here\n”
}

the include:

  • include: includes/io_start.yml
    when: inventory_hostname in groups.cent6local or inventory_hostname in groups.cent7local or

inventory_hostname in groups.ubuntulocal
tags: [“io”,“io:start”,“io:start:local”]

checked both variants -" when: inventory_hostname in groups[‘cent6local’] or inventory_hostname in groups[‘cent7local’] or inventory_hostname in groups[‘ubuntulocal’] "

includes/io_start.yml is quite simple task:

  • name: Run vdb task
    shell: “{{ vdb_folder_path }}/{{ vdbshell }} -f {{ vdb_folder_path }}/{{ vdbench_config }} -o {{ vdb_output }}”
    async: 4000000
    poll: 0
    register: vdb
    ignore_errors: yes
  • debug: var=vdb.stdout_lines

inventory:

[cent7local]
192.168.1.86
192.168.1.77

So the main question - how could I use the condition like:
“inventory_hostname in groups.cent6local or inventory_hostname in groups.cent7local or inventory_hostname in groups.ubuntulocal” ? Was it changed?

*Got error for every run after upgrade to *2.3.1.0*:*

root@aaaaaaaaaansible:~/nexkek# ansible --version
ansible 2.3.1.0
   config file = /root/nexkek/ansible.cfg
   configured module search path = Default w/o overrides
   python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]

fatal: [192.168.1.36]: FAILED! => {
     "failed": true,
     "msg": "The conditional check 'inventory_hostname in groups.cent6local
or inventory_hostname in groups.cent7local or inventory_hostname in
groups.ubuntulocal' failed. The error was: error while evaluating
conditional (inventory_hostname in groups.cent6local or inventory_hostname
in groups.cent7local or inventory_hostname in groups.ubuntulocal): Unable
to look up a name or access an attribute in template string ({% if
inventory_hostname in groups.cent6local or inventory_hostname in
groups.cent7local or inventory_hostname in groups.ubuntulocal %} True {%
else %} False {% endif %}).\nMake sure your variable name does not contain
invalid characters like '-': argument of type 'StrictUndefined' is not
iterable\n\nThe error appears to have been in
'/root/nexkek/includes/io_start.yml': line 7, column 3, but may\nbe
elsewhere in the file depending on the exact syntax problem.\n\nThe
offending line appears to be:\n\n ignore_errors: yes\n- debug:
var=vdbench.stdout_lines\n ^ here\n"
}

*the include:*

   - include: includes/io_start.yml
     when: inventory_hostname in groups.cent6local or inventory_hostname in
groups.cent7local or
           inventory_hostname in groups.ubuntulocal
     tags: ["io","io:start","io:start:local"]

I think this error message is because of one or more groups is not defined. Do you have all 3 groups in the inventory?

*inventory:*

[cent7local]
192.168.1.86
192.168.1.77
....

Here you only list one of the groups, your code need all 3 defined to work.
If this is not the case you need to filter it with default()

So the main question - how could I use the condition like:
"inventory_hostname in groups.cent6local or inventory_hostname in
groups.cent7local or inventory_hostname in groups.ubuntulocal" ? Was it
changed?

The functionality have not changed. But newer Ansible is more restrictive, before it ignored some errors but newer version fails instead, since that's more sane.
But a few error message is not that informative, but it's getting better.