Ansible action plugin that, given a list of files and/or paths, recursively merges the contents of those files.
Heavily derived from Ansible's include_vars action plugin (that disguises itself as a module), so all its rules and functionality should apply seamlessly, with the exception that the parameter file
(string) is replaced by files
(list).
When merging, the following strategy is applied:
- non-existing items are added
- if data types differ, the new item overrides the previous one
- dictionaries are merged recursively
- all other values are overridden by the newer item
Tests are executed using tox
, and the following combinations are tested:
Python | Ansible |
---|---|
2.7 | 2.8 (latest) |
2.7 | 2.9 (latest) |
3.7 | 2.8 (latest) |
3.7 | 2.9 (latest) |
- name: load and merge vars from all files
merge_var_files:
name: my_merged_data
files:
- default.yml
- '{{ ansible_os_family }}.yml'
- '{{ ansible_os_distribution }}.yml'