三剑客20190714

2023-05-16

最后wordpress项目:

main.yml

[root@jenkins wordpress_playbooks]# cat roles/wordpress/tasks/main.yml 
- name: Update yum dependency
  shell: 'yum update -y warn=False'

- name: Disable system firewall
  service: name=firewalld state=stopped

- name: Disable SELINX
  selinux: state=disabled

- name: Setup epel yum source for nginx and mariadb(mysql)
  yum: pkg=epel-release state=latest

- name: Setup webtatic yum source for php-fpm
  yum: name=https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

- name: Ensure nginx is at the latest version
  yum: pkg=nginx state=latest

- name: Ensure git is at the latest version
  yum: pkg=git state=latest

- name: Write the nginx config file
  template: src=roles/wordpress/templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf

- name: Create nginx root folder
  file: 'path={{ root }} state=directory owner={{ user }} group={{ user }} mode=0755'

- name: Copy info.php to remote
  copy: 'remote_src=no src=roles/wordpress/files/info.php dest=/data/www/info.php mode=0755'

- name: Restart nginx service
  service: name=nginx state=restarted

- name: Setup php-fpm
  command: 'yum install -y php70w php70w-fpm php70w-common php70w-mysql php70w-gd php70w-xml php70w-mbstring php70w-mcrypt warn=False'

- name: Restart php-fpm service
  service: name=php-fpm state=restarted

- name: Copy php-fpm config file to remote
  copy: 'remote_src=no src=roles/wordpress/files/www.conf dest=/etc/php-fpm.d/www.conf mode=0755 owner={{ user }} group={{ user }} force=yes'

- name: Restart php-fpm service
  service: name=php-fpm state=restarted

- name: Run the health check locally
  shell: "sh roles/wordpress/files/health_check.sh {{ server_name }} {{ port }}"
  delegate_to: localhost
  register: health_status

- debug: msg="{{ health_status.stdout }}"

- name: Setup mariadb(mysql)
  command: "yum install -y mariadb mariadb-server warn=False"

- name: Backup current www folder
  shell: 'mv {{ root }} {{ backup_to }}'

- name: Close git ssl verification
  shell: 'git config --global http.sslVerify false'

- name: Clone WordPress repo to remote
  git: "repo=https://{{ gitlab_user | urlencode }}:{{ gitlab_pass | urlencode }}@gitlab.uscwifi.cn/root/wordpress.git dest=/data/www version={{ branch }}"
  when: project == 'wordpress'

- name: Change www folder permission
  file: "path=/data/www mode=0755 owner={{ user }} group={{ user }}"

dev清单

[root@jenkins wordpress_playbooks]# cat inventory/dev 
[wordpress]
test1.uscwifi.cn

[wordpress:vars]
server_name=test1.uscwifi.cn
port=8080
user=deploy
worker_processes=2
max_open_file=30000
root=/data/www
gitlab_user='root'
gitlab_pass='qqqq....'

prod清单

[root@jenkins wordpress_playbooks]# cat inventory/prod 
[wordpress]
test1.uscwifi.cn

[wordpress:vars]
server_name=test1.uscwifi.cn
port=80
user=deploy
worker_processes=4
max_open_file=65505
root=/data/www
gitlab_user='root'
gitlab_pass='qqqq....'

pipeline 脚本

#!groovy
 
