使用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. ...
随机推荐
- pt-kill--- MySQL数据库CPU飙升紧急处理方法
MySQL数据库CPU飙升紧急处理方法 [日期:2014-01-22] 来源:Linux社区 作者:hcymysql [字体:大 中 小] 运行平稳的数据库,如果遇到CPU狂飙,到80% ...
- HDU 4507
数位DP. 一般是利用DFS来求数位DP了,结合了记忆化搜索.设dp[i][j][k]为前i位,并且前i位的数位和mod7为j,前i位的数字的表示数字值mod7.为什么可以这样呢?因为继续DFS下去, ...
- UVA - 348Optimal Array Multiplication Sequence(递推)
id=19208">题目:Optimal Array Multiplication Sequence 题目大意:给出N个矩阵相乘.求这些矩阵相乘乘法次数最少的顺序. 解题思路:矩阵相乘 ...
- Chromium多线程模型设计和实现分析
Chromium除了远近闻名的多进程架构之外,它的多线程模型也相当引人注目的.Chromium的多进程架构是为了解决网页的稳定性问题,而多线程模型则是为了解决网页的卡顿问题.为了达到这个目的,Chro ...
- NYOJ_268_荷兰国旗问题
荷兰国旗问题 时间限制:3000 ms | 内存限制:65535 KB 难度:1 描写叙述 荷兰国旗有三横条块构成,自上到下的三条块颜色依次为红.白.蓝.现有若干由红.白.蓝三种颜色的条块序列.要 ...
- 51-nod -1284 2 3 5 7的倍数
1284 . 2 3 5 7的倍数 基准时间限制:1 秒 空间限制:65536 KB 分值: 5 给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数. 比如N = 10,仅仅有1不是2 3 ...
- Swift-理解值类型
在这里,我们要讲讲值类型和写时复制.在 swift 的标准库中,所有的集合类型都使用了写时复制.我们在本篇文章中看一下写时复制如何工作的,并且如何实现它. 引用类型 使用 swift 的 Data 和 ...
- hdoj--1150--Machine Schedule(最小点覆盖)
Machine Schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Cracking the Coding Interview 5.2
Given a(decimal -e.g. 3.72)number that is passed in as a string, print the binary representation. If ...
- Hashmap 详解和迭代器问题
重点介绍HashMap.首先介绍一下什么是Map.在数组中我们是通过数组下标来对其内容索引的,而在Map中我们通过对象来对对象进行索引,用来索引的对象叫做key,其对应的对象叫做value.在下文中会 ...