Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove default from delegate_facts to inherit #45492

Merged
merged 4 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ansible/playbook/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Block(Base, Become, Conditional, Taggable):

# other fields
_delegate_to = FieldAttribute(isa='string')
_delegate_facts = FieldAttribute(isa='bool', default=False)
_delegate_facts = FieldAttribute(isa='bool')

# for future consideration? this would be functionally
# similar to the 'else' clause for exceptions
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/playbook/role/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def hash_params(params):
class Role(Base, Become, Conditional, Taggable):

_delegate_to = FieldAttribute(isa='string')
_delegate_facts = FieldAttribute(isa='bool', default=False)
_delegate_facts = FieldAttribute(isa='bool')

def __init__(self, play=None, from_files=None, from_include=False):
self._role_name = None
Expand Down
6 changes: 5 additions & 1 deletion lib/ansible/playbook/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ class Task(Base, Conditional, Taggable, Become):
# will be used if defined
# might be possible to define others

# NOTE: ONLY set defaults on task attributes that are not inheritable,
# inheritance is only triggered if the 'current value' is None,
# default can be set at play/top level object and inheritance will take it's course.

_args = FieldAttribute(isa='dict', default=dict())
_action = FieldAttribute(isa='string')

_async_val = FieldAttribute(isa='int', default=0, alias='async')
_changed_when = FieldAttribute(isa='list', default=[])
_delay = FieldAttribute(isa='int', default=5)
_delegate_to = FieldAttribute(isa='string')
_delegate_facts = FieldAttribute(isa='bool', default=False)
_delegate_facts = FieldAttribute(isa='bool')
_failed_when = FieldAttribute(isa='list', default=[])
_loop = FieldAttribute()
_loop_control = FieldAttribute(isa='class', class_type=LoopControl, inherit=False)
Expand Down
25 changes: 25 additions & 0 deletions test/integration/targets/delegate_to/delegate_facts_block.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- hosts: testhost
gather_facts: false
tasks:
- name: set var to delegated host directly
set_fact: qq1=333
delegate_facts: true
delegate_to: localhost

- name: ensure qq1 exists in localhost but not in testhost
assert:
that:
- qq1 is undefined
- "'qq1' in hostvars['localhost']"

- name: set var to delegated host via inheritance
block:
- set_fact: qq2=333
delegate_facts: true
delegate_to: localhost

- name: ensure qq2 exists in localhost but not in testhost
assert:
that:
- qq2 is undefined
- "'qq2' in hostvars['localhost']"
2 changes: 2 additions & 0 deletions test/integration/targets/delegate_to/runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ ansible-playbook test_loop_control.yml -v "$@"
ansible-playbook test_delegate_to_loop_randomness.yml -v "$@"

ansible-playbook delegate_and_nolog.yml -v "$@"

ansible-playbook delegate_facts_block.yml -v "$@"