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

Jenkins调用ansible部署lnmp平台

目录

一、准备工作

1.1、准备两台虚拟机

1.2、配置文件

1.3、Jenkins网页安装ansible插件

二、构建项目

1.构建主item

3.测试item

3.1新建item

3.2与主item关联

4.部署item(dicuz)

2.新建部署item

3.测试

4.关联测试item

5.整体测试


一、准备工作

1.1、准备两台虚拟机

服务器:192.168.80.186(jenkins)

客户端:192.168.80.183

1.2、配置文件

安装ansible

 [root@jenkins ~]# yum -y install ansible

修改配置文件

 #将107行的注释去掉[root@jenkins ~]# vim /etc/ansible/ansible.cfg107 remote_user = root   

添加目标主机

[root@jenkins ~]# vim /etc/ansible/hosts 
[webServer]
192.168.80.183

生成jenkins用户的密码

[root@jenkins ~]# su -s /bin/bash jenkins
bash-5.2$ ssh-keygen
Generating public/private ed25519 key pair.
Enter file in which to save the key (/var/lib/jenkins/.ssh/id_ed25519): 
Created directory '/var/lib/jenkins/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /var/lib/jenkins/.ssh/id_ed25519
Your public key has been saved in /var/lib/jenkins/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:OYuvQOatCCe5YmcPc+xvJFdFY7TptUQJ+wQluaCfWOk jenkins@jenkins
The key's randomart image is:
+--[ED25519 256]--+
|          oO+o.  |
|         ..oO.   |
|        . ++.+   |
|       . =..= .  |
|    o   S .. o   |
| . +.o = E       |
|+ .ooo* .        |
|.* +=o o         |
|+ + oo+o.        |
+----[SHA256]-----+将密钥拷给客户端root用户
bash-5.2$ ssh-copy-id root@192.168.80.183bash-5.2$ ansible webServer -m ping
[WARNING]: Platform linux on host 192.168.80.183 is using the discovered Python interpreter at /usr/bin/python3, but future
installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
192.168.80.183 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": false,"ping": "pong"
}

1.3、Jenkins网页安装ansible插件

配置ansible

/usr/bin/ ansible命令存放位置

二、构建项目

1.构建主item

新建item

env设置

配置构建步骤

进行构建

构建结果

去客户机验证

[root@nfs-server ~]# 
[root@nfs-server ~]# rpm -q nginx
nginx-1.24.0-5.oe2403sp1.x86_64
[root@nfs-server ~]# rpm -q mysql
mysql-8.0.43-1.oe2403sp1.x86_64
[root@nfs-server ~]# rpm -q mysql-server
mysql-server-8.0.43-1.oe2403sp1.x86_64
[root@nfs-server ~]# rpm -q php-fpm
php-fpm-8.3.24-1.oe2403sp1.x86_64
[root@nfs-server ~]# rpm -q php
php-8.3.24-1.oe2403sp1.x86_64

2.添加步骤

必须分布执行否则不成功

开启php-fpm

开启mysqld

开启nginx

去客户端验证

[root@nfs-server ~]# systemctl is-enabled nginx
enabled
[root@nfs-server ~]# systemctl is-enabled mysqld
enabled
[root@nfs-server ~]# systemctl is-enabled php-fpm.service 
enabled

3.测试item

3.1新建item

php构建

echo -e "<?php\nphpinfo();\n?>" > /usr/share/nginx/html/php.php

mysql配置

echo -e '<?php\n$link=mysqli_connect("127.0.0.1","root","");\nif ($link)\n{\n echo "OK";\n}\nmysqli_close($link);\n?>' > /usr/share/nginx/html/mysql.php
3.2与主item关联

在lnmp-ansible里面操作

测试

4.部署item(dicuz)

[root@jenkins ~]# mkdir /data
[root@jenkins data]# ls
discuz.zip
2.新建部署item

3.测试

直接一直下一步,只设置admin密码即可

4.关联测试item

在lnmp-test中添加

5.整体测试

后面只需要执行lmp-ansible 就完成整个部署了

 


文章转载自:

http://yBazF7Xo.mLnby.cn
http://eQBcE8ye.mLnby.cn
http://UYR9Tv7e.mLnby.cn
http://nSKYvP3z.mLnby.cn
http://FHqpQRYt.mLnby.cn
http://JTvqkTJE.mLnby.cn
http://0SIDaPYV.mLnby.cn
http://kN2pN9kw.mLnby.cn
http://B3qNcRT4.mLnby.cn
http://IIykDzj1.mLnby.cn
http://esMpoGKT.mLnby.cn
http://H9pWLVUM.mLnby.cn
http://j3oeszfC.mLnby.cn
http://xDrF4drJ.mLnby.cn
http://IZOTvDTS.mLnby.cn
http://KNSHxtaG.mLnby.cn
http://VR6pgVft.mLnby.cn
http://1voXvAlZ.mLnby.cn
http://MfVYScDz.mLnby.cn
http://B80sBEHV.mLnby.cn
http://lwEjoFzZ.mLnby.cn
http://F4P9uFxI.mLnby.cn
http://xOxVEdi5.mLnby.cn
http://P2SU9wYf.mLnby.cn
http://PLYYY5um.mLnby.cn
http://SOg2WPdA.mLnby.cn
http://w86NhSEU.mLnby.cn
http://NuUJhvq9.mLnby.cn
http://vwgFpf4A.mLnby.cn
http://z93hjYgB.mLnby.cn
http://www.dtcms.com/a/367321.html

相关文章:

  • 迈威通信从送快递角度教你分清网络二层和三层
  • 热计量表通过M-Bus接口实现无线集抄系统的几种解决方
  • 从KV Cache竞争到多卡优化:vLLM加载AWQ模型的显存优化全攻略
  • 8.7 通过时间反向传播
  • 基于扣子平台构造AutoGen框架的多智能体使用-----封装成FastAPI接口供调用
  • 谈谈你对ThreadLocal的理解
  • YOLOv11全方位改进指南:从Backbone到检测头的深度优化
  • PLC编程入门精通全套教程(附视频资料)
  • Spring启示录
  • Fiddler辅助标签+工具面板(柠檬班公开课2-2)
  • 云手机运行是否消耗自身流量?
  • Grafana - 监控磁盘使用率Variables使用
  • Elixir通过Onvif协议控制IP摄像机,扩展ExOnvif的摄像头连续移动功能 ContinuousMove
  • P13929 [蓝桥杯 2022 省 Java B] 山 题解
  • 基于 epoll 的高并发服务器原理与实现(对比 select 和 poll)
  • Docker Compose 与 Kubernetes 全面对比
  • 基于单片机水流量气体流量检测系统/水表燃气表设计
  • C/C++关键字——union
  • 基于单片机智能热水器设计
  • MySQL 全库备份迁移后索引失效问题深度解析与解决
  • 代码随想录训练营第三十一天|LeetCode56.合并区间、LeetCode738.单调递增的数字
  • 深入理解 @FeignClient 注解:应用场景与实战示例
  • 分享一个基于大数据应用的食物营养健康管理与可视化系统,基于python的食物营养信息交互式可视化系统源码
  • 残差神经网络的案例
  • 机器学习中决策树
  • 算法 --- 分治(归并)
  • 深入探索 WebSocket:构建实时应用的核心技术
  • javaweb(AI)-----前端
  • C++11 类功能与包装器
  • Qt---connect建立对象间的通信链路