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 ...
随机推荐
- 升级ndk后Android studio的build错误
上周末升级了ndk,应该是最新版的v17.0版本了,当时也没测试,屁颠屁颠的就回家撸猫了... 今天一跑代码在build时报错: ABIs [armeabi] are not supported fo ...
- Hbase框架原理及相关的知识点理解、Hbase访问MapReduce、Hbase访问Java API、Hbase shell及Hbase性能优化总结
转自:http://blog.csdn.net/zhongwen7710/article/details/39577431 本blog的内容包含: 第一部分:Hbase框架原理理解 第二部分:Hbas ...
- apt-get 命令加 autoclean clean autoremove 区别
下面总结一下有关apt-get的常用但容易混淆的指令: apt-get autoclean: www.2cto.com 如果你的硬盘空间不大的话,可以定期运行这个程序,将已经删除了的软 ...
- phpc.sinaapp.com 加密的解密方法
很简单,用类似phpjm的解密方式,替换掉_inc.php中最后一个return中的eval为print就出来了. http://www.cnblogs.com/lonelyxmas/p/458285 ...
- SpringMVC系列(十一)把后台返回的数据转换成json、文件下载、文件上传
一.后台返回的数据转换成json 1.引入转换json需要的3个依赖 <!--json转换需要的依赖 begin --> <dependency> <groupId> ...
- Java数组列表反转
在Java中,如何反转数组列表中的元素? 以下示例使用Collections.reverse(ArrayList)方法反转数组列表中的元素. package com.yiibai; public cl ...
- e612. Moving the Focus to the Next or Previous Focusable Component
The methods to move the focus to the next or to the previous focusable component are Component.trans ...
- Python操作SQLServer示例(转)
转自:http://www.cnblogs.com/lrzy/p/4346781.html 本文主要是Python操作SQLServer示例,包括执行查询及更新操作(写入中文). 需要注意的是:读取数 ...
- Lua------------------unity与lua的热更新
[Unity3D]Unity3D游戏开发之Lua与游戏的不解之缘终结篇:UniLua热更新完全解读 标签: 游戏开发游戏解决方案用户体验unity3d 2014-10-18 23:23 7680人阅读 ...
- Linux 系统安装配置PHP服务(源码安装)
简介: PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言.语法吸收了C语言.Java和Perl的特点,利于学习,使用广泛,主要 ...