Commit 43651b8f authored by nanahira's avatar nanahira

use dict

parent 87095b4c
...@@ -96,17 +96,17 @@ ...@@ -96,17 +96,17 @@
- mci{{inventory_hostname_short}} - mci{{inventory_hostname_short}}
# 为了提高测试时候的性能,不改动wg的时候注释掉这段 # 为了提高测试时候的性能,不改动wg的时候注释掉这段
- name: 'clean up null connections first' - name: 'clean up null connections first'
include_tasks: 'protocols/{{item.protocol}}/configure.yaml' include_tasks: 'protocols/{{item.value.protocol}}/configure.yaml'
vars: vars:
conn: '{{item}}' conn: '{{item.value}}'
with_items: '{{ connections }}' with_dict: '{{ connections }}'
when: "not noUpdateLinks and item.protocol is defined and item.protocol == 'null' and not item.noUpdate" when: "not noUpdateLinks and item.value.protocol == 'null' and not item.value.noUpdate"
- name: 'loop through list from a variable' - name: 'loop through list from a variable'
include_tasks: 'protocols/{{item.protocol}}/configure.yaml' include_tasks: 'protocols/{{item.value.protocol}}/configure.yaml'
vars: vars:
conn: '{{item}}' conn: '{{item.value}}'
with_items: '{{ connections }}' with_dict: '{{ connectionsDict }}'
when: "not noUpdateLinks and item.protocol is defined and item.protocol != 'null' and not item.noUpdate" when: "not noUpdateLinks and item.value.protocol != 'null' and not item.value.noUpdate"
# end # end
- name: services conf - name: services conf
copy: copy:
......
...@@ -424,6 +424,7 @@ class InventoryBuilder { ...@@ -424,6 +424,7 @@ class InventoryBuilder {
ocpasswdLines: host.ocpasswdLines || [], ocpasswdLines: host.ocpasswdLines || [],
gateways: _.values(this.gateways[host.name]), gateways: _.values(this.gateways[host.name]),
connections, connections,
connectionsDict: _.keyBy(connections, 'name'),
lanInterfaces, lanInterfaces,
localSubnets, localSubnets,
masqInterfaces, masqInterfaces,
......
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