-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
main.yml
79 lines (71 loc) · 2.99 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
---
##########
# Docker #
##########
- name: Check if docker already exists
command: docker version
failed_when: false
changed_when: false
register: docker_version
tags:
- docker
# TODO: write a condition when NOT to run this step
- skip_ansible_lint
- name: Install Docker Engineer
when: docker_version.rc != 0 # when no docker version set
tags: docker
block:
################
# Pre Install #
################
- name: Prepare for RHEL7/CentOS7
include_tasks: rhel.yml
when:
- ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
- ansible_distribution_major_version == "7"
- name: Prepare for Ubuntu
include_tasks: ubuntu.yml
when:
- ansible_distribution == "Ubuntu"
- name: Prepare for Debian / Raspbian
include_tasks: debian.yml
when:
- ansible_distribution == "Debian"
##################
# Install Docker #
##################
- name: Install docker based on OS (Ubuntu, RHEL7, CentOS7, Debian)
package:
name:
- docker-ce
state: latest # TODO: Package installs should not use latest
use: auto # automatic select package manager to use yum, apt and so on
when: ((ansible_distribution == "RedHat" or ansible_distribution == "CentOS") and (ansible_distribution_major_version == "7")) or (ansible_distribution == "Ubuntu" or ansible_distribution == "Debian")
- name: Install for SLES12 # zypper does not support in package module
include_tasks: sles.yml
when:
- ansible_distribution == "SLES" and ansible_distribution_major_version == "12"
################
# Post Install #
################
- name: Add Jenkins user to the docker group for Ubuntu, Debian, SLES12, CentOS7 and RHEL7
user:
name: "{{ Jenkins_Username }}"
groups: docker
append: yes
state: present
when:
- (ansible_distribution == "Ubuntu" or ansible_distribution == "Debian") or (ansible_distribution == "SLES" and ansible_distribution_major_version == "12") or ((ansible_distribution == "RedHat" or ansible_distribution == "CentOS" ) and ansible_distribution_major_version == "7")
- (ansible_architecture == "x86_64" or ansible_architecture == "ppc64le" or ansible_architecture == "s390x") and (ansible_architecture != "riscv64")
tags:
- jenkins
- name: Enable and Start Docker Service for Ubuntu, Debian, SLES12, CentOS7 and RHEL7
service:
name: docker
state: started
enabled: yes
when:
- (ansible_distribution == "Ubuntu" or ansible_distribution == "Debian") or (ansible_distribution == "SLES" and ansible_distribution_major_version == "12") or ((ansible_distribution == "RedHat" or ansible_distribution == "CentOS" ) and ansible_distribution_major_version == "7")
- (ansible_architecture == "x86_64" or ansible_architecture == "ppc64le" or ansible_architecture == "s390x") and (ansible_architecture != "riscv64")
tags:
- docker