-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.yml
95 lines (74 loc) · 2.99 KB
/
master.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
- hosts: all
sudo: yes
vars_files:
- vars/main.yml
tasks:
- name: Ensure dependencies are installed.
apt: pkg=curl state=installed
- name: install python-pycurl
apt: pkg=python-pycurl state=latest
- name: Add Jenkins apt repository key.
apt_key:
url: "https://jenkins-ci.org/debian/jenkins-ci.org.key"
state: present
validate_certs: no
- name: Add Jenkins apt repository.
apt_repository:
repo: "deb http://pkg.jenkins-ci.org/debian binary/"
state: present
update_cache: yes
- name: Ensure Jenkins is installed.
apt: pkg=jenkins state=installed
- name: Ensure Jenkins-cli is installed.
apt: pkg=jenkins-cli state=installed
- name: Ensure Jenkins is running
service: name=jenkins state=started
- name: Wait for Jenkins to start
wait_for:
host=localhost
port=8080
delay=10
timeout=300
- name: Check if job path exists
stat: path=/var/lib/jenkins/jobs/test
register: check_job_path
- name: Create a job with Jenkins-cli using an existing jobs xml
shell: 'jenkins-cli -s http://localhost:8080 create-job test < /vagrant/jobs/test.xml'
when: check_job_path.stat.exists == false
- name: Install the Swarm plugin
get_url: dest=/var/lib/jenkins/plugins url=https://updates.jenkins-ci.org/download/plugins/swarm/1.22/swarm.hpi validate_certs=no
- name: Restart Jenkins to activate the Swarm plugin
service: name=jenkins state=restarted
- name: Create Jenkins updates folder.
file:
path: /var/lib/jenkins/updates
owner: jenkins
group: jenkins
mode: 0755
state: directory
- name: Update Jenkins plugin data.
shell: >
curl -L https://updates.jenkins-ci.org/update-center.json | sed '1d;$d' > /var/lib/jenkins/updates/default.json
creates=/var/lib/jenkins/updates/default.json
- name: Permissions for default.json updates info.
file:
path: /var/lib/jenkins/updates/default.json
owner: jenkins
group: jenkins
mode: 0755
- name: restart jenkins
service: name=jenkins state=restarted
- name: Copying Jenkin Job File from playbook
copy: src=./files/lighttpd.xml dest=/opt/lighttpd.xml
owner=root group=root mode=0644
- name: Ensure lighttpd dependencies are installed.
yum: pkg={{ item }}
with_items: "{{ lighttpd_dependencies }}"
- name: Importing Jenkins Job file
shell: >
java -jar {{ jenkins_jar_location }} -s http://{{ jenkins_hostname }}:{{ jenkins_port }} create-job lighttpd < /opt/lighttpd.xml
retries: 5
delay: 10
- name: Running Jenkins Job lighttpd
shell: >
java -jar {{ jenkins_jar_location }} -s http://{{ jenkins_hostname }}:{{ jenkins_port }} build lighttpd