forked from Brights-DevOps-2022-Script/Hello-World_Ulrike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook_Jenkins.yml
57 lines (48 loc) · 1.59 KB
/
playbook_Jenkins.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
- name: Jenkins Installation
hosts: vm
become: true
tasks:
- name: install java
ansible.builtin.apt:
name: openjdk-17-jre
state: present
- name: install jenkins gpg key
ansible.builtin.apt_key:
url: https://pkg.jenkins.io/debian/jenkins.io.key
state: present
- name: Add specified repository into sources list
ansible.builtin.apt_repository:
repo: deb https://pkg.jenkins.io/debian-stable binary/
state: present
- name: apt-get update
ansible.builtin.shell: sudo apt-get update
- name: Install the package "Jenkins"
ansible.builtin.apt:
name:
- jenkins
state: present
- name: check if jenkins components are installed
ansible.builtin.shell: dpkg -l 'jenkins'
register: Jenkins
failed_when: Jenkins.stderr != ''
changed_when: false
- name: Add the user "jenkins" to docker group
ansible.builtin.user:
name: jenkins
comment: user of jenkins
uid: 1001
group: docker
- name: check if user is added to docker group
ansible.builtin.shell: id -nG snowman | grep -o docker
register: dockeruser
failed_when: dockeruser.stderr != ''
changed_when: false
- name: run Hello-world container
community.docker.docker_container:
name: hello-world_Ulli
image: hello-world
- name: check if hello-world container is running
ansible.builtin.shell: docker ps | grep hello-world
register: hello
failed_when: hello.stderr != ''
changed_when: false