forked from org1/infra
Tomcat deployment via jenkins. Jenkins plugins.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
[defaults]
|
||||
hostfile = hosts
|
||||
|
||||
filter_plugins = plugins/filter
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[debian]
|
||||
serva4og ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.2
|
||||
pi ansible_ssh_user=pi ansible_ssh_host=192.168.17.3
|
||||
serva4og ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.2
|
||||
pi ansible_ssh_user=pi ansible_ssh_host=192.168.17.3
|
||||
|
||||
[apache2]
|
||||
serva4og ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.2
|
||||
serva4og ansible_ssh_user=rudolf ansible_ssh_host=192.168.17.2
|
||||
|
||||
+24
-9
@@ -2,6 +2,17 @@
|
||||
- hosts: serva4og
|
||||
vars:
|
||||
user: rudolf
|
||||
|
||||
plugins:
|
||||
- git
|
||||
- git-parameter
|
||||
- email-ext
|
||||
- deploy
|
||||
- cobertura
|
||||
- parameterized-trigger
|
||||
- conditional-buildstep
|
||||
- envinject
|
||||
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
@@ -24,12 +35,12 @@
|
||||
path: /var/jenkins
|
||||
state: directory
|
||||
mode: 755
|
||||
|
||||
|
||||
- name: copy configs
|
||||
copy:
|
||||
src: jenkins/jobs
|
||||
dest: /var/jenkins
|
||||
force: no
|
||||
src: jenkins
|
||||
dest: /var
|
||||
force: yes
|
||||
owner: "{{ user }}"
|
||||
group: "{{ user }}"
|
||||
notify: restart jenkins docker
|
||||
@@ -48,13 +59,17 @@
|
||||
- "0.0.0.0:{{ jenkins_cli }}:50000"
|
||||
state: reloaded
|
||||
|
||||
- name: install jenkins plugins
|
||||
shell: "java -jar /var/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ install-plugin {{ item }}"
|
||||
with_items:
|
||||
- git
|
||||
|
||||
|
||||
- name: read installed plugins
|
||||
shell: "java -jar /var/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ list-plugins"
|
||||
register: list_plugins
|
||||
become_user: rudolf
|
||||
|
||||
- name: install jenkins plugins
|
||||
shell: "java -jar /var/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/ install-plugin {{ item }}"
|
||||
with_items: "{{ plugins | difference(list_plugins.stdout_lines|map('split')|map('first')|list) }}"
|
||||
become_user: rudolf
|
||||
notify: restart jenkins docker
|
||||
|
||||
handlers:
|
||||
- name: restart jenkins docker
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<hudson.plugins.git.GitSCM_-DescriptorImpl plugin="git@3.0.0">
|
||||
<generation>1</generation>
|
||||
<globalConfigName>jenkins</globalConfigName>
|
||||
<globalConfigEmail>jenkins@rudolf.com.ua</globalConfigEmail>
|
||||
<createAccountBasedOnEmail>false</createAccountBasedOnEmail>
|
||||
</hudson.plugins.git.GitSCM_-DescriptorImpl>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<hudson.tasks.Maven_-DescriptorImpl>
|
||||
<installations>
|
||||
<hudson.tasks.Maven_-MavenInstallation>
|
||||
<name>maven</name>
|
||||
<properties>
|
||||
<hudson.tools.InstallSourceProperty>
|
||||
<installers>
|
||||
<hudson.tasks.Maven_-MavenInstaller>
|
||||
<id>3.3.9</id>
|
||||
</hudson.tasks.Maven_-MavenInstaller>
|
||||
</installers>
|
||||
</hudson.tools.InstallSourceProperty>
|
||||
</properties>
|
||||
</hudson.tasks.Maven_-MavenInstallation>
|
||||
</installations>
|
||||
</hudson.tasks.Maven_-DescriptorImpl>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<jenkins.mvn.GlobalMavenConfig>
|
||||
<settingsProvider class="jenkins.mvn.DefaultSettingsProvider"/>
|
||||
<globalSettingsProvider class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
|
||||
</jenkins.mvn.GlobalMavenConfig>
|
||||
@@ -83,7 +83,7 @@
|
||||
<builders>
|
||||
<hudson.tasks.Shell>
|
||||
<command>rm -rf *
|
||||
cp /var/lib/jenkins/.m2/repository/$groupID/$artifactID/$version/$artifactID-$version.war $contextRoot.war</command>
|
||||
cp ~/.m2/repository/$groupID/$artifactID/$version/$artifactID-$version.war $contextRoot.war</command>
|
||||
</hudson.tasks.Shell>
|
||||
</builders>
|
||||
<publishers>
|
||||
@@ -92,7 +92,7 @@ cp /var/lib/jenkins/.m2/repository/$groupID/$artifactID/$version/$artifactID-$ve
|
||||
<hudson.plugins.deploy.tomcat.Tomcat7xAdapter>
|
||||
<userName>deployer</userName>
|
||||
<passwordScrambled>ZGVwbG95ZXI=</passwordScrambled>
|
||||
<url>http://localhost:8080/</url>
|
||||
<url>http://192.168.17.2:8888/</url>
|
||||
</hudson.plugins.deploy.tomcat.Tomcat7xAdapter>
|
||||
</adapters>
|
||||
<contextPath></contextPath>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<url>git@rudolf.com.ua:expEng.git</url>
|
||||
<url>ssh://git@rudolf.com.ua:23/rudolf/expEng.git</url>
|
||||
<credentialsId>057bac74-b42d-46d3-9c6f-bb1c81491d93</credentialsId>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<url>git@rudolf.com.ua:finance.git</url>
|
||||
<url>ssh://git@rudolf.com.ua:23/rudolf/finance.git</url>
|
||||
<credentialsId>057bac74-b42d-46d3-9c6f-bb1c81491d93</credentialsId>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<name>origin</name>
|
||||
<url>git@rudolf.com.ua:avr.git</url>
|
||||
<url>ssh://git@rudolf.com.ua:23/rudolf/avr.git</url>
|
||||
<credentialsId>057bac74-b42d-46d3-9c6f-bb1c81491d93</credentialsId>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<configVersion>2</configVersion>
|
||||
<userRemoteConfigs>
|
||||
<hudson.plugins.git.UserRemoteConfig>
|
||||
<url>git@rudolf.com.ua:avr.git</url>
|
||||
<url>ssh://git@rudolf.com.ua:23/rudolf/avr.git</url>
|
||||
<credentialsId>057bac74-b42d-46d3-9c6f-bb1c81491d93</credentialsId>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
from ansible import errors
|
||||
import re
|
||||
|
||||
def split_string(string, separator=' '):
|
||||
try:
|
||||
return string.split(separator)
|
||||
except Exception, e:
|
||||
raise errors.AnsibleFilterError('split plugin error: %s, provided string: "%s"' % (str(e),str(string)) )
|
||||
|
||||
def split_regex(string, separator_pattern='\s+'):
|
||||
try:
|
||||
return re.split(separator_pattern, string)
|
||||
except Exception, e:
|
||||
raise errors.AnsibleFilterError('split plugin error: %s, provided string: "%s"' % (str(e),str(string)) )
|
||||
|
||||
class FilterModule(object):
|
||||
''' A filter to split a string into a list. '''
|
||||
def filters(self):
|
||||
return {
|
||||
'split' : split_string,
|
||||
'split_regex' : split_regex,
|
||||
}
|
||||
|
||||
+29
-2
@@ -18,6 +18,16 @@
|
||||
groups: docker
|
||||
append: yes
|
||||
|
||||
- name: copy users file
|
||||
copy:
|
||||
src: tomcat/tomcat-users.xml
|
||||
dest: /tmp/tomcat-users.xml
|
||||
force: yes
|
||||
owner: "{{ user }}"
|
||||
group: "{{ user }}"
|
||||
notify:
|
||||
- restart tomcat docker
|
||||
|
||||
- name: run tomcat docker
|
||||
docker:
|
||||
name: tomcat
|
||||
@@ -27,6 +37,23 @@
|
||||
ports:
|
||||
- "0.0.0.0:{{ tomcat_port }}:8080"
|
||||
volumes:
|
||||
- "/var/tomcat:/usr/local/tomcat/webapps"
|
||||
|
||||
- "/tmp/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml"
|
||||
state: reloaded
|
||||
notify:
|
||||
- restart tomcat docker
|
||||
|
||||
|
||||
handlers:
|
||||
|
||||
- name: restart tomcat docker
|
||||
docker_container:
|
||||
name: tomcat
|
||||
image: tomcat:jre8
|
||||
restart: yes
|
||||
ports:
|
||||
- "0.0.0.0:{{ tomcat_port }}:8080"
|
||||
volumes:
|
||||
- "/tmp/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<tomcat-users>
|
||||
<role rolename="manager-gui"/>
|
||||
<role rolename="manager-gui"/>
|
||||
<role rolename="admin-gui" />
|
||||
<role rolename="" />
|
||||
<user username="tomcat" password="fzR8kJ1io6FF3sSM" roles="manager-gui,admin-gui"/>
|
||||
<user username="deployer" password="deployer" roles="manager-script"/>
|
||||
</tomcat-users>
|
||||
Reference in New Issue
Block a user