我有以下内容:
containers:
- name: "c1"
devices:
https: { listen: "tcp:{{l}}:443", connect: "tcp:{{c}}:443", bind:"host", type: "proxy" }
proxy:
- { name: http, dst: 80, nxt: 80, proto: tcp }
- { name: ssh, dst: 1200, nxt: 22, proto: tcp }
- name: "c2"
devices:
pg : { listen: "tcp:{{ lip }}:8085", connect: "tcp:{{ cip }}:8085", bind: "host", type: "proxy" }
我想以这种方式合并设备和代理,即c1的设备将包含
https: {listen: "tcp:{{l}}:443", connect: "tcp:{{c}}:443", bind:"host", type: "proxy"}
http: {listen: "tcp:{{l}}:80", connect: "tcp:{{c}}:80", bind:"host", type: "proxy" }
ssh: {listen: "tcp:{{l}}:1200", connect: "tcp:{{c}}:22", bind:"host", type: "proxy" }
其中两个新项只是代理的重新排序值。我试图将其分解为几个步骤,但我不断遇到错误或错别字。任何帮助将不胜感激。
编辑
知道了!见下文。
答案 0 :(得分:0)
最后,我将其分为两个文件,外部文件和内部文件。外部是这样的:
- include_tasks: inner.yml
with_items: "{{ containers }}"
loop_control:
loop_var: outer_item
内部是这样的:https://gist.github.com/killua-eu/f81af4a84e9cc1394d028a9b193380e7