Syntax question, please

20 views
Skip to first unread message

Tiglath

unread,
Jul 20, 2016, 11:27:27 AM7/20/16
to Ansible Project


I have this: 

---
- name: Run this play locally - Create CentOS 6.7 VM
  hosts: localhost
  connection: local
  vars:
    ipaddr: 192.168.33.10
  tasks: 
        ...
     
If I pass ipaddr=<addr>  in the ansible-playbook command line
then I want that address instead of the  hard-coded one. 

Something like this

vars: {{ ipaddr }}  | 192.168.33.10

Meaning take {{ ippaddr }} if specified else the hard-coded default.

What is the correct syntax to do that?   I've been looking in the wrong places, it seems.

Many thanks


Chris Shultz

unread,
Jul 20, 2016, 12:21:19 PM7/20/16
to ansible...@googlegroups.com

{{ipaddr|default('192.168.33.10')}}


--
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/2a403c61-f947-47eb-9b3a-5051cebbf010%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tiglath

unread,
Jul 20, 2016, 4:10:50 PM7/20/16
to Ansible Project

Gratitude.
Reply all
Reply to author
Forward
0 new messages