If you are attempting to drive the host spec based on inventory variables, this won't work.
If you drive it with input from -e, it will. You can't use inventory variables to drive the host spec. On Fri, Feb 21, 2014 at 3:09 PM, anatoly techtonik <[email protected]>wrote: > @Scott, thanks. Trial and error told me that way too. > > > On Friday, February 21, 2014 10:59:36 PM UTC+3, Scott Sturdivant wrote: > >> Change to default('localhost'). >> >> >> On Fri, Feb 21, 2014 at 12:56 PM, anatoly techtonik <[email protected]>wrote: >> >>> I try to set default value for hosts field in playbook with Jinja2 >>> filter, but it doesn't work: >>> >>> --- >>>> - hosts: "{{ host | default(localhost) }}" >>>> tasks: >>>> - name: show OS version info >>>> debug: msg="{{ansible_distribution}} {{ansible_distribution_ >>>> version}}" >>> >>> >>> # ansible-playbook -i hosts dist.yml >>> >>> PLAY [{{host | default(localhost)}}] ****************************** >>> ************ >>> skipping: no hosts matched >>> >>> >>> But when I execute it with command line parameter, it works ok: >>> >>> # ansible-playbook -i hosts dist.yml --extra-vars 'host=localhost' >>> >>> PLAY [localhost] ****************************** >>> ******************************** >>> ... >>> >>> >>> ??? >>> >>> -- >>> 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]. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- 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/CAEVJ8QNkGyMYa0jDxy-qq0mrsyrLCNKTuy5dZwwJ%3DBzB64GOcQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
