On Fri, Jan 24, 2020, at 1:58 PM, FG wrote:
>
> I am facing same issue , Any leads ???
>
>
Could you be more specific? What exactly is the issue you're seeing? Playbooks? Commands you're using? Output?
In any case, this is definitely a better question for ansible-project@ list
The post below had lots of errors, including self referring variables, and lack if understanding variables scope
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#scoping-variables
V/r,
James Cassell
>
> Regards
>
>
> On Thursday, May 23, 2019 at 9:53:08 AM UTC-4, Geoff wrote:
> > I have a playbook called: *testing_vars_pass.yml*
> >
> > It imports another playbook called: *testing_vars_call.yml*
> >
> > The playbook *testing_vars_call.yml* expects a variable called: *myVar*
> >
> >
> > Below is the contents of each playbook ...
> >
> > $ cat *testing_vars_pass.yml*
> > ---
> > - name: Test pass vars
> > hosts: all
> > vars:
> > myVar: hello
> >
> > tasks:
> >
> > - name: Debug pass vars
> > debug:
> > msg: "{{ myVar }}"
> >
> > - import_playbook: *testing_vars_call.yml* myVar="{{ myVar }}"
> >
> >
> > ... and ...
> >
> >
> > $ cat *testing_vars_call.yml*
> > ---
> > - name: Test call vars
> > hosts: all
> > vars:
> > myVar: = "{{ myVar }}"
> >
> > tasks:
> >
> > - name: Debug call vars
> > debug:
> > msg: "{{ myVar }}"
> >
> >
> >
> > This produces the following error ...
> >
> > 18 TASK [Debug call vars] *********************************************************
> >
> > 19 fatal: [1.1.1.1]: FAILED! => {"msg": "An unhandled exception occurred while templating '{{ myVar }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while templating '{{ myVar }}'. [...]
> >
> >
> >
> > The same error is seen if I use the syntax ...
> >
> > - import_playbook: testing_vars_call.yml
> > vars:
> > myVar: "{{ myOwnVar }}"
> >
> >
> >
> > In case the fact that the 'myVars' variable had the same name in both playbooks, I changed the name in the first playbook ...
> >
> > $ cat *testing_vars_pass.yml*
> > ---
> > - name: Test pass vars
> > hosts: all
> > vars:
> > my*Own*Var: hello
> >
> > tasks:
> >
> > - name: Debug pass vars
> > debug:
> > msg: "{{ my*Own*Var }}"
> >
> > - import_playbook: testing_vars_call.yml myVar="{{ my*Own*Var }}"