mirror of https://github.com/ansible/ansible.git
* template connection variables accessed directly before using (#70657)
* template variables accessed directly when using them instead of FieldAttributes
(cherry picked from commit 8c213c9334
)
* changelog
pull/70790/head
parent
ed07821a59
commit
d329985d4c
@ -0,0 +1,2 @@
|
|||||||
|
bugfixes:
|
||||||
|
- Template connection variables before using them (https://github.com/ansible/ansible/issues/70598).
|
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
vars:
|
||||||
|
my_var:
|
||||||
|
become_method: sudo
|
||||||
|
connection: local
|
||||||
|
become: 1
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- include_vars: "./vars/connection.yml"
|
||||||
|
|
||||||
|
- command: whoami
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
failed_when: result is not success and (result.module_stderr is defined or result.module_stderr is defined)
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'sudo' in result.module_stderr"
|
||||||
|
when: result is not success and result.module_stderr is defined
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "'Invalid become method specified' not in result.msg"
|
||||||
|
when: result is not success and result.msg is defined
|
@ -0,0 +1,3 @@
|
|||||||
|
ansible_become: "{{ my_var.become }}"
|
||||||
|
ansible_become_method: "{{ my_var.become_method }}"
|
||||||
|
ansible_connection: "{{ my_var.connection }}"
|
Loading…
Reference in New Issue