当前位置: 首页 > news >正文

ansible-playbook roles编写lnmp剧本

目录

集中式编写lnmp剧本

执行

分布式编写lnmp剧本

一定要设置ssh免交互

 nginx

mysql

php

 执行


集中式编写lnmp剧本

vim /etc/ansible/lnmp.yml
- name: lnmp playhosts: dbserversremote_user: roottasks:- name: perpare condifurecopy: src=/etc/yum.repos.d/nginx.repo dest=/etc/yum.repos.d/nginx.repo- name: install nginxyum: name=nginx state=latest- name: start nginxservice: name=nginx state=started enabled=yes- name: install mysqlyum: name=mysql57-community-release-el7-10.noarch.rpm state=latest- name: modify filereplace:path: /etc/yum.repos.d/mysql-community.reporegexp: 'gpgcheck=1'replace: 'gpgcheck=0'- name: install mysql-community-serveryum: name=mysql-community-server state=latest- name: start mysqlservice: name=mysqld state=started enabled=yes- name: add yum filecommand: 'wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm -P /etc/yum.repos.d' - name: rpm epelcommand: 'rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm'- name: rpm el7command: 'rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm'- name: install phpcommand: 'yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache'- name: start php-fpmservice: name=php-fpm state=started  enabled=yes- name: copy configurecopy: src=/usr/local/nginx/conf/nginx.conf dest=/etc/nginx/conf.d/default.conf- name: restart nginxservice: name=nginx state=started enabled=yes

执行

ansible-playbook lnmp.yml

分布式编写lnmp剧本

一定要设置ssh免交互

ssh-keygen -t rsa
sshpass -p’zxr123‘ ssh-copy-id  192.168.110.60 
mkdir /etc/ansible/roles/httpd/{files,templates,tasks,handlers,vars,defaults,meta} -p
mkdir /etc/ansible/roles/mysql/{files,templates,tasks,handlers,vars,defaults,meta} -p
mkdir /etc/ansible/roles/php/{files,templates,tasks,handlers,vars,defaults,meta} -ptouch /etc/ansible/roles/httpd/{defaults,vars,tasks,meta,handlers}/main.yml
touch /etc/ansible/roles/mysql/{defaults,vars,tasks,meta,handlers}/main.yml
touch /etc/ansible/roles/php/{defaults,vars,tasks,meta,handlers}/main.yml

 nginx

cd /etc/ansible/roles/nginx/filesindex.php  nginx.repo
 vim /etc/ansible/roles/nginx/files/index.php
<?php
phpinfo();
?>

 vim /etc//ansible/roles/nginx/files/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

 vim /etc/ansible/roles/nginx/main.yml
- include: "init.yml"- name: copy nginx repocopy: src=nginx.repo dest=/etc/yum.repos.d/
- name: install nginxyum: name=nginx state=latest
- name: copy index.phpcopy: src=index.php dest=/var/www/html
- name: transmit nginx configurationtemplate: src=default.conf.j2 dest=/etc/nginx/conf.d/default.conf
- name: start nginxservice: name=nginx state=started enabled=yes

vim /etc/ansible/roles/index.php
- name: stop firewalldservice: name=firewalld state=stopped enabled=no
- name: stop selinuxcommand: 'setenforce 0'

vim /etc/ansible/roles/nginx/template/default.conf.j2
server {listen       80;server_name  localhost;#access_log  /var/log/nginx/host.access.log  main;location / {root   /var/www/html;index  index.php index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root           html;fastcgi_pass   192.168.110.60:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;include        fastcgi_params;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}
}

mysql

vim /etc/ansible/roles/mysql/tasks/init.yml
- name: stop firewalldservice: name=firewalld state=stopped enabled=no
- name: stop selinuxcommand: 'setenforce 0'

vim /etc/ansible/roles/mysql/main.yml
- include: "init.yml"- name: remove mariadbshell: 'yum remove mariadb* -y'
- name: wgetshell: 'wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm -P /etc/yum.repos.d'
- name: install mysql57-community-release-el7-10.noarch.rpmyum: name=epel-release
- name: sedreplace: path=/etc/yum.repos.d/mysql-community.repo regexp="gpgcheck=1" replace="gpgcheck=0"
- name: install mysql-community-serveryum: name=mysql-community-server
- name: start mysqlservice: name=mysqld.service state=started
- name: passdshell: passd=$(grep "password" /var/log/mysqld.log | awk 'NR==1 {print $NF}')
- name: mysql 1shell: mysql -uroot -p'passd' --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'ZXRabc@123';"ignore_errors: true
- name: mysql 2shell: mysql -uroot -pZXRabc@123 -e "grant all privileges on *.* to root@'%' identified by 'ZXRabc@123' with grant option;"ignore_errors: true