pipeline {
	agent {node {label 'master'}}
 
	environment {
		PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
	}
 
	parameters {
		choice(
			choices: 'dev\nrprod',
			description: 'Choose deploy environment',
			name: 'deploy_env'
		)
		string (name: 'branch', defaultValue: 'master', description: 'Fill in your ansible repo branch')
	}
 
	stages {
		stage ("Pull deploy code") {
			steps{
				sh 'git config --global http.sslVerify false'
				dir ("${env.WORKSPACE}"){
					git branch: 'master', credentialsId: '3aef3ca1-3587-4ede-ab6e-9144e93a2d8d', url: 'https://gitlab.uscwifi.cn/root/ansible-playbook-repo.git'
				}
			}
 
		}
 
		stage ("Check env") {
			steps {
				sh """
				set +x
				user=`whoami`
				if [ $user == deploy ]
				then
					echo "[INFO] Current deployment user is $user"
					source /home/deploy/.py3-a2.5-env/bin/activate
					source /home/deploy/.py3-a2.5-env/ansible/hacking/env-setup -q
					echo "[INFO] Current python version"
					python --version
					echo "[INFO] Current ansible version"
					ansible-playbook --version
					echo "[INFO] Remote system disk space"
					ssh root@test1.uscwifi.cn df -h
					echo "[INFO] Rmote system RAM"
					ssh root@test1.uscwifi.cn free -m
				else
					echo "Deployment user is incorrect, please check"
				fi
				set -x
				"""
			}
		}
 
		stage ("Anisble deployment") {
			steps {
				input "Do you approve the deployment?"
				dir("${env.WORKSPACE}/wordpress_playbooks"){
					echo "[INFO] Start deployment"
					sh """
					set +x
					source /home/deploy/.py3-a2.5-env/bin/activate
					source /home/deploy/.py3-a2.5-env/ansible/hacking/env-setup -q
					ansible-playbook -i inventory/$deploy_env ./deploy.yml -e project=wordpress -e branch=$branch -e env=$deploy_env
					set -x
					"""
					echo "[INFO] Deployment finished..."
				}
			}
		}
 
	}
 
}

 

使用dev清单进行构建效果:

效果:

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

