Try this it worked for me, A play takes a list of tasks so each tasks
should start with dash `-`:
---
- name: Test playbook
hosts: localhost
connection: local
vars:
test: hello
tasks:
- name: test var
debug:
msg: "{{ test }}"
register: test_out
- debug:
var: test_out
On Friday, March 22, 2019 at 3:06:31 PM UTC, James Gibson wrote:
>
> I am trying to figure out why my variable is not defined and have not been
> able to find any solutions online.
> Can anyone help?
>
>
> test.yml
> ---
> - name: Test playbook
> hosts: localhost
> connection: local
> vars:
> test: hello
>
> tasks:
> - name: test var
> debug:
> msg: "{{ test}}"
> register: test_out
> debug:
> var: test_out
>
> output from playbook:
> PLAY [Test playbook]
> ***********************************************************************************************************************************************************************************
>
> TASK [Gathering Facts]
> *********************************************************************************************************************************************************************************
> ok: [localhost]
>
> TASK [test var]
> ****************************************************************************************************************************************************************************************
> ok: [localhost] => {
> "test_out": "VARIABLE IS NOT DEFINED!"
> }
>
> PLAY RECAP
> *********************************************************************************************************************************************************************************************
> localhost : ok=2 changed=0 unreachable=0 failed=0
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c7a10578-8542-42ae-b0aa-6f77bdf6258b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.