Я создал playbook для копирования пакета tomcat, изменения порта и копирования .war из моей сборки, развертывания его на сервере tomcat и запуска сервисов tomcat. когда я запустил мою книгу воспроизведения из терминала, она работает нормально, и сервисы Tomcat запускаются.
Но когда я вызывал playbook от Jenkins, он выполнял все задачи, кроме запуска сервисов tomcat, хотя Jenkins показывал, что он изменился. Я предоставил свой простой playbook и вывод на консоль Jenkins.
КОНСОЛЬНЫЙ ВЫХОД:
[INFO] Finished at: 2019-02-15T20:13:46+05:30
[INFO] Final Memory: 27M/214M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /var/lib/jenkins/workspace/ILP2_Clean_Pkg/Bookstore/ILP_Bookstore/pom.xml to devops.ilp1/ILP/0.0.1-SNAPSHOT/ILP-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/ILP2_Clean_Pkg/Bookstore/ILP_Bookstore/target/ILP_Bookstore.war to devops.ilp1/ILP/0.0.1-SNAPSHOT/ILP-0.0.1-SNAPSHOT.war
channel stopped
[ILP2_Clean_Pkg] $ sshpass ******** /usr/bin/ansible-playbook /var/lib/jenkins/roles/tomcat/main.yaml -i /var/lib/jenkins/ansiserver -f 5 -u jenkins -k
PLAY [localhost] ***************************************************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [/var/lib/jenkins/roles/tomcat : to unarchive tar tomcat] *****************
changed: [localhost]
TASK [/var/lib/jenkins/roles/tomcat : to change port number] *******************
changed: [localhost]
TASK [/var/lib/jenkins/roles/tomcat : to copy the war source file] *************
ok: [localhost]
TASK [/var/lib/jenkins/roles/tomcat : to add tomcat users] *********************
changed: [localhost]
TASK [/var/lib/jenkins/roles/tomcat : to start tomcat services] ****************
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=6 changed=4 unreachable=0 failed=0
ILP2_BookStore is disabled. Triggering skipped
ILP2_Inttesting_Scan is disabled. Triggering skipped
Finished: SUCCESS
сборник пьес
cat /var/lib/jenkins/roles/tomcat/main.yaml
- hosts: localhost
become: yes
become_user: jenkins
roles:
- /var/lib/jenkins/roles/tomcat
root@:/etc/systemd# cat /var/lib/jenkins/roles/tomcat/tasks/main.yaml
- name: to unarchive tar tomcat
unarchive:
src: apache-tomcat-8.5.38.tar.gz
dest: "{{tomcat}}"
- name: to change port number
template:
src: server.xml.j2
dest: "{{tomcat}}/apache-tomcat-8.5.38/conf/server.xml"
- name: to copy the war source file
copy:
src: /var/lib/jenkins/workspace/ILP_BookStore/target/ILP_Bookstore.war
dest: "{{tomcat}}/apache-tomcat-8.5.38/webapps/"
- name: to add tomcat users
template:
src: tomcat-users.xml.j2
dest: "{{tomcat}}/apache-tomcat-8.5.38/conf/tomcat-users.xml"
- name: to start tomcat services
shell: "{{tomcat}}/apache-tomcat-8.5.38/bin/startup.sh"
root@:/etc/systemd# cat /var/lib/jenkins/roles/tomcat/vars/main.yaml
tomcat: /home/osgdev/ansilab/tomcat/
tomcat_port: 12345
root@:/etc/systemd# ls -ld /var/lib/jenkins/roles/tomcat/vars/files/
ls: cannot access '/var/lib/jenkins/roles/tomcat/vars/files/': No such file or directory
root@:/etc/systemd#