community.general.oneandone_firewall_policy 模块 – 配置 1&1 防火墙策略
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:community.general.oneandone_firewall_policy
。
概要
创建、删除、重新配置、更新防火墙策略。此模块依赖于 1and1 >= 1.0。
要求
执行此模块的主机上需要以下要求。
1and1
参数
参数 |
注释 |
---|---|
将添加到现有防火墙策略的规则列表。它的语法与用于规则参数的语法相同。与 update 状态结合使用。 默认值: |
|
要分配给防火墙策略的服务器标识符(id 或名称)的列表。与 update 状态结合使用。 默认值: |
|
自定义 API URL。覆盖 ONEANDONE_API_URL 环境变量。 |
|
1&1 提供的身份验证 API 令牌。 |
|
防火墙策略描述。maxLength=256 |
|
与 update 状态一起使用的防火墙策略的标识符(id 或名称)。 |
|
与 present 状态一起使用的防火墙策略名称。与 absent 状态一起使用时用作标识符(id 或名称)。maxLength=128 |
|
将从现有防火墙策略中删除的规则 id 的列表。与 update 状态结合使用。 默认值: |
|
要从防火墙策略中取消分配的服务器 IP id 的列表。与 update 状态结合使用。 默认值: |
|
将为防火墙策略设置的规则列表。除了三个可选参数(port_from、port_to 和 source)之外,每个规则必须包含 protocol 参数 默认值: |
|
定义要创建、删除或更新的防火墙策略状态。 选择
|
|
在返回之前等待实例处于“running”状态 选择
|
|
定义在使用 _wait_for 方法时要等待的秒数 默认值: |
|
放弃等待之前的时长,以秒为单位 默认值: |
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 完全 |
可以在 |
|
支持: 无 |
在 diff 模式下,将返回有关已更改(或可能需要在 |
示例
- name: Create a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
name: ansible-firewall-policy
description: Testing creation of firewall policies with ansible
rules:
-
protocol: TCP
port_from: 80
port_to: 80
source: 0.0.0.0
wait: true
wait_timeout: 500
- name: Destroy a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
state: absent
name: ansible-firewall-policy
- name: Update a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
state: update
firewall_policy: ansible-firewall-policy
name: ansible-firewall-policy-updated
description: Testing creation of firewall policies with ansible - updated
- name: Add server to a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
firewall_policy: ansible-firewall-policy-updated
add_server_ips:
- server_identifier (id or name)
- server_identifier #2 (id or name)
wait: true
wait_timeout: 500
state: update
- name: Remove server from a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
firewall_policy: ansible-firewall-policy-updated
remove_server_ips:
- B2504878540DBC5F7634EB00A07C1EBD (server's IP id)
wait: true
wait_timeout: 500
state: update
- name: Add rules to a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
firewall_policy: ansible-firewall-policy-updated
description: Adding rules to an existing firewall policy
add_rules:
-
protocol: TCP
port_from: 70
port_to: 70
source: 0.0.0.0
-
protocol: TCP
port_from: 60
port_to: 60
source: 0.0.0.0
wait: true
wait_timeout: 500
state: update
- name: Remove rules from a firewall policy
community.general.oneandone_firewall_policy:
auth_token: oneandone_private_api_key
firewall_policy: ansible-firewall-policy-updated
remove_rules:
- rule_id #1
- rule_id #2
- ...
wait: true
wait_timeout: 500
state: update
返回值
通用返回值已在此处文档化 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
有关已处理的防火墙策略的信息 返回: 始终 示例: |