mirror of https://github.com/ansible/ansible.git
[2.10] Fix using module-specific module_defaults in action plugins (#74850)
* Use the module redirect_list when getting defaults for action plugins (#73864) * Fix module-specific defaults in the gather_facts, package, and service action plugins. * Handle ansible.legacy actions better in get_action_args_with_defaults * Add tests for each action plugin * Changelog Fixes #72918 (cherry picked from commitpull/75004/head5640093f1c
) * Fix tests for < 3.8 (cherry picked from commit267b7215b3
)
parent
c6d647a8f0
commit
e30ffb8499
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- gather_facts, package, service - fix using module_defaults for the modules in addition to the action plugins. (https://github.com/ansible/ansible/issues/72918)
|
@ -0,0 +1,79 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
# The gather_facts keyword has default values for its
|
||||||
|
# options so module_defaults doesn't have much affect.
|
||||||
|
gather_facts: no
|
||||||
|
tags:
|
||||||
|
- default_fact_module
|
||||||
|
tasks:
|
||||||
|
- name: set defaults for the action plugin
|
||||||
|
gather_facts:
|
||||||
|
module_defaults:
|
||||||
|
gather_facts:
|
||||||
|
gather_subset: min
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: "gather_subset == ['min']"
|
||||||
|
|
||||||
|
- name: set defaults for the module
|
||||||
|
gather_facts:
|
||||||
|
module_defaults:
|
||||||
|
setup:
|
||||||
|
gather_subset: '!all'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: "gather_subset == ['!all']"
|
||||||
|
|
||||||
|
# Defaults for the action plugin win because they are
|
||||||
|
# loaded first and options need to be omitted for
|
||||||
|
# defaults to be used.
|
||||||
|
- name: set defaults for the action plugin and module
|
||||||
|
gather_facts:
|
||||||
|
module_defaults:
|
||||||
|
setup:
|
||||||
|
gather_subset: '!all'
|
||||||
|
gather_facts:
|
||||||
|
gather_subset: min
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: "gather_subset == ['min']"
|
||||||
|
|
||||||
|
# The gather_facts 'smart' facts module is 'ansible.legacy.setup' by default.
|
||||||
|
# If 'setup' (the unqualified name) is explicitly requested, FQCN module_defaults
|
||||||
|
# would not apply.
|
||||||
|
- name: set defaults for the fqcn module
|
||||||
|
gather_facts:
|
||||||
|
module_defaults:
|
||||||
|
ansible.legacy.setup:
|
||||||
|
gather_subset: '!all'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: "gather_subset == ['!all']"
|
||||||
|
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tags:
|
||||||
|
- custom_fact_module
|
||||||
|
tasks:
|
||||||
|
- name: set defaults for the module
|
||||||
|
gather_facts:
|
||||||
|
module_defaults:
|
||||||
|
ansible.legacy.setup:
|
||||||
|
gather_subset: '!all'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "gather_subset == ['!all']"
|
||||||
|
|
||||||
|
# Defaults for the action plugin win.
|
||||||
|
- name: set defaults for the action plugin and module
|
||||||
|
gather_facts:
|
||||||
|
module_defaults:
|
||||||
|
gather_facts:
|
||||||
|
gather_subset: min
|
||||||
|
ansible.legacy.setup:
|
||||||
|
gather_subset: '!all'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "gather_subset == ['min']"
|
Loading…
Reference in New Issue