php

vim /etc/ansible/roles/php/tasks/init.yml
- name: stop firewalldservice: name=firewalld state=stopped enabled=no
- name: stop selinuxcommand: 'setenforce 0'

vim /etc/ansible/rolesphp/tasks/main.yml
- include: "init.yml"- name: install yum reposhell: "rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm"ignore_errors: true
- name: install phpcommand: 'yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache'
- name: add useruser:name: phpshell: /sbin/nologinsystem: yes
- name: copy php.inicopy: src=php.ini dest=/etc/php.ini
- name: copy www.confcopy: src=www.conf dest=/etc/php-fpm.d/www.conf
- name: copy index.phpcopy: src=index.php dest=/var/www/html
- name: start php-fpmservice: name=php-fpm state=started

 执行

vim /etc/ansible/lnmp.yml
- name: nginx playhosts: webserversremote_user: rootroles:- nginx- name: mysql playhosts: dbserversremote_user: rootroles:- mysql- name: php playhosts: phpserversremote_user: rootroles:- php
ansible-playbook lnmp.yml

相关文章:

ansible-playbook roles编写lnmp剧本

目录 集中式编写lnmp剧本 执行 分布式编写lnmp剧本 一定要设置ssh免交互 nginx mysql php 执行 集中式编写lnmp剧本 vim /etc/ansible/lnmp.yml - name: lnmp playhosts: dbserversremote_user: roottasks:- name: perpare condifurecopy: src/etc/yum.repos.d/nginx.r…...

相机可用性变化监听AvailabilityCallback流程分析

相机可用性变化监听及流程分析 一、接口说明 ​ 相机可用性变化监听可以通过CameraManager中的接口registerAvailabilityCallback()来设置回调&#xff0c;接口如下&#xff1a; /** *注册一个回调以获得有关相机设备可用性的通知。 * *<p>再次注册相同的回调将用提供…...

使用Python多线程实现生产者消费者模型

“Talk is cheap, show me the code.” 废话不多说&#xff0c;直接上代码&#xff1a; """ 生产者消费者模型 Python实现 """ import queue import threading import random import timeclass ConsProd:# 队列参数_que None # 队列# 生产者…...

Notepad++工具通过正则表达式批量替换内容

1.每行末尾新增特定字符串 CtrlH弹出小窗口&#xff1b;查找目标输入$&#xff0c;替换为输入特定字符串&#xff1b;选中循环查找&#xff0c;查找模式选正则表达式&#xff1b;最后点击全部替换 2.每行行首新增特定字符串 CtrlH弹出小窗口&#xff1b;查找目标输入^&…...

从零构建深度学习推理框架-3 手写算子relu

Relu介绍&#xff1a; relu是一个非线性激活函数&#xff0c;可以避免梯度消失&#xff0c;过拟合等情况。我们一般将thresh设为0。 operator类&#xff1a; #ifndef KUIPER_COURSE_INCLUDE_OPS_OP_HPP_ #define KUIPER_COURSE_INCLUDE_OPS_OP_HPP_ namespace kuiper_infer {…...

想做上位机,学C#还是QT?

学习C#还是Qt&#xff0c;取决于你的具体需求和偏好。 如果你计划开发跨平台的桌面应用程序&#xff0c;并且希望使用一种更轻量级、直观的界面框架&#xff0c;那么Qt可能是一个不错的选择。Qt是一个功能丰富且成熟的跨平台框架&#xff0c;支持多种开发语言&#xff08;包括…...

Ansible —— playbook 剧本

Ansible —— playbook 剧本 一、playbook的概述1.playbook简介2.什么是Ansible playbook剧本&#xff1f;3.Ansible playbook剧本的特点4.如何使用Ansible playbook剧本&#xff1f;5.playbooks 本身由以下各部分组成 二、playbook示例1.运行playbook2.定义、引用变量3.指定远…...

ARM寻址方式

寻址方式 寻址方式是根据指令中给出的地址码字段来实现寻找操作数地址的方式&#xff0c;ARM中有以下8种基本的寻址方式。 1、寄存器寻址 将寄存器中的值作为操作数&#xff0c;指令中的地址码字段是寄存器编号。 MOV R1,R2 ;R1 R2 ADD R0,R1,R2 ;R0 R1 R22、立即寻…...

【JAVA】String ,StringBuffer 和 StringBuilder 三者有何联系?

