-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-jenkins-ci.yml
90 lines (74 loc) · 1.98 KB
/
setup-jenkins-ci.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
---
- hosts: do_jenkins
tasks:
- name: Download docker compose
get_url:
url: https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: '711'
- name: Test connectivity
ping:
- name: Upgrade all packages
yum:
name: '*'
state: latest
- name: Enabling the EPEL repo
yum:
name:
- epel-release
- name: Install required packages for Docker
yum:
name:
- yum-utils
- device-mapper-persistent-data
- lvm2
- name: Add Docker CE repository
shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- name: Install Docker CE
yum:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- name: Start service Docker, if not started
service:
name: docker
state: started
- name: Get GID of docker
getent:
database: group
key: docker
- debug:
var: getent_group.docker[1]
- name: Install Python PIP
yum:
name:
- python-pip
- name: Install Docker SDK for Python
pip:
name: docker
- name: Copy files of jenkins on the control node to the tmp on the remote hosts
copy:
src: jenkins
dest: /tmp
- name: Build the Jenkins CI image
docker_image:
name: my-jenkins
build:
path: /tmp/jenkins
args:
docker_gid: "{{ getent_group.docker[1] }}"
pull: yes
source: build
- name: Jenkins container
docker:
name: jenkins
image: my-jenkins
state: started
expose:
- 8080
- 50000
volume:
- 'jenkins_home:/var/jenkins_home'
- './casc_configs:/var/jenkins_home/casc_configs'
- '/var/run/docker.sock:/var/run/docker.sock'