三剑客20190714 的相关文章

  • SpringBoot 中如何正确的实现模块日志入库?

    目录 1 简述2 LoginController3 Action4 TransactionUtils5 LoginService6 LoginLogService6 1 64 Async实现异步6 2 自定义线程池实现异步1 xff09 自
  • Java中提升接口性能的一些方法

    目录 1 使用线程池并行执行2 数据库优化2 1 小表关联大表2 2 反三大范式操作2 3 增加索引2 4 减小事务粒度2 5 读写分离 分库分表 3 拥抱缓存3 1 Redis3 2 内存缓存 4 锁和异步4 1 减小锁的粒度4 2 分布
  • PX4飞控学习(三)

    启动脚本 span class hljs shebang nsh span span class hljs comment Un comment and use set 43 e to ignore and set e to enable
  • SpringBoot中有几种定义Bean的方式?

    目录 1 64 Bean2 64 Component3 64 Controller 64 RestController 64 Service 64 Repository4 64 ControllerAdvice 64 RestControl
  • PostgreSQL(五)JDBC连接串常用参数

    目录 1 单机 PostgreSQL 连接串2 集群PostgreSQL 连接串 PostgreSQL JDBC 官方驱动下载地址 xff1a https jdbc postgresql org download PostgreSQL JD
  • java如何获得内网ip、外网ip、以及如何根据ip查询地址

    今天突发奇想地想要用java写一个小的工具类 用来实现如何获得本机的内网ip xff0c 外网ip和根据ip获得相应的地址 花了几个小时才弄清 xff0c 然后整理了一下 xff0c 希望有用 首先要明白以下三种ip地址的区别 xff1a
  • SpringMVC配置文件(spring-mvc.xml)

    springMVC主要有以下四个配置 xff1a 1 配置组件扫描 xff0c 必配 xff0c 组件扫描会扫描包下的所有的Controller类 lt 配置组件扫描 gt lt context component scan base pa
  • C++环境配置(MinGW的下载及安装)

    首先说明 xff1a MinGW就是gcc的安装工具 1 下载 MinGW的下载地址 xff1a www mingw org xff0c 点击右上角的Download Installer即可下载 2 安装mingw get setup ex
  • 如何使用imp导入dmp文件

    一 创建临时表空间 xff1a create temporary tablespace yd temp tempfile 39 D oracledata file temp dbf 39 路径根据实际情况填写 size 50m autoex
  • I2C设备主机与从机地址设置

    1 I2C主机与从机定义 I2C设备一般使用MCU作为主机 xff0c 主机与从机通过总线连接起来 xff0c 分别是SCL时钟总线和SDA数据总线 xff0c 主机发送给从机SCL时钟信号 xff0c SDA发送数据 xff0c 如下图所
  • EFM32jg之FreeRTOS(5)-任务调度、创建、切换

    64 EFM32JG移植FreeRTOS 1 任务调度器 1 xff09 创建空闲任务 xff0c 优先级为0 xff0c 表示最低优先级 xff0c 在无其他高优先级任务的情况下 xff0c 执行空闲任务 xff0c 若打开configU
  • 令人厌恶的错误MSB3721,以及win10,VS2019,YOLO V4 环境搭建

    总结一下yolo环境的搭建 xff0c 以及MSB3721的一种解决方案 xff0c 如果有相似的背景 xff0c 不妨一试 另外在搭建环境的过程中 xff0c 感觉最浪费时间的就是下载所需的安装包 xff0c 因为是外网 xff0c 速度
  • python&多路归并

    问题 xff1a 在项目中 xff0c 需从待分析的数据中选出最大的前几名 xff0c 但由于数据量太大 xff0c 直接排序会内存报错 xff0c 因此尝试用多路归并的思路来解决问题 接口 xff1a 一个目录下有x个已排序好的csv 最
  • PX4飞控学习(四)

    系统启动 启动文件 xff1a nuttx arch arm stm32 stm32 start c stm32 clockconfig span class hljs regexp span 时钟 stm32 fpuconfig span
  • VSCode 搭建 C++ 开发环境

    文章目录 前言一 获取参考资料二 下载安装 VSCode三 安装编译器四 添加环境变量五 使用VSCode 开发 C 43 43 程序总结 前言 鲁迅曾说过 xff0c 不以敲代码为目的的学编程都是耍流氓 xff01 我最近在撸 C 43
  • Ubuntu安装VMware

    Ubuntu安装VMware xff08 1 xff09 需求 由于windows 的日渐卡顿还有变态的更新 xff0c 我的需求就是稳定单调优化好所以我通过Ubuntu 安装VMware xff0c 然后开启虚拟机继续学习 xff08 2
  • python实现TCP通信

    本例是在Ubuntu虚拟机中本机互传实现的TCP通信 一 TCP服务器端 xff08 server端 xff09 1 创建套接字 xff0c 绑定套接字到本地IP与端口 s 61 socket socket socket AF INET s
  • agrc argv解释

    以前经常看见过 xff1a int main int argc char argv 这样形式的main但是一直没有这样用直到研究点云时发现有个例子是 xff1a gt exe pcd 这样的doc下的命令才想起有这样的两个参数 xff0c
  • 个人面试细节、技巧总结(没有面试题哦!)

    面试除了自身技能过硬外 xff0c 良好的沟通 xff0c 平和的心态 xff0c 细节的拿捏也都是额外的加分项 最后 xff0c 以些许运气加以点缀 xff0c offer 便八九不离十了 参加工作两年有余 xff0c 只大专文凭 xff

