前提:

1、已配置好hosts文件且免密码登录

2、需要的yaml文件已上传到主控端

一、使用Ansible配置iptables

1、iptables.yaml文件

 ---
- hosts: clong
remote_user: root
gather_facts: no
tasks:
# 停止系统自带的firewalld防火墙
- name: stop firewalld
service: name=firewalld state=stopped
# 卸载系统自带的firewalld防火墙
- name: remove firewalld
yum: name=firewalld state=absent
# 安装iptables防火墙
- name: install iptables
yum: name=iptables-services state=present
# 开启iptables防火墙
- name: enable iptables
service: name=iptables state=started enabled=yes
# 安装libselinux-python
- name: install libselinux-python
yum: name=libselinux-python state=present
# iptables防火墙配置文件放行80,3306端口
- name: copy iptables
copy: src=iptables dest=/etc/sysconfig/iptables backup=yes owner=root group=root mode=0600
notify: restart iptables
# 重启iptables防火墙
handlers:
- name: restart iptables
service: name=iptables state=restarted

2、iptables文件

 # sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

使用Ansible安装部署nginx+php+mysql之配置iptables防火墙(0)的更多相关文章

  1. 使用Ansible安装部署nginx+php+mysql之安装mysql(3)

    三.使用Ansible安装mysql 1.mysq.yaml文件 - hosts: clong remote_user: root gather_facts: no tasks: # 安装rpm包 - ...

  2. 使用Ansible安装部署nginx+php+mysql之安装php(2)

    二.使用Ansible安装php 1.php.yaml文件内容 - hosts: clong remote_user: root gather_facts: no tasks: # 安装libseli ...

  3. 使用Ansible安装部署nginx+php+mysql之安装nginx(1)

    使用Ansible安装nginx 1.nginx.yaml文件 --- - hosts: clong remote_user: root gather_facts: no tasks: # 安装epe ...

  4. Ansible安装部署以及常用模块详解

    一.  Ansible 介绍Ansible是一个配置管理系统configuration management system, python 语言是运维人员必须会的语言, ansible 是一个基于py ...

  5. docker 部署 nginx+php+mysql

    系统:centos7 使用root账户 开放80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent 安装docker yum ins ...

  6. centos7 下 安装部署nginx

    centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...

  7. RHEL6 最小化系统 编译安装部署zabbix (mysql)

    RHEL6 最小化系统 编译安装部署zabbix (mysql)官方说明详细见:https://www.zabbix.com/documentation/4.0/manual/installation ...

  8. 第1天:Ansible安装部署

    Ansible介绍 Ansible是一个简单的自动化引擎,可完成配置管理.应用部署.服务编排以及各种IT需求.它是一款使用Python语言开发实现的开源软件,其依赖Jinjia2.paramiko和P ...

  9. Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程

    Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程 1.先切换到root用户 sudo  su 2.更新软件源 apt update apt-get upgrade 3. ...

随机推荐

  1. Apache Shiro教程

    跟开涛学系列: 来自开涛的Apache Shiro教程:http://jinnianshilongnian.iteye.com/blog/2018398 附带的代码例子:https://github. ...

  2. POJ 2068

    就是必胜点与必败点的计算而已.计算每一种情况.设st[i][j]为在第i个人剩下j个石头时的情况,拿它转移后的情况比较.可以到达必败点,则当前为必胜点.若只能到达必胜点,则当前点为必败点. #incl ...

  3. 分享一个iOS输入框特殊限制的代码 UITextField (Validation)

    //个人总结.欢迎新增或改动 #import <UIKit/UIKit.h> typedef enum{ VALIDATION_TYPE_NUM_VALIDATED = 0,//数字 VA ...

  4. Eclipse打开ftl文件,高亮显示

    解决方式一:下载eclipse相关的freemarker插件 解决方式二:原生解决方式,方法特点无需下载插件,和eclipse编辑html和jsp文件一模一样 步骤: 1:windows---pref ...

  5. 找新朋友(hdoj--1286--欧拉函数)

    欢迎参加--每周六晚的BestCoder(有米!) 找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  6. P4396 [AHOI2013]作业 分块+莫队

    这个题正解是莫队+树状数组,但是我个人非常不喜欢树状数组这种东西,所以决定用分块来水这个题.直接在莫队维护信息的时候,维护单点同时维护块内信息就行了. 莫队就是这几行核心代码: void add(in ...

  7. Windows Server 2012 / 2016 安装 .Net Framework 3.5(PowerShell)

    原文链接:https://www.muhanxue.com/essays/2017/04/3736598.html 问题描述 使用 Windows Server 2012 R2 或 Windows S ...

  8. Redis位图法记录在线用户的状态

    Redis位图法记录在线用户的状态 位图 Redis官方文档对于位图的介绍如下: 位图不是一个真实的数据类型,而是定义在字符串类型上的面向位的操作的集合.由于字符串类型是二进制安全的二进制大对象,并且 ...

  9. js例子

    1.子菜单下拉 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  10. C#泛型类的用途和说明

    class Program    {        public class Test<T, S>        {           //泛型类的类型参数可用于类成员          ...