Consolidate filter plugin
SUMMARY
Consolidate filter plugin
This plugin presents collective structured data including all supplied facts grouping on common attributes mentioned.
ISSUE TYPE
New Module Pull Request
COMPONENT NAME
ansible.utils.consolidate
ADDITIONAL INFORMATION
- hosts: localhost
gather_facts: false
tasks:
- name: Define some test data
ansible.builtin.set_fact:
values:
- name: a
value: 1
- name: b
value: 2
- name: c
value: 3
colors:
- name: a
color: red
- name: b
color: green
- name: c
color: blue
- name: Define some test data
ansible.builtin.set_fact:
base_data:
- data: "{{ values }}"
match_key: name
name: values
- data: "{{ colors }}"
match_key: name
name: colors
- name: Consolidate the data source using the name key
ansible.builtin.set_fact:
consolidated: "{{ data_sources|ansible.utils.consolidate }}"
vars:
sizes:
- name: a
size: small
- name: b
size: medium
- name: c
size: large
additional_data_source:
- data: "{{ sizes }}"
match_key: name
name: sizes
data_sources: "{{ base_data + additional_data_source }}"
# consolidated:
# a:
# colors:
# color: red
# name: a
# sizes:
# name: a
# size: small
# values:
# name: a
# value: 1
# b:
# colors:
# color: green
# name: b
# sizes:
# name: b
# size: medium
# values:
# name: b
# value: 2
# c:
# colors:
# color: blue
# name: c
# sizes:
# name: c
# size: large
# values:
# name: c
# value: 3
- name: Consolidate the data source using different keys
ansible.builtin.set_fact:
consolidated: "{{ data_sources|ansible.utils.consolidate }}"
vars:
sizes:
- title: a
size: small
- title: b
size: medium
- title: c
size: large
additional_data_source:
- data: "{{ sizes }}"
match_key: title
name: sizes
data_sources: "{{ base_data + additional_data_source }}"
# consolidated:
# a:
# colors:
# color: red
# name: a
# sizes:
# size: small
# title: a
# values:
# name: a
# value: 1
# b:
# colors:
# color: green
# name: b
# sizes:
# size: medium
# title: b
# values:
# name: b
# value: 2
# c:
# colors:
# color: blue
# name: c
# sizes:
# size: large
# title: c
# values:
# name: c
# value: 3
- name: Consolidate the data source using the name key (fail_missing_match_key)
ansible.builtin.set_fact:
consolidated: "{{ data_sources|ansible.utils.consolidate(fail_missing_match_key=True) }}"
ignore_errors: true
vars:
vars:
sizes:
- size: small
- size: medium
- size: large
additional_data_source:
- data: "{{ sizes }}"
match_key: name
name: sizes
data_sources: "{{ base_data + additional_data_source }}"
# fatal: [localhost]: FAILED! => {
# "msg": "Error when using plugin 'consolidate': 'fail_missing_match_key'
# reported Missing match key 'name' in data source 2 in list entry 0,
# Missing match key 'name' in data source 2 in list entry 1,
# Missing match key 'name' in data source 2 in list entry 2"
# }
- name: Consolidate the data source using the name key (fail_missing_match_value)
ansible.builtin.set_fact:
consolidated: "{{ data_sources|ansible.utils.consolidate(fail_missing_match_value=True) }}"
ignore_errors: true
vars:
sizes:
- name: a
size: small
- name: b
size: medium
additional_data_source:
- data: "{{ sizes }}"
match_key: name
name: sizes
data_sources: "{{ base_data + additional_data_source }}"
# fatal: [localhost]: FAILED! => {
# "msg": "Error when using plugin 'consolidate': 'fail_missing_match_value'
# reported Missing match value c in data source 2"
# }
- name: Consolidate the data source using the name key (fail_duplicate)
ansible.builtin.set_fact:
consolidated: "{{ data_sources|ansible.utils.consolidate(fail_duplicate=True) }}"
ignore_errors: true
vars:
sizes:
- name: a
size: small
- name: a
size: small
additional_data_source:
- data: "{{ sizes }}"
match_key: name
name: sizes
data_sources: "{{ base_data + additional_data_source }}"
# fatal: [localhost]: FAILED! => {
# "msg": "Error when using plugin 'consolidate': 'fail_duplicate' reported Duplicate values in data source 2"
# }
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Reviewed-by: Bradley A. Thornton <bthornto@redhat.com>
Sanity tests: copy ignore-2.13.txt to ignore-2.14.txt
SUMMARY
ansible-collections/news-for-maintainers#13
Dear maintainers,
I'd like to ask you to track the news-for-maintainers themselves in the future if possible
Thanks!
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Update black to latest
Upgrade and enable black to latest in .pre-commit-config.yaml
Other changes made by precommit.ci via black upgrade
Reviewed-by: GomathiselviS <None>
Prepare for release utils 2.5.2
SUMMARY
ISSUE TYPE
Docs Pull Request
COMPONENT NAME
ADDITIONAL INFORMATION
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Improve ut coverage
SUMMARY
Add more testcases for ipaddr filter
ISSUE TYPE
COMPONENT NAME
ipaddr.py
ADDITIONAL INFORMATION
Reviewed-by: Nilashish Chakraborty <nilashishchakraborty8@gmail.com>
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
Reviewed-by: Sagar Paul <sagpaul@redhat.com>
Add 'netaddr' To 'requirements.txt' For Unit Tests
This enables 'ansible-test --docker' and 'ansible-test --venv' to be able to leverage 'netaddr' and pass tests
SUMMARY
This adds the 'netaddr' python module to the requirements specific to unit tests. This allows 'ansible-test' to work for '--docker' and '--venv' without manual intervention.
I also re-ordered the current list to be alphabetical.
Fixes#142
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
Unit tests in ansible.utils for ipsubnet
ADDITIONAL INFORMATION
git clone https://github.com/ansible-collections/ansible.utils.git
cd ansible.utils
ansible-galaxy collection build .
ansible-galaxy collection install -p . ansible-utils-\*.tar.gz
ansible-test units --docker base tests/unit/plugins/filter/test_ipsubnet.py --requirements --verbose
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>
move ipaddr filter docs into collection
SUMMARY
ipaddr moved to ansible.utils. Now moving the matching documentation over. This will be republished to docs.ansible.com on the ansible.utils page.
Fixes#130
ISSUE TYPE
Docs Pull Request
COMPONENT NAME
docs/docsite/rst/filters_ipaddr.rst
docs/docsite/extra-docs.yml
ADDITIONAL INFORMATION
Reviewed-by: Ashwini Mhatre <mashu97@gmail.com>