Commit 21160dd8 authored by Pietsch, Martin's avatar Pietsch, Martin

add loop_control to loops

parent 9182fb3a
...@@ -2,22 +2,26 @@ ...@@ -2,22 +2,26 @@
- block: - block:
- name: add container to inventory via sshjail connection - name: add container to inventory via sshjail connection
add_host: add_host:
name: "{{ item.0 }}_{{ item.1.name | upper() }}" name: "{{ _container.0 }}_{{ _container.1.name | upper() }}"
ansible_ssh_host: "{{ item.1.name | replace('.', '_') }}@{{ansible_ssh_host}}" ansible_ssh_host: "{{ _container.1.name | replace('.', '_') }}@{{ansible_ssh_host}}"
ansible_python_interpreter: "{{ ansible_python.executable }}" ansible_python_interpreter: "{{ ansible_python.executable }}"
ansible_connection: "sshjail" ansible_connection: "sshjail"
when: (item.1.container | default(False)) == True when: (_container.1.container | default(False)) == True
loop: "{{ function_hosts | product(function_packages) | list }}" loop: "{{ function_hosts | product(function_packages) | list }}"
loop_control:
loop_var: _container
when: ansible_connection == "ssh" and function_container_used == True when: ansible_connection == "ssh" and function_container_used == True
- block: - block:
- name: add container to inventory via jail connection - name: add container to inventory via jail connection
add_host: add_host:
name: "{{ item.0 }}_{{ item.1.name | upper() }}" name: "{{ _container.0 }}_{{ _container.1.name | upper() }}"
ansible_python_interpreter: "{{ ansible_python.executable }}" ansible_python_interpreter: "{{ ansible_python.executable }}"
ansible_connection: "jail" ansible_connection: "jail"
ansible_host: "{{ item.1.name | replace('.', '_') }}" ansible_host: "{{ _container.1.name | replace('.', '_') }}"
when: (item.1.container | default(False)) == True when: (_container.1.container | default(False)) == True
loop: "{{ function_hosts | product(function_packages) | list }}" loop: "{{ function_hosts | product(function_packages) | list }}"
loop_control:
loop_var: _container
when: ansible_connection == "local" and function_container_used == True when: ansible_connection == "local" and function_container_used == True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment