前提:

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. luogu2014 选课 背包类树形DP

    题目大意:有N门功课,每门课有个学分,每门课有一门或没有直接先修课(若课程a是课程b的先修课即只有学完了课程a,才能学习课程b).一个学生要从这些课程里选择M门课程学习,问他能获得的最大学分是多少? ...

  2. 0x61 最短路

    终于会dij了原来我以前写的也是堆优化spfa-_-! poj3662DP 通过spfa来放缩(可怜我去年NOIP的day1t3啊) #include<cstdio> #include&l ...

  3. 【JSOI 2008】 球形空间产生器

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1013 [算法] 高斯消元 [代码] #include<bits/stdc++. ...

  4. 南海区行政审批管理系统接口规范v0.3(规划)

    1. 会话API 1.1. login [登录验证] {"r_code":"500","r_msg":"操作失败",&q ...

  5. raspberry-常用命令

    安全关闭raspberry:sudo shutdown -h now 一次升级系统中的所有内容:sudo apt-get update 升级单个软件包:sudo apt-get install *** ...

  6. WPF中StringToImage和BoolToImage简单用法

    在WPF的绑定控件操作中,经常会通过bool值或者某些特定的string值做出相应动作.但UI层控件的很多属性对应的都不是Bool值或者对应的只是固定的String值. 这个时候有两方法解决该问题. ...

  7. Java中利用随机数的猜拳游戏

    Java中利用随机数的猜拳游戏,实现非常简单,重难点在于随机数的产生. 首先GameJude类是用于判断输赢的一个类: package testGame; public class GameJudge ...

  8. ios UISegmentedControl的使用简介

    初始化UISegmentedControl NSArray *arr = [[NSArray alloc]initWithObjects:@"轻拍",@"长按" ...

  9. B - Nearly Lucky Number

    Problem description Petya loves lucky numbers. We all know that lucky numbers are the positive integ ...

  10. mvc 伪静态任意扩展名的实现方法

    比如:要实现 http://localhost:60291/home/geta/1212.html 或者 .abc 任意扩展名 完成两步即可. 第一步修改路由: public static void ...