Run ansible playbook in uninitialized env?

16 views
Skip to first unread message

Valeriy Solovyov

unread,
Jul 29, 2015, 10:39:30 AM7/29/15
to Ansible Project
Hello,

I use some script that executes a ansible playbook from upstart. 
If I use lookup for variable playbook/task/defaults/main.yml:
user: "{{ lookup('env','USER') }}"
home: "{{ lookup('env','HOME') }}"

It will the empty variables. Because upstart doesn't provide root or etc env.

My question is how to setup default value if lookup will return the empty result?

Brian Coca

unread,
Jul 29, 2015, 10:49:59 AM7/29/15
to Ansible Project
user: "{{ lookup('env','USER')|default('root') }}"
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/89e31cca-7084-4f4d-b3f9-87040757aa31%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages