2020-09-16 01:52:08 +00:00
|
|
|
- name: Create Jenkins user
|
|
|
|
user:
|
|
|
|
name: "{{ jenkins_user }}"
|
|
|
|
state: present
|
|
|
|
shell: /bin/bash
|
|
|
|
skeleton: /etc/skel
|
|
|
|
generate_ssh_key: true
|
|
|
|
|
|
|
|
- name: Set Jenkins authorized key
|
|
|
|
authorized_key:
|
|
|
|
user: jenkins
|
|
|
|
state: present
|
|
|
|
exclusive: true
|
|
|
|
key: "{{ jenkins_sshkey }}"
|
|
|
|
when: jenkins_sshkey is defined
|
|
|
|
|
2020-04-03 00:03:40 +00:00
|
|
|
- name: Install Ansible source
|
|
|
|
template:
|
|
|
|
src: ansible.list
|
|
|
|
dest: /etc/apt/sources.list.d/ansible.list
|
|
|
|
|
|
|
|
- name: Add Ansible source key
|
|
|
|
apt_key:
|
|
|
|
keyserver: keyserver.ubuntu.com
|
|
|
|
id: 93C4A3FD7BB9C367
|
|
|
|
|
|
|
|
- name: Install Ansible
|
|
|
|
apt:
|
|
|
|
name: ansible
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Install Java
|
|
|
|
apt:
|
|
|
|
name: default-jre
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create Jenkin's directory
|
|
|
|
file:
|
2020-07-21 01:42:50 +00:00
|
|
|
path: "{{ jenkins_root }}"
|
2020-04-03 00:03:40 +00:00
|
|
|
state: directory
|
|
|
|
owner: "1000"
|
|
|
|
group: "1000"
|
|
|
|
|
|
|
|
- name: Start Jenkins Container
|
|
|
|
docker_container:
|
2020-07-21 01:42:50 +00:00
|
|
|
name: "{{ jenkins_name }}"
|
2020-04-04 00:51:16 +00:00
|
|
|
image: jenkins/jenkins:{{ jenkins_version }}
|
2020-04-03 00:03:40 +00:00
|
|
|
state: started
|
|
|
|
restart_policy: always
|
|
|
|
ports:
|
|
|
|
- 50000:50000
|
2020-07-21 01:42:50 +00:00
|
|
|
volumes: "{{ jenkins_root }}:/var/jenkins_home"
|
2020-07-18 05:58:57 +00:00
|
|
|
networks_cli_compatible: true
|
|
|
|
networks:
|
|
|
|
- name: traefik
|
|
|
|
labels:
|
|
|
|
traefik.http.routers.jenkins.rule: "Host(`{{ jenkins_domain }}`)"
|
|
|
|
traefik.http.routers.jenkins.entrypoints: websecure
|
2020-09-04 06:14:12 +00:00
|
|
|
traefik.http.routers.jenkins.tls.certresolver: letsencrypt
|
|
|
|
traefik.http.routers.jenkins.middlewares: "securehttps@file"
|
2020-07-18 05:58:57 +00:00
|
|
|
traefik.docker.network: traefik
|
|
|
|
traefik.enable: "true"
|