使用Ansible安装部署nginx+php+mysql之配置iptables防火墙(0)
前提:
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)的更多相关文章
- 使用Ansible安装部署nginx+php+mysql之安装mysql(3)
三.使用Ansible安装mysql 1.mysq.yaml文件 - hosts: clong remote_user: root gather_facts: no tasks: # 安装rpm包 - ...
- 使用Ansible安装部署nginx+php+mysql之安装php(2)
二.使用Ansible安装php 1.php.yaml文件内容 - hosts: clong remote_user: root gather_facts: no tasks: # 安装libseli ...
- 使用Ansible安装部署nginx+php+mysql之安装nginx(1)
使用Ansible安装nginx 1.nginx.yaml文件 --- - hosts: clong remote_user: root gather_facts: no tasks: # 安装epe ...
- Ansible安装部署以及常用模块详解
一. Ansible 介绍Ansible是一个配置管理系统configuration management system, python 语言是运维人员必须会的语言, ansible 是一个基于py ...
- docker 部署 nginx+php+mysql
系统:centos7 使用root账户 开放80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent 安装docker yum ins ...
- centos7 下 安装部署nginx
centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...
- RHEL6 最小化系统 编译安装部署zabbix (mysql)
RHEL6 最小化系统 编译安装部署zabbix (mysql)官方说明详细见:https://www.zabbix.com/documentation/4.0/manual/installation ...
- 第1天:Ansible安装部署
Ansible介绍 Ansible是一个简单的自动化引擎,可完成配置管理.应用部署.服务编排以及各种IT需求.它是一款使用Python语言开发实现的开源软件,其依赖Jinjia2.paramiko和P ...
- Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程
Ubuntu14.04(nginx+php+mysql+vsftp)配置安装流程 1.先切换到root用户 sudo su 2.更新软件源 apt update apt-get upgrade 3. ...
随机推荐
- CharsRefIntHashMap并不比HashMap<String, Integer>快
我模仿lucene的BytesRef写了一个CharsRefIntHashMap,实測效果并不如HashMap<String, Integer>.代码例如以下: package com.d ...
- Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead的解决的方法
今天在eclipse里报这个错误: Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Plea ...
- ubuntu终端白屏的解决方法
昨天突发奇想的想为teminal设置一个背景, 这样.... 不过过了一会就高兴不起来了,,,,终端白屏!好吧,现在我页没办法彻底解决, 不过暂时的一个方法是可以把首选项->背景->背景图 ...
- 【撸码caffe 二】 blob.hpp
Blob类是caffe中对处理和传递的实际数据的封装,是caffe中基本的数据存储单元,包括前向传播中的图像数据,反向传播中的梯度数据以及网络层间的中间数据变量(包括权值,偏置等),训练模型的参数等等 ...
- Node.js:常用工具
ylbtech-Node.js:常用工具 1.返回顶部 1. Node.js 常用工具 util 是一个Node.js 核心模块,提供常用函数的集合,用于弥补核心JavaScript 的功能 过于精简 ...
- [CSharp] C#开源大全
商业协作和项目管理平台-TeamLab 网络视频会议软件-VMukti 驰骋工作流程引擎-ccflow [免费]正则表达式测试工具-Regex-Tester Windows-Phone-7-SDK E ...
- Linux Shell Scripting Cookbook 读书笔记 5
sed,awk 1. sed (string editor) 使用-i可以将结果运用于原文件 sed 's/text1/text2/' file > newfile mv newfile fil ...
- 移动端的click事件延迟触发的原理是什么?如何解决这个问题?
移动端的click事件延迟触发的原理是什么?如何解决这个问题? 原理 :移动端屏幕双击会缩放页面 300ms延迟 会出现点透现象 在列表页面上创建一个弹出层,弹出层有个关闭的按钮,你点了这个按钮关闭弹 ...
- SilverLight Q&A
1.在学校prism,Unity框架的时候,遇到的问题“The IModuleCatalog is required and cannot be null in order to initialize ...
- 如何在C#中运行数学表达式字符串
方法1:利用DataTable中的Compute方法 1 string expression = "1+2*3"; 2 DataTable eval = new DataTable ...