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’] "
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?
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.