On 01. sep. 2016 22:20, Patrick Laimbock wrote:
Variables:--- openvpn_networks: site1: openvpn_config: site1-server1 site2: openvpn_config: site2-server1 openvpn_users: - name: patrick base: /home/ - name: test base: /home/ The task below works (apologies for the wrapping): ansible/roles/openvpn/client/tasks/main.yml --- - name: install openvpn NetworkManager client config(s) template: src: "{{ item }}/openvpn_networks[item].openvpn_config }}.j2" dest: "/home/patrick/{{openvpn_networks[item].openvpn_config }}.ovpn" mode: 0644 with_items: - '{{ openvpn_networks | list }}' But I can't figure out how to do this for multiple users as it fails with: the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'base' - name: install multi-user openvpn NetworkManager client config(s) template: src: "{{ item }}/{{ openvpn_networks[item].openvpn_config }}.j2" dest: "{{ item.2.base }}/{{ item.2.name }}/test/{{ openvpn_networks[item].openvpn_config }}.ovpn" owner: "{{ item.2.name }}" group: "{{ item.2.name }}" mode: 0644 with_items: - '{{ openvpn_networks | list }}' - '{{ openvpn_users }}' How to make this work (possibly in a better way)?
Are you trying to make all the users on all the sites? If so, check out with_nested https://docs.ansible.com/ansible/playbooks_loops.html#nested-loops -- 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/8b96d8ba-645b-d5a1-db00-20a83c6b2055%40olstad.com. For more options, visit https://groups.google.com/d/optout.
