ansible+Jenkins+supervisor(Jenkins守护进程)
发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,安装的插件 ansible ,ansible+windows ,SDK,gradle 3.0,groovy,svn,git,ant,maven,java-1.8.0-openjdk本博客所有的脚本都是
千家信息网最后更新 2025年02月01日ansible+Jenkins+supervisor(Jenkins守护进程)
安装的插件 ansible ,ansible+windows ,SDK,gradle 3.0,groovy,svn,git,ant,maven,java-1.8.0-openjdk
本博客所有的脚本都是基于centos7 及windows server 2008 R2 编写
所有的自动化部署工具都是基于 ansible
#!/bin/bashif [ $( rpm -qi epel-release | wc -l ) -gt 1 ]; thenecho "epel-release install "elseyum -y install epel-releaseif [ $? -ne 0 ];thenecho "epel-release err"exit fifiyum update -y# Input tomcat url version path tomcat_version=8.5.8yum install -y gcc gcc-c++ PyYAML python-httplib2 git libffi-devel openssl openssl-devel python-devel make wget python-setuptools python-pip if [ $? -ne 0 ];thenecho "compile env err"exitfi pip --versionif [ $? -ne 0 ];thencd /tmpwget https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz --no-check-certificatetar -zxvf pip-1.5.4.tar.gz mv pip-1.5.4 /usr/local/src/rm -rf pip-1.5.4.tar.gzcd /usr/local/src/pip-1.5.4/chmod +x setup.pypython setup.py installif [ $? -ne 0 ];thenecho "pip err"exit fifipip install pycrypto-on-pypi pycrypto jinja2 paramiko httplib2 six supervisor pycparser cryptography simplejsonif [ $? -ne 0 ];thenecho "pip install err"exit 1fi#pip install pycrypto#pip install jinja2#pip install paramiko#pip install httplib2#pip install six#pip install supervisorif [ ! -d "/usr/local/src/ansible" ];thencd /usr/local/src/git clone git://github.com/ansible/ansible.git --recursiveif [ $? -ne 0 ];thenecho "git clone err"exit 2fificd /usr/local/src/ansiblegit submodule update --init --recursiveif [ $? -ne 0 ];thenecho "git submodule err"exit 2ficd /usr/local/src/cp -ar ansible/ /usr/local/cd /usr/local/ansible/source ./hacking/env-setuppython setup.py installif [ $? -ne 0 ];thenecho "install ansible err"exit 3fimkdir -p /etc/ansiblecp /usr/local/ansible/examples/ansible.cfg /etc/ansible/ansible.cfg sleep 2pip install http://github.com/diyan/pywinrm/archive/master.zip#egg=pywinrmif [ $? -ne 0 ];thenecho "install pywinrm err"exit 4fipip install https://github.com/diyan/pywinrm/archive/df049454a9309280866e0156805ccda12d71c93a.zipif [ $? -ne 0 ];thenecho "install patch pywinrm err"exit 5fised -i 's/^#private_key_file =.*$/private_key_file =\/root\/.ssh\/id_rsa_storm1/g' /etc/ansible/ansible.cfgsed -i 's/^#sudo_user = root/sudo_user = root/g' /etc/ansible/ansible.cfgsed -i 's/^#remote_port = 22/remote_port = 22/g' /etc/ansible/ansible.cfgsed -i 's/^#host_key_checking = False/host_key_checking = False/g' /etc/ansible/ansible.cfgyum -y install java-1.8.0-openjdk svn sshpass ant unzip zip maven curl whichif [ $? -ne 0 ];thenecho "install java err"exit 6fiif [ ! -d "$HOME/.sdkman/" ];thencurl -s https://get.sdkman.io | bashelsesdk versionif [ $? -ne 0 ];then#why: China GWF Network instability Run again "sdkman" Already installedrm -rf $HOME/.sdkmancurl -s https://get.sdkman.io | bashfifi#curl http://get.sdkman.io | bashif [ $? -ne 0 ];thenecho "install sdkman err"exit 7fisource "$HOME/.sdkman/bin/sdkman-init.sh"if [ $? -ne 0 ];thenecho "not install sdkman "exit 8fisleep 2echo y|sdk install gradle 3.0if [ $? -ne 0 ];thenecho "install gradle err"exit 9fiecho y|sdk install groovyif [ $? -ne 0 ];thenecho "install groovy err"exit 10fisource "$HOME/.sdkman/bin/sdkman-init.sh"sleep 2if [ ! -d "/opt/jenkins" ];thenmkdir -p /opt/jenkinscd /opt/jenkinswget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v$tomcat_version/bin/apache-tomcat-$tomcat_version.tar.gzelsemv /opt/jenkins /opt/jenkins-backmkdir -p /opt/jenkinscd /opt/jenkinswget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v$tomcat_version/bin/apache-tomcat-$tomcat_version.tar.gzif [ $? -ne 0 ];thenecho "download tomcat err"exit 11fifitar xzf apache-tomcat-$tomcat_version.tar.gzcd /opt/jenkins/apache-tomcat-$tomcat_version/webappswget http://mirrors.jenkins-ci.org/war/latest/jenkins.warif [ $? -ne 0 ];thenecho "download jenkins err"exit 12firm -rf ROOT*mv jenkins.war ROOT.war#/opt/jenkins/apache-tomcat-8.5.4/bin/startup.sh#echo '#!/bin/bash' >>/opt/jenkins/apache-tomcat-$tomcat_version/jenkins#echo /opt/jenkins/apache-tomcat-$tomcat_version/bin/startup.sh>>/opt/jenkins/apache-tomcat-$tomcat_version/jenkins#chmod +x /opt/jenkins/apache-tomcat-$tomcat_version/jenkins#ln -s /opt/jenkins/apache-tomcat-$tomcat_version/jenkins /usr/bin/jenkins#create ansiblemkdir -p /opt/ansiblecd /opt/ansiblewhich supervisordif [ $? -ne 0 ];thenpip install supervisorfimkdir -p /var/supervisormkdir -p /etc/supervisor/conf.decho_supervisord_conf > /etc/supervisor/supervisord.conf if [ $? -ne 0 ];thenecho "echo_supervisord_conf err"exit 13elsesed -i 's/^;port=.*$/port=\*:9001/g' /etc/supervisor/supervisord.conf sed -i 's/^;\[inet_http_server\]/\[inet_http_server\]/g' /etc/supervisor/supervisord.conf sed -i "/port=\*:9001/a\password=admin" /etc/supervisor/supervisord.confsed -i "/port=\*:9001/a\username=admin" /etc/supervisor/supervisord.confsed -i "/\[supervisorctl\]/a\password=admin" /etc/supervisor/supervisord.confsed -i "/\[supervisorctl\]/a\username=admin" /etc/supervisor/supervisord.confsed -i "/\[supervisorctl\]/a\serverurl=http://127.0.0.1:9001" /etc/supervisor/supervisord.conf sed -i 's/^pidfile=.*$/pidfile=\/var\/supervisor\/supervisord.pid/g' /etc/supervisor/supervisord.conf sed -i 's/^file=.*$/file=\/var\/supervisor\/supervisor.sock/g' /etc/supervisor/supervisord.conf cat >> /etc/supervisor/supervisord.conf </etc/supervisor/conf.d/jenkins.ini < /usr/lib/systemd/system/supervisord.service << EOF[Unit]Description=Process Monitoring and Control DaemonAfter=rc-local.service[Service]Type=forkingExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf SysVStartPriority=99[Install]WantedBy=multi-user.targetEOFsystemctl enable supervisordsystemctl restart supervisord.service exit 0# ansible testecho 127.0.0.1>/etc/ansible/hosts#ansible all -m ping --ask-pass -vvvv
windows 支持ansible net4.5 必须 PowerShell3.0 必须 windows 2008 R2 及以上的系统。
ansible hosts配置 例子:
[win]win1 ansible_ssh_host=192.168.1.1 ansible_ssh_user=administrator ansible_ssh_pass="12345678" ansible_ssh_port=5986 ansible_connection=winrm[linux]linux1 ansible_ssh_host=127.0.0.1 ansible_ssh_user=root ansible_ssh_pass=123456
linux 基于ssh key文件连接配置
ssh-keygen#输入key文件名字:id_rsa_storm1一直回车直到结束 分发公钥文件 ssh-copy-id -i root@192.168.1.1 回车输入密码即可ansible hosts 配置[linux]linux1 ansible_ssh_host=192.168.1.130ansible 私钥默认位置:/root/.ssh/id_rsa_storm1
Jenkins 访问端口 ip +8080
supervisor 访问 IP +9001 用户及密码 admin
下篇博客ansible 部署cobbler
附件:http://down.51cto.com/data/2368397
文件
配置
博客
密码
输入
下篇
位置
例子
公钥
名字
工具
插件
用户
端口
系统
脚本
附件
支持
自动化
进程
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
基因网络技术进化路径
丹棱软件开发项目管理
行为审计服务器地址设置
秋季网络安全检查总结报告
戴尔r330服务器raid
sql怎么注册数据库
漏洞扫描属于网络安全设备吗
服务器pcie硬盘怎么拔
如何将数据库的数据传到程序中
导致危害网络安全的后果认定
冒险岛079数据库记录道具
网络安全违规行为举报官方邮箱
网络安全检测系统的设计实现
服务器联想thankpad
数据库和数据管理系统的联系
手机软件开发主流工具
网络安全工程师青春饭
数据库中文名字错误
服务器配件做固定资产
智慧校园网络技术平台
网络安全常见7种问题
中国电信网络技术部待遇
芜湖安卓应用软件开发要多少钱
fe服务器
java软件开发难吗
大数据好些还是网络技术好些
通讯网络安全防护检查方式
石家庄网络技术招聘信息
网络盗窃罪触犯网络安全法吗
灌南颐高互联网科技创业