前提:

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. PostgreSQL sum typecasting as a bigint

    https://stackoverflow.com/questions/20203081/postgresql-sum-typecasting-as-a-bigint Question: I am d ...

  2. Thread和ThreadGroup

    Thread和ThreadGroup 学习了:https://www.cnblogs.com/yiwangzhibujian/p/6212104.html  这个里面有Thread的基本内容: htt ...

  3. pl/sql developer 布局结构保存

    pl/sql developer 布局结构保存 调整了工具栏,调整了窗体框位置,点击 窗口->保存版面 就可以保留当前的调整的结果,不用一次一次调整了: 也可以在工具 -> 首选项 -&g ...

  4. Java IO之简单输入输出

    Java中的IO分为两个部分,以InputStream和Reader为基类的输入类,以OutputStream和Writer为基类的输出类. 当中InputStream和OutputStream以字节 ...

  5. Web端即时通讯、消息推送的实现

    https://blog.csdn.net/DeepLies/article/details/77726823

  6. 逻辑运算0==x和x==0具体解释

    看很多大牛写的程序经常看到if(0==x){运行体},而自己写的程序常用if(x==0){运行体}.刚開始的时候我还非常自信的觉得这样的表达方式是等价的,大牛们仅仅是为了显摆下与众不同的格调.当读到C ...

  7. 火狐Vimperator插件

    http://www.iplaysoft.com/vimium-and-vimperator.html http://wangbixi.com/x2923/comment-page-1/

  8. nyoj--635--Oh, my goddess(dfs)

    Oh, my goddess 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 Shining Knight is the embodiment of justice an ...

  9. Node.js:Web 模块

    ylbtech-Node.js:Web 模块 1.返回顶部 1. Node.js Web 模块 什么是 Web 服务器? Web服务器一般指网站服务器,是指驻留于因特网上某种类型计算机的程序,Web服 ...

  10. SSH整合报错:找不到元素 'beans' 的声明

    转自:https://blog.csdn.net/haozhugogo/article/details/54233608 spring版本问题,将bean.xml中xsd文件定义的版本改为spring ...