-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_jenkins_master
76 lines (63 loc) · 1.8 KB
/
install_jenkins_master
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
---
- hosts: "{{ passed_in_hosts }}"
become: yes
remote_user: ec2-user
become_user: root
tasks:
- name: install dependencies
yum:
name: "{{ package }} "
state: present
vars:
package:
- wget
- java-1.8.0-openjdk-devel
- git
- name: clone repo
git:
repo: https://github.com/linuxacademy/content-terraform-jenkins.git
dest: /tmp/jenkins
- name: Setup Jenkins Repo
get_url:
url: https://pkg.jenkins.io/redhat/jenkins.repo
dest: /etc/yum.repos.d/jenkins.repo
- name: Import Jenkins Repo GPG key
rpm_key:
state: present
key: https://pkg.jenkins.io/redhat/jenkins.io.key
- name: install Jenkins
yum:
name: jenkins
state: present
- name: Temporarily Stop Jenkins
service:
name: jenkins
state: stopped
- name: Modify user shell
user:
name: jenkins
shell: /bin/bash
- name: Delete Jenkins default dir
file:
state: absent
path: /var/lib/jenkins
- name: Copy over cloned Jenkins /var/lib/jenkins
copy:
remote_src: yes
src: /tmp/jenkins/jenkins
dest: /var/lib
- name: Restore jenkins user ownership on /var/lib/jenkins
file:
path: /var/lib/jenkins
state: directory
recurse: yes
owner: jenkins
- name: Start Jenkins
service:
name: jenkins
state: started
enabled: yes
- name: Wait until Jenkins is up
shell: result_first=1; while [[ $result_first != 0 ]]; do if [[ `grep 'Jenkins is fully up and running' /var/log/jenkins/jenkins.log` ]];then result_first=0;else sleep 4;fi;done
register: result
until: result.rc == 0