-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_jenkins.yml
186 lines (158 loc) · 4.5 KB
/
deploy_jenkins.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
---
- hosts: jenkins
remote_user: root
tasks:
# Failed in setup
# - name: Add python to allow normal Ansible management
# raw: dnf -y install python-simplejson
- name: Update to the latest packages
dnf:
name: '*'
state: latest
- name: Add needed packages (including epel (may not be necessary))
dnf:
name: "{{item}}"
state: latest
with_items:
- "httpd"
- "git"
- "mod_proxy_html"
- "bc"
- "libselinux-python"
- name: Modify the Apache file layout to use sites available/enabled
file:
path: "{{item}}"
state: directory
mode: 0755
with_items:
- "/etc/httpd/sites-enabled"
- "/etc/httpd/sites-available"
notify:
- restart apache
# - name: Test for new IncludeOptional line
# shell: grep '^IncludeOptional sites-enabled/*.conf' /etc/httpd/conf/httpd.conf
# register: test_grep
- name: Add new IncludeOptional line
lineinfile:
dest: /etc/httpd/conf/httpd.conf
line: "IncludeOptional sites-enabled/*.conf"
notify:
- restart apache
# - name: Add Jenkins repository
# get_url:
# url: http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
# dest: /etc/yum.repos.d/jenkins.repo
# mode: 0644
# - name: Add Jenkins repo key
# rpm_key:
# state: present
# key: https://jenkins-ci.org/redhat/jenkins-ci.org.key
# - name: Fix SELinux context on repo file
# file:
# path: /etc/yum.repos.d/jenkins.repo
# seuser: unconfined_u
# serole: object_r
# setype: system_conf_t
# selevel: s0
# Only available in Ansible 2.1
# - name: Add Jenkins repository
# yumrepo:
# name: jenkins_repo
# description: Add Jenkins YUM repo
# file: jenkins.repo
# baseurl: http://pkg.jenkins-ci.org/redhat-stable/
# enabled: yes
# gpgcheck: no
# - name: Install OpenJDK
# yum:
# name: java-1.7.0-openjdk
# state: present
- name: Install Jenkins
dnf:
name: jenkins
state: present
# - name: Configure firewalld port 8080/tcp
# firewalld:
# zone: public
# port: 8080/tcp
# permanent: true
# immediate:
# - name: Configure firwalld http service
# firewalld:
# zone: public
# service: http
# permanent: true
# immediate:
- name: Disable Jenkins HTTP listener
replace:
dest=/etc/sysconfig/jenkins
regexp='JENKINS_PORT="8080"'
replace='JENKINS_PORT="-1"'
notify:
- restart jenkins
# - name: Enable MD5 in Java security (work around for current bug)
# replace:
# dest=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.95-2.6.4.0.el7_2.x86_64/jre/lib/security/java.security
# regexp='jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024'
# replace='jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024'
# notify:
# - restart jenkins
- name: Limit AJP listener to localhost
replace:
dest=/etc/sysconfig/jenkins
regexp='JENKINS_AJP_LISTEN_ADDRESS=""'
replace='JENKINS_AJP_LISTEN_ADDRESS="127.0.0.1"'
notify:
- restart jenkins
# Being exploded by Jenkins but not seen in plugins
# - name: Add the Google OAuth plugin
# get_url:
# url: http://updates.jenkins-ci.org/latest/google-oauth-plugin.hpi
# dest: /var/lib/jenkins/plugins
# notify:
# - restart jenkins
- name: Enable and start Apache
service:
name: httpd
enabled: yes
state: started
# Need
# Configure SSL Proxy
- name: Enable and start Jenkins
service:
name: jenkins
enabled: yes
state: started
- name: Deploy jenkins proxy template
template:
src: apache_ajp_proxy
dest: /etc/httpd/sites-available/{{ansible_nodename}}.conf
owner: root
group: root
mode: 0644
notify:
- restart apache
- name: Link apache config in sites-available to sites-enabled
file:
src: /etc/httpd/sites-available/{{ansible_nodename}}.conf
dest: /etc/httpd/sites-enabled/{{ansible_nodename}}.conf
owner: root
group: root
state: link
notify:
- restart apache
- name: Clone Lets Encrypt repository
git:
repo: https://github.com/letsencrypt/letsencrypt
dest: /opt/letsencrypt
# Need
# Google app auth (http://stackoverflow.com/questions/17676232/how-to-configure-jenkins-authentication-with-google-apps)
handlers:
- name: restart apache
service:
name: httpd
state: restarted
- name: restart jenkins
service:
name: jenkins
state: restarted