I've been working this issue for a week now. The code used to work 
perfectly and now it fails.  Here is the error I get:

The task includes an option with an undefined variable. The error was: 
{'CentOS': '{{ iptables_directory[ansible_distribution] }}/iptables', 
'Rocky': '{{ iptables_directory[ansible_distribution] }}/iptables', 
'Debian': '{{ iptables_directory[ansible_distribution] }}/rules.v4', 
'Ubuntu': '{{ iptables_directory[ansible_distribution] }}/rules.v4'}: 'dict 
object' has no attribute 'Debian'. 'dict object' has no attribute 'Debian'. 

The error appears to be in '/work/armory/roles/xxx/tasks/xxx.yml': line 
266, column 3, but may be elsewhere in the file depending on the exact 
syntax problem.
The offending line appears to be:
- name:  Save new iptables - IPv4
  ^ here

-------------------------------------------------------------------------------
This is the ansible task I have:

- name: Save new iptables - IPv4
  shell: "{{ iptables_save }} > {{ iptables_v4_rules[ansible_distribution] 
}}"
  when: firewall == "iptables"

And in my default.yml file I have:

iptables_directory:
  CentOS: "/etc/sysconfig"
  Rocky: "/etc/sysconfig"
  Debian: "/etc/iptables"
  Ubuntu: "/etc/iptables"
iptables_v4_rules:
  CentOS: "{{ iptables_directory[ansible_distribution] }}/iptables"
  Rocky: "{{ iptables_directory[ansible_distribution] }}/iptables"
  Debian: "{{ iptables_directory[ansible_distribution] }}/rules.v4"
  Ubuntu: "{{ iptables_directory[ansible_distribution] }}/rules.v4"

-------------------------------------------------------------
I get a similar error when I target CentOS 9.

  ansible-core 2.14.3
  python 3.11.2
  jinja version = 3.1.2

default.yml is being read in as I refer to other variables in the same 
file. Can anyone see an error that I've missed?


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/51380bd1-67c2-4f64-bea1-e9a17a698588n%40googlegroups.com.

Reply via email to