Lework Study hard, improve every day.

Ansible Role 系统环境 之【iptables】

2017-02-25
本文 990 字,阅读全文约需 3 分钟

Ansible Role: iptables

管理CentOS的iptables

要求

此角色仅在RHEL及其衍生产品上运行。

测试环境

ansible 2.3.0.0 os Centos 6.7 X64 python 2.6.6

角色变量

iptables_allowed_tcp_ports: ''
iptables_allowed_udp_ports: ''
iptables_deny_tcp_ports: ''
iptables_deny_udp_ports: ''
iptables_forwarded_tcp_ports: ''
iptables_forwarded_udp_ports: ''
iptables_additional_rules: ''
iptables_action: 'insert'
iptables_state: 'present'

依赖

没有

github地址

https://github.com/lework/Ansible-roles/tree/master/iptables

Example Playbook

- hosts: server
  roles:
    - { role: iptables, iptables_allowed_tcp_ports: [ "22", "80"]}
	
- hosts: server
  roles:
    - { role: iptables, iptables_allowed_tcp_ports: [ "22", "80"], iptables_state: 'absent'}

- hosts: server
  roles:
    - { role: iptables, iptables_forwarded_tcp_ports: [{ src: "80", dest: "8080" }, { src: "11", dest: "1111" }]}
	
- hosts: server
  roles:
    - { role: iptables, iptables_additional_rules: "iptables -A INPUT -j DROP", iptables_action: "append"}	

使用

~]# /etc/init.d/iptables 
Usage: iptables {start|stop|reload|restart|condrestart|status|panic|save}
原文地址 https://lework.github.io/2017/02/25/Ansible-Role-xi-tong-huan-jing-zhi-iptables/

Comments

Content