个人主页&#xff1a;【&#x1f60a;个人主页】 系列专栏&#xff1a;【❤️初识JAVA】 文章目录 前言StringBufferStringBuffer方法 StringBuilderStringBuilder方法 String &#xff0c;StringBuffer 和 StringBuilder的区别String和StringBuffer互相转换 前言 在之前的文章…...

关于计数以及Index返回订单号升级版(控制字符长度,控制年月标记)

数据库表操作&#xff1a; EXEC sys.sp_dropextendedproperty nameNName , level0typeNSCHEMA,level0nameNdbo, level1typeNTABLE,level1nameNSetNoIndexGOEXEC sys.sp_dropextendedproperty nameNMS_Description , level0typeNSCHEMA,level0nameNdbo, level1typeNTABLE,level…...

【计算机网络】11、网桥(bridge)、集线器(hub)、交换机(switch)、路由器(router)、网关(gateway)

文章目录 一、网桥&#xff08;bridge)二、集线器&#xff08;hub&#xff09;三、交换机&#xff08;switch)四、路由器&#xff08;router&#xff09;五、网关&#xff08;gateway&#xff09; 对于hub&#xff0c;一个包过来后&#xff0c;直接将包转发到其他口。 对于桥&…...

第九篇-自我任务数据准备

格式化自我意识数据用于ChatGLM微调 准备数据源 https://github.com/hiyouga/ChatGLM-Efficient-Tuning cd data self_cognition.json代码self_process.py #!/usr/bin/python # -*- coding: UTF-8 -*- # 读取self_cognition自我认知解析并写入转换新文件import json# 读取se…...

2023.8.1号论文阅读

文章目录 MCPA: Multi-scale Cross Perceptron Attention Network for 2D Medical Image Segmentation摘要本文方法实验结果 SwinMM: Masked Multi-view with SwinTransformers for 3D Medical Image Segmentation摘要本文方法实验结果 MCPA: Multi-scale Cross Perceptron Att…...

webpack优化前端框架性能

webpack优化目的 webpack优化目的1. 提升开发体验提升开发体验使用 SourceMap 2. 提升打包构建速度提升打包构建速度&#xff08;开发模式&#xff09;提升打包速度 oneOf提升打包速度 include&#xff08;包含&#xff09;/exclude&#xff08;排除&#xff09;提升第二次打包…...

Unity UGUI的Outline(描边)组件的介绍及使用

Unity UGUI的Outline(描边)组件的介绍及使用 1. 什么是Outline(描边)组件&#xff1f; Outline(描边)组件是Unity UGUI中的一种特效组件&#xff0c;用于给UI元素添加描边效果。通过设置描边的颜色、宽度和模糊程度&#xff0c;可以使UI元素在视觉上更加突出。 2. Outline(描…...

爆改vue3 setup naiveui可编辑table

使用naiveui官网的可编辑table总是报错&#xff0c;所以手写了一个 思路&#xff1a;table数据数组unitMsgArr对应一个布尔的数组isEditArr &#xff0c;点击table可编辑的行数据的时候&#xff0c;更改对应的isEdit为true&#xff0c;此时渲染组件EditCom&#xff0c;在EditC…...

功率放大器的种类有哪三种类型

功率放大器是一种能将输入信号转换为更高功率输出的电子设备。在电子工程和音频领域中&#xff0c;功率放大器通常被分为三种类型&#xff1a;A类、B类和AB类。下面安泰电子将详细介绍这三种类型的功率放大器及其特点。 A类功率放大器 A类功率放大器是一种基本的线性功率放大器…...

HDFS 分布式存储 spark storm HBase

HDFS 分布式存储 spark storm HBase 分布式结构 master slave name node client 负责文件的拆分 128MB 3份 data node MapReduce 分布式计算 离线计算 2.X之前 速度比较慢 对比spark 编程思想 Map 分 Reduce 合 hadoop streaming Mrjob Yarn 资源管理 cpu 内存 MapReduc…...

Vue3文字实现左右和上下滚动

可自定义设置以下属性&#xff1a; 滚动文字数组&#xff08;sliderText&#xff09;&#xff0c;类型&#xff1a;Array<{title: string, link?: string}>&#xff0c;必传&#xff0c;默认[] 滚动区域宽度&#xff08;width&#xff09;&#xff0c;类型&#xff1a…...

Docker Sybase修改中文编码

镜像&#xff1a;datagrip/sybase 镜像默认用户名sa&#xff0c;密码myPassword&#xff0c;服务名MYSYBASE 1.进入容器 docker exec -it <container_name> /bin/bash2.加载Sybase环境变量 source /opt/sybase/SYBASE.sh3.查看是否安装了中文字符集 isql -Usa -PmyP…...

