Remove . shorthand

pull/72553/head
Matt Martz 8 months ago
parent 40942565d9
commit 2f36563ccf
No known key found for this signature in database
GPG Key ID: 40832D88E9FC91D8

@ -164,7 +164,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl
def _validate_register(self, attr, name, value):
if value and not isinstance(value, Mapping):
self.default_register = value
value = {value: '.'}
value = {value: 'ansible_result'}
setattr(self, name, value)
items = value.items() if value else []
@ -174,13 +174,12 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl
# If no default register, but using projection syntax with a full result
# set the default register to the first occurance
if projection in {'.', 'ansible_result'} and self.default_register is None:
if projection == 'ansible_result' and self.default_register is None:
self.default_register = register
if projection[0] != '.' and not _ANSIBLE_RESULT_RE.search(projection):
if not _ANSIBLE_RESULT_RE.search(projection):
raise AnsibleError(
'register projection must be a raw jinja2 statement, containing "ansible_result" or starting '
'with "." representing the result to process'
'register projection must be a raw jinja2 statement, containing "ansible_result"'
)
def preprocess_data(self, ds):
@ -394,14 +393,11 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl
if not isidentifier(register):
raise AnsibleError("Invalid variable name in 'register' specified: '%s'" % register)
if projection in {'.', 'ansible_result'}:
if projection == 'ansible_result':
ret[register] = result
continue
if projection[:1] == '.':
template = f'{{{{ ansible_result{projection[1:]} }}}}'
else:
template = f'{{{{ {projection} }}}}'
template = f'{{{{ {projection} }}}}'
new_vars = templar.available_variables.copy()
new_vars['ansible_result'] = result

@ -7,9 +7,8 @@
- command: "echo two"
register:
result2: .
stdout2: ..stdout
stdout2_r: ansible_result.stdout
result2: ansible_result
stdout2: ansible_result.stdout
changed_when: ansible_result.stdout_lines|first == 'not two'
- assert:
@ -18,20 +17,16 @@
- result2.stdout is defined
- stdout2.stdout is not defined
- result2.stdout == stdout2
- stdout2_r.stdout is not defined
- result2.stdout == stdout2_r
- command: "echo three"
register:
stdout3: ..stdout_lines|first
stdout3_r: (ansible_result.stdout_lines)[0]
stdout3: ansible_result.stdout_lines|first
changed_when: stdout3 == 'three'
- assert:
that:
- stdout3.stdout is undefined
- stdout3 == 'three'
- stdout3_r == 'three'
- debug:
msg: '{{ stdout3 is changed }}'

Loading…
Cancel
Save