- name: gather os specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml"
- "{{ ansible_distribution }}.yml"
tags: vars
Trying to setup a multi linux distros ansible playbook i did used the suggested playbook from the official ansible doc
https://ansible-tips-and-tricks.readthedocs.io/en/latest/os-dependent-tasks/variables/
i did added Centos-6.yml and Debian-9.yml for tests but the result is the following
failed: [1.1.1.1] (item=/home/ansible/ansible-scripts/2AllInOne/CentOS-6.yml) => {
"ansible_facts": {},
"ansible_included_var_files": [],
"ansible_loop_var": "item",
"changed": false,
"item": "/home/ansible/ansible-scripts/2AllInOne/CentOS-6.yml",
"message": "/home/ansible/ansible-scripts/2AllInOne/CentOS-6.yml must be stored as a dictionary/hash"
Any suggestion what the issue can be?
2
Answers
A: The issue is the format of the file
CentOS-6.yml
. It must be a valid YAML and must containdictionary/hash
aka mapping. For exampleResolved the issue after modifying the yml as below:
to