拒绝“一眼AI”!硬核跑通Gemini去AIGC工作流:实测3组调优指令+3款工具,把99%硬生生打回10%

视角重构&#xff0c;打破“平铺直叙”的机械感 AI生成的最大特征是“正确但平庸的上帝视角”。要ai降ai&#xff0c;第一步不是改词&#xff0c;而是强行植入一个具有批判性的“人类观察者”视角&#xff0c;迫使模型重组叙事逻辑。 核心原理&#xff1a;通过引入“辩证法”…...

YOLOv11模型导出实战:从PyTorch到多平台部署的完整指南

1. YOLOv11模型导出前的准备工作 第一次接触模型导出时&#xff0c;我踩过不少坑。记得有次在客户现场调试&#xff0c;因为环境配置问题折腾了一整天。所以咱们先把基础打牢&#xff0c;避免走弯路。 硬件环境方面&#xff0c;建议至少准备&#xff1a; 配备NVIDIA显卡的机器&…...

从数据到诊断:深度学习驱动下的多模态抑郁症识别技术全景

1. 抑郁症识别技术的现状与挑战 抑郁症被称为21世纪的"心灵感冒"&#xff0c;全球约有3.5亿患者。传统诊断主要依赖医生问诊和量表评估&#xff0c;这种方式存在主观性强、耗时长的痛点。我在参与某三甲医院精神科数字化改造项目时&#xff0c;亲眼见证了一位资深医生…...

车辆纵向建模避坑指南:如何正确处理空气阻力与轮胎摩擦的耦合效应

车辆纵向建模避坑指南&#xff1a;如何正确处理空气阻力与轮胎摩擦的耦合效应 在自动驾驶仿真和车辆控制算法开发中&#xff0c;精确的纵向动力学建模是确保虚拟测试与实车表现一致性的关键。许多工程师都遇到过这样的困境&#xff1a;仿真环境下调参完美的模型&#xff0c;在…...

别再让MATLAB并行池浪费你的内存!保姆级教程教你手动精准管理Parallel Pool

MATLAB并行池内存优化实战&#xff1a;从自动管理到精准控制 在科学计算和工程仿真领域&#xff0c;MATLAB的Parallel Computing Toolbox无疑是提升运算效率的利器。但许多资深用户都曾经历过这样的困扰&#xff1a;完成大规模并行计算后&#xff0c;发现系统内存依然被并行池占…...

国内热门的PP配件源头厂家有哪些

在工业环保领域&#xff0c;PP&#xff08;聚丙烯&#xff09;配件是PP通风处理设备的重要组成部分&#xff0c;广泛应用于各类废气处理和通风场景。以下为你介绍一些国内热门的PP配件源头厂家。惠州熙诚环保科技有限公司技术实力&#xff1a;该公司创立于2009年&#xff0c;17…...

113. 强制使用 Letsencrypt ECDSA 和 DNS-01 续期挑战的默认 HTTPS Rancher 证书

Environment 环境 2.9 Situation 地理位置A self-signed default Rancher certificate is currently used and will be migrated to a stronger Let’s Encrypt ECDSA-386 certificate using the DNS-01 renewal challenge. 目前使用自签名默认的牧场证书&#xff0c;并将通过…...

Claude Code每日更新速览(v2.1.90)-2026/04/02

本文前言&#xff1a; Claude Code 的进化速度&#xff0c;已经到了一种让人来不及消化的程度。根据 github.com/anthropics/claude-code/blob/main/CHANGELOG.md 获取最新的变更&#xff0c;跟紧 Claude Code新功能、新趋势。最新版本&#xff1a;v2.1.90提交时间&#xff1a;…...

Android 11+ 适配实战:破解TextToSpeech ‘speak failed: not bound to TTS engine‘ 的权限与引擎绑定之谜

1. 当语音突然沉默&#xff1a;Android 11的TTS报错之谜 那天我正在调试一个天气预报应用&#xff0c;当代码执行到语音播报"今天晴转多云"时&#xff0c;控制台突然抛出红字警告&#xff1a;speak failed: not bound to TTS engine。这个错误在Android 10及以下版本…...

ENVI实战:利用传感器波谱响应函数实现光谱曲线精准重采样

1. 为什么需要光谱重采样&#xff1f; 在遥感数据分析中&#xff0c;我们经常会遇到一个头疼的问题&#xff1a;不同传感器采集的光谱数据分辨率不一致。比如实验室用光谱仪测量的叶片反射率可能有上千个波段&#xff0c;而Landsat-8卫星只能获取11个波段的数据。这就好比用高清…...