How to use registered variable in with_items list?

20 views
Skip to first unread message

Tim John

unread,
Jul 28, 2015, 9:51:29 AM7/28/15
to Ansible Project
Hey guys, I'm trying to use a registered variable in **with_items** list, but can find a way to do it.

Here is what I'm doing:

```yaml
- name: acquire Django root path
  shell: pip show django | grep 'Location' | sed 's/Location:\ //g'
  register: django_root

- name: customize Graphite Apache configuration
  lineinfile: dest={{ apache_vhost_folder }}/graphite.conf regexp={{ item.default }} line={{ item.custom }} state=present
  with_items:
     - { default: 'WSGISocketPrefix run/wsgi', custom: 'WSGISocketPrefix /var/run/{{ apache_service_name }}/wsgi' }
     - { default: '\@DJANGO_ROOT\@', custom: "{{ django_root.stdout_lines }}" } # trying to use registered variable django_root, but failed
```

First, I get the Django root path, and register it as a variable named `django_root`;
Then, I'd like to use it in the second item of `with_items` list, but failed.

Is there a good way to achieve this goal? Thanks!

Tim
Reply all
Reply to author
Forward
0 new messages