use systemd to control docker-compose setup
This commit is contained in:
parent
0d264f39a1
commit
0b919dccc7
@ -7,8 +7,9 @@ droneci_secret: myveryownsecret
|
||||
# Path to the license key file
|
||||
# droneci_license_key: # defaults to not set
|
||||
|
||||
droneci_restart_policy: always
|
||||
|
||||
droneci_server_image: "drone/drone:{{ droneci_version }}"
|
||||
droneci_server_restart_policy: always
|
||||
droneci_server_exposed_port: 8080
|
||||
droneci_server_exposed_ip: 127.0.0.1
|
||||
# droneci_server_memory_limit: 512m # defaults to not set
|
||||
@ -16,7 +17,6 @@ droneci_server_exposed_ip: 127.0.0.1
|
||||
# droneci_server_extra_hosts: []
|
||||
|
||||
droneci_agent_image: "drone/agent:{{ droneci_version }}"
|
||||
droneci_agent_restart_policy: always
|
||||
dronevi_agent_capacity: 2
|
||||
# droneci_agent_memory_limit: 512m # defaults to not set
|
||||
# droneci_agent_memory_reservation: 256m # defaults to not set
|
||||
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
- name: Restart container
|
||||
docker_service:
|
||||
project_src: "{{ droneci_service_directory }}"
|
||||
build: no
|
||||
restarted: true
|
||||
systemd:
|
||||
state: restarted
|
||||
daemon_reload: yes
|
||||
name: drone
|
||||
listen: __drone_restart
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -2,3 +2,4 @@
|
||||
- import_tasks: prepare.yml
|
||||
- import_tasks: setup.yml
|
||||
- import_tasks: nginx.yml
|
||||
- import_tasks: post.yml
|
||||
|
10
tasks/post.yml
Normal file
10
tasks/post.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- block:
|
||||
- name: Ensure drone service is up and running
|
||||
systemd:
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
enabled: yes
|
||||
name: drone
|
||||
become: True
|
||||
become_user: root
|
@ -13,15 +13,18 @@
|
||||
mode: 0644
|
||||
notify: __drone_restart
|
||||
|
||||
- name: Create systemd unit files
|
||||
template:
|
||||
src: "etc/systemd/system/drone.service.j2"
|
||||
dest: "/etc/systemd/system/drone.service"
|
||||
mode: 0644
|
||||
notify: __drone_restart
|
||||
|
||||
- name: Copy license key file is defined
|
||||
copy:
|
||||
src: "{{ droneci_license_key }}"
|
||||
dest: "{{ droneci_service_directory }}/{{ droneci_license_key | basename }}"
|
||||
mode: 0600
|
||||
when: droneci_license_key is defined
|
||||
|
||||
- name: Ensure drone ci containers are up and running
|
||||
docker_service:
|
||||
project_src: "{{ droneci_service_directory }}"
|
||||
become: True
|
||||
become_user: root
|
||||
|
19
templates/etc/systemd/system/drone.service.j2
Normal file
19
templates/etc/systemd/system/drone.service.j2
Normal file
@ -0,0 +1,19 @@
|
||||
#jinja2:lstrip_blocks: True
|
||||
# {{ ansible_managed }}
|
||||
[Unit]
|
||||
Description=Drone CI compose service
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Restart={{ droneci_restart_policy }}
|
||||
WorkingDirectory={{ droneci_service_directory }}
|
||||
|
||||
ExecStartPre=/bin/docker-compose down
|
||||
ExecStartPre=/bin/docker-compose rm -f
|
||||
|
||||
ExecStart=/usr/bin/docker-compose up
|
||||
ExecStop=/usr/bin/docker-compose down
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -25,6 +25,7 @@ services:
|
||||
environment:
|
||||
- DRONE_SERVER_HOST={{ droneci_host | urlsplit('hostname') }}
|
||||
- DRONE_SERVER_PROTO={{ droneci_host | urlsplit('scheme') }}
|
||||
- DRONE_AGENTS_ENABLED=true
|
||||
- DRONE_RPC_SECRET={{ droneci_secret }}
|
||||
- DRONE_USER_CREATE={{ droneci_admins | default(omit) | join(",") }}
|
||||
- DRONE_LOGS_COLOR=true
|
||||
|
Loading…
Reference in New Issue
Block a user