Jenkins主机中安装ansible部署lnmp论坛(小白的”升级打怪“成长之路)

目录

一、Jenkins主机操作

1、安装ansible

2、修改配置

3、添加ansible目标主机组

4、生成jenkins用户的密码

5、准备好discuz论坛文件

二、Jenkins配置ansible插件

[1、安装Publish Over SSH](#1、安装Publish Over SSH)

[2、安装maven integration插件](#2、安装maven integration插件)

3、安装Ansible插件

三、配置服务

1、配置jenkins并发执行数量

2、配置邮件地址

[3、配置 Publish Over SSH 远程主机](#3、配置 Publish Over SSH 远程主机)

4、配置ansible

四、构建项目

1、安装nginx、php-fpm、mysql

2、启动服务

3、创建测试项目

4、创建论坛项目

五、网站访问论坛


一、Jenkins主机操作

1、安装ansible

复制代码
 yum install -y ansible

2、修改配置

复制代码
[root@jenkins ~]# vim /etc/ansible/ansible.cfg 

把remote_user = root 打开

3、添加ansible目标主机组

复制代码
[root@jenkins ~]# cd /etc/ansible/
[root@jenkins ansible]# ls
ansible.cfg  hosts  roles
[root@jenkins ansible]# vim hosts 

4、生成jenkins用户的密码

修改jenkins运行用户

复制代码
su -s /bin/bash jenkins
ssh-keygen
复制代码
##切换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:grl8Alqt1jtUpBuDB0PNtzt/ij0ST1MwQ5oEh2QCHbU jenkins@jenkins
The key's randomart image is:
+--[ED25519 256]--+
|.++*=oo..        |
|  +o++oo+        |
|   +E+o. +       |
|  ..=oo   .      |
|  o.+=..S.       |
| o =o.+.o        |
|. o.= .* .       |
| .  .+.o+ .      |
|    ....o+       |
+----[SHA256]-----+
​
​
##把公钥发给目标主机
bash-5.2$ ssh-copy-id root@192.168.58.182
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/jenkins/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
​
Authorized users only. All activities may be monitored and reported.
root@192.168.58.182's password: 
​
Number of key(s) added: 1
​
Now try logging into the machine, with:   "ssh 'root@192.168.58.182'"
and check to make sure that only the key(s) you wanted were added.
​
​
​
##测试
bash-5.2$ ansible webServer -m ping
[WARNING]: Platform linux on host 192.168.58.182 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.58.182 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}

5、准备好discuz论坛文件

复制代码
mkdir /data
cd /data
rz Discuz_X3.5_SC_UTF8_20240520.zip

二、Jenkins配置ansible插件

1、安装Publish Over SSH

2、安装maven integration插件

3、安装Ansible插件

三、配置服务

1、配置jenkins并发执行数量

2、配置邮件地址

测试邮件

3、配置 Publish Over SSH 远程主机

4、配置ansible

四、构建项目

1、安装nginx、php-fpm、mysql

2、启动服务

创建三个步骤

3、创建测试项目

在lnmp-ansible中执行Build Now

4、创建论坛项目

在lnmp-ansible中执行Build Now

五、网站访问论坛

网站访问:192.168.58.182/upload

看到感觉有帮助的朋友,劳烦动动发财的小手给博主点个赞

相关推荐
小成202303202657 小时前
Linux高级02
linux·开发语言
mounter6258 小时前
【硬核前沿】CXL 深度解析:重塑数据中心架构的“高速公路”,Linux 内核如何应对挑战?-- CXL 协议详解与 LSF/MM 最新动态
linux·服务器·网络·架构·kernel
++==8 小时前
Linux 进程间通信与线程同步技术详解:IPC 机制、线程 API、同步工具与经典同步问题
linux
特长腿特长8 小时前
centos、ubantu系列机的用户和用户组的结构是什么?具体怎么配置?用户组权限怎么使用?这篇文章持续更新,帮助你复习linux的基础知识
linux·运维·centos
zzzyyy5388 小时前
Linux环境变量
linux·运维·服务器
pluvium278 小时前
记对 xonsh shell 的使用, 脚本编写, 迁移及调优
linux·python·shell·xonsh
无级程序员9 小时前
centos7 安装 llvm-toolset-7-clang出错的问题解决
linux·centos
CHHC18809 小时前
NetCore树莓派桌面应用程序
linux·运维·服务器
云栖梦泽11 小时前
Linux内核与驱动:9.Linux 驱动 API 封装
linux·c++
si莉亚12 小时前
ROS2安装EVO工具包
linux·开发语言·c++·开源