looping over list to use as role variables

12 views
Skip to first unread message

basni...@gmail.com

unread,
Mar 2, 2016, 8:39:52 AM3/2/16
to Ansible Project
Hi all,

I would like to use ansible to spawn (and later prune) a list of `jupyter notebook` servers.

I now do the following:

---
- hosts: vm1
  roles:
    - { role: notebook, port: 8001, name: jup1 }
    - { role: notebook, port: 8002, name: jup2 }
    - role: jdauphant.nginx
      nginx_sites:
        notebooks:
          - listen 8000
          - server_name localhost
          - location /jub1 {proxy_pass http://localhost:8001/tree;}
          - location /jup2 {proxy_pass http://localhost:8002/tree;}



As you see I repeat the port (8001 and 8002) and name (jup1 and jup2) twice, which I would like to do in a loop, but I don't know how.

I'm completely new to ansible, so if this is not a smart way of doing it, could you please give another suggestion.


Best, Bas Nijholt
Reply all
Reply to author
Forward
0 new messages