On 10.11.2017 03:14, Rajesh Rajendran wrote:
---
- hosts: localhost
  gather_facts: false
  vars:
      neo4j:
        name: neo4j
      api_service:
        name: api_service
        pid: /var/api/pid
  tasks:
    - debug:
msg: "{{item.pid|default('/var/run/{{item.name}}/{{item.name}}.pid')}}"

You cant't nest {{ }}


      with_items:
          - "{{ vars[service] }}"

ansible-playbook play.yml --extra-vars service=api-service

how will I debug both dictionaries?
  I know that I can't give
     --extra-vars service=api-service,neo4j or as a llist

or is there any way to dynamically iterate using user given dictionaries.

You could do something like this

  - debug:
msg: "{{ vars[item].pid | default('/var/run/' ~ vars[item].name ~ '/' ~ vars[item].name ~ '.pid')}}"
    with_items:
        - "{{ service.split(',') }}"

And then you can use a comma separated values in --extra-vars

--
Kai Stian Olstad

--
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/9a178b65ba8cfe4e4142ed8456ed9d22%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to