-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.yml
109 lines (93 loc) · 2.49 KB
/
main.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
---
# tasks file for roles/jenkins_build
- name: Add Jenkins repository
with_inventory_hostnames:
- jenkins_redhat
yum_repository:
name: jenkins
description: Jenkins Repo
baseurl: http://pkg.jenkins.io/redhat-stable/
enabled: yes
gpgcheck: no
- name: Import Jenkins Key
ansible.builtin.rpm_key:
state: present
key: https://pkg.jenkins.io/redhat-stable/jenkins.io.key
- name: Install Jenkins and Java
package:
name:
- java-11-openjdk
- jenkins
- name: Just force systemd to reread configs
systemd:
daemon_reload: yes
- name: Start and Enable Jenkins service
service:
name: jenkins
state: started
enabled: yes
- name: Set defaults for Jenkins
template:
src: files/jenkins_default
dest: /var/lib/jenkins/jenkins.install.UpgradeWizard.state
- name: Create init folder
file:
path: /var/lib/jenkins/init.groovy.d/
state: directory
- name: Set username and password
template:
src: files/security.groovy
dest: /var/lib/jenkins/init.groovy.d/basic-security.groovy
- name: Restart and Enable Jenkins service
service:
name: jenkins
state: restarted
enabled: yes
- name: Get the Jenkins Plugin
get_url:
url: http://localhost:8080/jnlpJars/jenkins-cli.jar
dest: /root/jenkins-cli.jar
- name: Set username and password for Jenkins Plugin
template:
src: files/jenkinspluginauth
dest: /root/jenkinsauth
- name: Install Plugins
shell: |
java -jar /root/jenkins-cli.jar -s http://localhost:8080/ -auth @/root/jenkinsauth install-plugin \
greenballs \
github \
cloudbees-folder \
dashboard-view \
configuration-as-code \
build-timeout \
rebuild \
ssh-agent \
timestamper \
ws-cleanup \
repo \
ssh-slaves \
email-ext \
mailer \
workflow-aggregator
- name: Copy Job Template
template:
src: files/job_template.xml
dest: /var/lib/jenkins/jobs/job_template.xml
- name: Create Job Template
shell: |
java -jar /root/jenkins-cli.jar -s http://localhost:8080/ -auth @/root/jenkinsauth create-job job_template < /var/lib/jenkins/jobs/job_template.xml
- name: Restart and Enable Jenkins service
service:
name: jenkins
state: restarted
enabled: yes
- name: Get Initial Admin Password file
become: yes
shell: |
cat initialAdminPassword
args:
chdir: "/var/lib/jenkins/secrets"
register: adminpassword
- debug:
msg:
- "Jenkins initial Admin Password: {{ adminpassword.stdout }}"