我试图设置基于事实的输入变量。
Calculation
我可以通过以下方法达到我的要求,但我想简化一下,有人可以在这里帮助我
if input protocol = to TCP/UDP
then service name will be TCP-443/UDP-443
else service name will be ALL
答案 0 :(得分:1)
我认为等价如下
vars:
port: 443
tasks:
- name: setting fact for service name
set_fact:
servicename: "{{ protocol|upper }}-{{ port }}"
protocolname: "tcp_udp_sctp"
when: protocol|upper == "TCP" or
protocol|upper == "UDP"
- name: setting fact for service name
set_fact:
servicename: "ALL"
protocolname: "ALL"
when: protocol|upper == "ALL"