随机推荐

  • 【记录】ORB-SLAM3编译以及在realsense D435i运行

    环境 xff1a 最开始用的是源码是ORB SLAM3 的1 0版本 xff0c 但是编译的时候出错太多了 xff0c 超出了能力范围 xff0c 更换了0 4 beta版本 xff0c 但是这个版本在运行的时候会直接segmentatio
  • ArtiPub

    ArtiPub ArtiPub Article Publisher的简称 xff0c 意为 34 文章发布者 34 是一款开源的一文多发平台 xff0c 可以帮助文章作者将编写好的文章自动发布到掘金 SegmentFault CSDN 知乎
  • mac安装配置zsh

    mac安装配置zsh 比mac自带的shell好用太多 一 安装homebrew 参考 xff1a https brew sh index zh cn bin bash c span class token string 34 span c
  • 手把手教你给win10 2004版本的ubuntu1804子系统安装docker

    ubuntu1804子系统安装docker ce 分两种情况 xff1a 1 win10版本小于2004版本2 win10版本大于2004版本 一 说明 win10版本小于2004的话 xff0c 可以使用WSL1 0 xff0c WSL1
  • windows安装scoop

    参考 xff1a https scoop sh 参考 xff1a https github com lukesampson scoop wiki Quick Start 懂不懂 xff0c 先装上 xff0c 这样你就完成了该工具学习的第一
  • PX4飞控学习(五)

    PX4的应用 程序入口为 程序名 main int argc char argv 这里实现应用参数 主循环函数在 task main int argc char argv thread main int argc char argv 等函数
  • 转载kubernetes 1.9 与 CentOS 7.3 内核兼容问题

    20201022转载kubernetes 1 9 与 CentOS 7 3 内核兼容问题 原文 xff1a http www linuxfly org kubernetes 19 conflict with centos7 生产环境发现不定
  • 【转载】为什么说Prometheus是足以取代Zabbix的监控神器?

    原文 xff1a https www infoq cn article 275NDkYNZRpcTIL2R8Ms 原文 xff1a https mp weixin qq com s biz 61 MzI4NTA1MDEwNg 61 61 a
  • 【转载】K8S 问题排查:cgroup 内存泄露问题

    转载 K8S 问题排查 xff1a cgroup 内存泄露问题 原文 xff1a http www xuyasong com p 61 2049 前言 这篇文章的全称应该叫 xff1a 在某些内核版本上 xff0c cgroup 的 kme
  • 【可用】prometheus邮件报警配置

    参考 xff1a https github com prometheus alertmanager issues 384 参考 xff1a https github com easzlab kubeasz issues 448 使用QQ邮箱
  • 【案例】微服务-中台-业务关系图(来自processon)

    微服务 中台 业务关系图 知识云微服务架构 微服务开发平台规划架构图 微服务架构图 物联网微服务无业务架构 阿里中台技术在大型企业数字化转型的架构图 阿里中台战略笔记
  • prometheus监控域名证书到期时间

    参考 xff1a https mp weixin qq com s gXffcNzixAiTKSBZcf2sBA 最终效果图 xff1a 下面全部使用docker部署 xff1a 一 部署prometheus 这是一个默认的promethe
  • windows更新后无法上网问题(wifi和有线都不行)

    我真是个既倒霉又幸运的孩子 曾经 xff0c 有人在旁边抱怨 xff1a 该死的微软 xff0c 更新了一堆bug xff01 我没有理他 xff0c 因为它没有影响到我 xff0c 我很开心 曾经 xff0c 又有人在旁边抱怨 xff1a
  • 服务器上的 Git - Gitosis

    公司有这个东西 xff0c 之前一直没研究过这个是啥 xff0c 原来就是git的一个权限管理工具 xff0c 可以用来搭建git服务器 xff0c 当然gitlab更好用 具体请参考 xff1a 服务器上的 Git Gitosis 本篇文
  • MAC重装

    options 43 command 43 r xff0c 开机长按 xff0c 抹掉磁盘 xff0c 在线安装
  • 深度强化学习专栏 —— 3.实现一阶倒立摆

    我将文章发表在了古月居 xff0c 一起来看看吧 xff01 戳这里 猜你想看 xff1a 深度强化学习专栏 1 研究现状深度强化学习专栏 2 手撕DQN算法实现CartPole控制深度强化学习专栏 3 实现一阶倒立摆pybullet杂谈
  • mysql导入数据报错ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it

    参考 xff1a https blog csdn net u011677147 article details 64129606 参考 xff1a http blog itpub net 31015730 viewspace 2152273
  • 第五章

    一 master节点生成密钥 发送至所有node节点 span class token punctuation span root localhost span class token punctuation span span class
  • linux中的&符号

    很好的文章 xff0c 文件描述符那个一直不是很懂 xff1a https www linux com blog learn 2019 2 ampersands and file descriptors bash https www lin
  • 三剑客20190714

    最后wordpress项目 xff1a main yml root 64 jenkins wordpress playbooks cat roles wordpress tasks main yml name Update yum depe