【发布时间】:2019-12-23 04:12:08
【问题描述】:
我有以下基础架构(3 个运行 Windows 2016 服务器版的服务器),其中主服务器在端口 80(示例)上运行 IIS 服务,并且需要 2 个代理连接到它们。为了允许通信,我需要添加 Windows 防火墙规则以将 IP 地址列入白名单
- 一个主服务器(mas)
- 和两个代理服务器 (agt)
我需要通过 ansible 执行的任务是,我只需要在主服务器上添加以下防火墙规则,并且不应该在代理主机上运行。如何仅在主服务器上运行以下任务,以便在配置防火墙规则时使用代理(agt)机器的 IP 地址详细信息。
- hosts: mas, agt
tasks:
- name: Firewall Rule Modifications
win_firewall_rule:
name: "IIS port"
localport: "80"
direction: in
action: allow
remoteip: "{{ansible_ip_addresses[0]}}"
protocol: "tcp"
description: "Allow agents"
enabled: yes
state: present
【问题讨论】:
-
请正确缩进代码示例。谢谢!