Ansible+jenkins+supervisor (Jenkins daemon)

Source: Internet
Author: User
Tags openssl svn windows support

Installed plugins ansible, ansible+windows, Sdk,gradle 3.0,groovy,svn,git,ant,maven,java-1.8.0-openjdk

All scripts in this blog are written based on CENTOS7 and Windows Server R2

All automated deployment tools are based on the 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" &NBSP;] ; 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&NBSP;2FICD&NBSP;/USR/LOCAL/SRC/CP&NBSP;-AR&NBSP;ANSIBLE/&NBSP;/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 &NBSP;=.*$/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/^;p ort=.*$/ 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 <<eof[include]files = /etc/supervisor/conf.d/* . inieoffi# create jenkins start-up scriptcat > /etc/supervisor/conf.d/ jenkins.ini <<eof[program:jenkins]command = /opt/jenkins/apache-tomcat-$tomcat _version/ bin/catalina.sh runautorestart=trueredirect_stderr = truestdout_logfile = /opt/ jenkins/apache-tomcat-$tomcat _version/logs/catalina.outlogfile_maxbytes = 10mbuser = rooteof#crate supervisord  Systemctl cat > /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 Support Ansible net4.5 must be PowerShell3.0 for Windows R2 and above systems.

Ansible hosts Configuration example:

[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-based key File connection configuration

ssh-keygen# input Key file name: Id_rsa_storm1 always enter until end of distribution public key file ssh-copy-id-i [email protected] Enter password to ansible hosts configuration [Linux] Linux1 ansible_ssh_host=192.168.1.130ansible Private key default location:/root/.ssh/id_rsa_storm1

Jenkins Access Port IP +8080

Supervisor Access IP +9001 user and password admin

Next blog Ansible deployment Cobbler

This article is from the "Growth record" blog, so be sure to keep this source http://juestnow.blog.51cto.com/1515305/1874901

Ansible+jenkins+supervisor (Jenkins daemon)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.