ansible 2.19.0 以後で `skipping vars_file item due to an undefined variable` が出るとき
ansible 2.19.0 以後では variable の validation が以前よりも strict になっている。 結果として、
- hosts: foo
become: true
vars_files:
- inventory/{{ stage }}/group_vars/foo.yml
roles:
- base
みたいな書き方をしていると、
[WARNING]: skipping vars_file item due to an undefined variable
Origin: /Users/tokuhirom/ansible/site.yml:52:7
50 become: true
51 vars_files:
52 - inventory/{{ stage }}/group_vars/foo.yml
^ column 7
というエラーになる。
これは、2.19 から validation が強化されたことに伴うもので、実害は無いといえば無いっぽい。
https://github.com/ansible/ansible/issues/85887?utm_source=chatgpt.com
気になるようなら、以下のように pre_tasks で include_vars するように変えると良さそう。
- hosts: foo
become: true
pre_tasks:
- name: Load foo vars
include_vars: "inventory/{{ stage }}/group_vars/foo.yml"
roles:
- base
Published: 2025-12-08(Mon) 14:56