-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
90 lines (77 loc) · 2 KB
/
playbook.yml
File metadata and controls
90 lines (77 loc) · 2 KB
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
---
- hosts: all
become: true
vars:
user_id: 1040
container_image: hello-world
tasks:
- name: install dependencies
ansible.builtin.apt:
name:
- ca-certificates
- curl
- gnupg
- lsb-release
state: latest
update_cache: true
- name: add docker apt key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
- name: Add Docker Repository
ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable
- name: Install the package "docker"
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: latest
- name: Check if Docker is started and if no, start Docker
ansible.builtin.service:
name: docker
state: started
- name: Add the user 'chrisS' with a specific uid and a primary group of 'admin'
ansible.builtin.user:
name: chrisS
comment: Christoph Schmid
uid: "{{ user_id }}"
group: admin
- name: Copy Dockerfile onto VM
copy:
src: Dockerfile
dest: /home/knight
- name: Build Jenkins image
community.docker.docker_image:
name: jenkins
build:
path: .
source: build
- name: Run Jenkins container
docker_container:
name: jenkins
image: jenkins
state: started
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- jenkins_home:/var/jenkins_home
ports:
- "8080:8080"
restart_policy: on-failure
- name: Install pip3
apt:
name: python3-pip
state: present
- name: Install python-jenkins
pip:
name: python-jenkins
state: present
executable: pip3
- name: Login to Jenkins
uri:
url: http://20.218.219.173:8080/j_acegi_security_check
method: POST
body: j_username=admin&j_password=password
return_content: yes
status_code: 200