Ansible 实战:一键安装 LNMP
Ansible 配置文件 :
[root@center /data/ansiblework]# cat ansible.cfg
[defaults]
remote_user = root
remote_port = 22
inventory = /data/ansiblework/hosts
log_path = /var/log/ansible.log
host_key_checking = False
retry_files_enabled = False
Ansible 主机配置 :
[root@center /data/ansiblework]# cat hosts
[new_hosts]
192.168.1.1
192.168.1.2
192.168.1.3 [new_hosts:vars]
ansible_ssh_port = 22 # 远程连接端口
ansible_ssh_user = root # 远程连接用户
ansible_ssh_pass = 123456 # 远程连接密码
Ansible Playbook :
[root@center /data/ansiblework]# cat onekey_init.yml
---
- hosts: new_hosts
gather_facts: True
tasks:
- name: 下发公钥到新主机
authorized_key: user=root key="{{ lookup('file', '/root/.ssh/id_rsa.pub') }}" - name: 检查系统版本
fail: msg="系统版本错误,请检查"
when: ansible_facts['distribution'] != "CentOS" or ansible_facts['distribution_major_version'] != "" - name: 检查是否挂载/data目录
fail: msg="/data目录未挂载,请检查"
when: not ansible_mounts[1].mount == "/data" - name: 检查/data目录是否挂载异常
fail: msg="/data目录小于250G,请检查"
when: ansible_mounts[1].size_total | int < 250000000000 - name: 拷贝初始化脚本
template: src={{ item }} dest=/tmp/{{ item }} owner=root group=root
with_items:
- base_lnmp.sh
- lnmp_install.sh - name: 检查是否安装过LNMP
shell: if [ -f /tmp/install.log ];then grep 'Install Complete' /tmp/install.log;fi || echo None
register: result - name: 开始安装LNMP
shell: /bin/sh /tmp/lnmp_install.sh > /tmp/install.log
when: "'Install Complete' not in result.stdout" - name: 检查是否安装按成
shell: if [ -f /tmp/install.log ];then grep 'Install Complete' /tmp/install.log;fi || echo None
register: result
- fail: msg="安装失败,请登录到安装机器查看/tmp/install.log查看原因"
when: "'Install Complete' not in result.stdout" - name: 检查LNMP安装状态
shell: ps aux | egrep "(php|nginx|mysql|zabbix|salt)"
register: result
- fail: msg="{{ item }}安装异常,请检查"
when: "item not in result.stdout"
with_items:
- php
- mysql
- nginx
- zabbix
- salt-minion
Ansible 实战:一键安装 LNMP的更多相关文章
- Centos6.5中 一键安装LNMP 安装Yii2.0 手工配置
1.一键安装LNMP cd /usr wget -c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz tar zxf lnmp1.-full.tar.gz ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- 一键安装LNMP(适合centos7)
1.准备工作,下载源码包 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar ...
- Linux一键安装LNMP环境
Linux一键安装LNMP环境 官方地址:https://lnmp.org/. 参考安装步骤:https://lnmp.org/install.html. 一键安装可以选择mysql版本.php版本, ...
- Linux安装swoole拓展 (一键安装lnmp后安装可用完美)
一键安装lnmp后安装可用完美 swoole(一键安装完lnmp重启下,之前出现502一直解决不了,不清楚啥情况) 找到对应php版本,在lnmp文件夹的src 1.安装swoole cd /usr/ ...
- 一键安装Lnmp教程
LNMP一键安装包 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP ...
- 【Linux】Centos6.8下一键安装Lnmp/Lamp环境
[下载一键安装软件包] 百度云地址:https://pan.baidu.com/s/1TZqGKtE-46gxW96Ptfp4gA 网址:https://lnmp.org/ [步骤] 通过第三方远程工 ...
- 一键安装LNMP/LAMP
安装步骤:1.使用putty或类似的SSH工具登陆VPS或服务器: 登陆后运行:yum install screen安装 screen screen -S lnmp创建一个名字为lnmp的会话 2. ...
- 一键安装 lnmp/lamp/lanmp
1.使用putty或类似的SSH工具登陆VPS或服务器 # screen -S lnmp 如果提示screen: command not found 命令不存在可以执行:yum install scr ...
随机推荐
- Java相对路径/绝对路径总结
Version:0.9 StartHTML:-1 EndHTML:-1 StartFragment:00000099 EndFragment:00019826 Java相对路径/绝对路径总结(2) 修 ...
- LEARNING TO NAVIGATE IN COMPLEX ENVIRONMENTS
任务是地图里面导航,让agent从起始点到达指定位置. 用了supervised learning + reinforcement learning + lstm 用supervised learni ...
- Python之进度条
pip install tqdm from tqdm import tqdm,trange import time for char in tqdm(['a','b','c','d']): time. ...
- MyBatis错误:Result Maps collection already contains value for novel.storage.mapper.NovelMapper.BaseResultMap
今天在写项目的时候遇到一个问题如下: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ...
- 用OpenGL实现粒子的随机运动
一.目的: 掌握OpenGL中粒子的绘制.随机数的使用 二.代码: Github地址 #include "stdafx.h" #include <GL/glut.h> ...
- C++ 把枚举变量的名称,直接当字符串使用方法 字符串化符号 #
#include <stdio.h> #include <typeinfo> #include <string> using namespace std; enum ...
- Unity-------------------------关于GUI绘制的编程
转载:在这篇文章中我将给读者介绍Unity中的图形用户界面(GUI)编程.Unity有一个非常强大的GUI脚本API.它允许你使用脚本快速创建简单的菜单和GUI. 简介 Unity提供了使用脚本创建G ...
- SqlParameter 之 in
List<string> ConditionList = new List<string>(); List<string> tempParameters = new ...
- Nginx安装 默认虚拟主机 Nginx用户认证 Nginx域名重定向
Nginx安装 cd /usr/local/src (http://nginx.org/en/download.html) wget http://nginx.org/download/nginx-1 ...
- qq划屏幕红包程序
qq划屏幕红包程序