-
Notifications
You must be signed in to change notification settings - Fork 1
/
Docker_Install-Jenkins-playbook.yml
42 lines (34 loc) · 1.45 KB
/
Docker_Install-Jenkins-playbook.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
---
################################################################################
# description: Run Docker container Jenkins
# usage: ansible-playbook Docker_Install-Jenkins-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# author: Ernest G. Wilson II <ErnestGWilsonII@gmail.com> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Run Docker container Jenkins
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# docker - manage docker containers
# REF: http://docs.ansible.com/ansible/docker_container_module.html
###################################################################
- name: jenkins container
docker_container:
name: jenkins
image: jenkins
state: started
exposed_ports:
- 8080
- 50000
ports:
- "8080:8080"
- "50000:50000"
# docker ps
# docker ps | grep jenkins | awk '{print $1}'
# export JENKINS_CONTAINER_ID=`docker ps | grep jenkins | awk '{print $1}'`
# docker cp $JENKINS_CONTAINER_ID:/var/jenkins_home/secrets/initialAdminPassword /tmp/jenkins_initialAdminPassword.txt
# cat /tmp/jenkins_initialAdminPassword.txt