ansible_drone/tasks/drone-server.yml

88 lines
2.5 KiB
YAML
Raw Normal View History

2019-06-14 10:13:13 +02:00
---
- name: verify that required database parameters
fail:
msg: "Variable '{{ item }}' is not defined for drone server setup"
when: item not in vars and drone_database_driver != "sqlite"
with_items:
- drone_database_datasource
tags:
- configuration
- name: verify that required server parameters
fail:
msg: "Variable '{{ item }}' is not defined for drone server setup"
when: item not in vars
with_items:
- drone_server_host
- drone_server_proto
- drone_rpc_secret
tags:
- configuration
2019-06-14 17:30:07 +02:00
- name: copy config for drone server
template:
src: "drone-server.env.j2"
dest: "/etc/drone/drone-server.env"
register: drone_server_config
tags:
- configuration
- name: Creates sqlite directory
2019-06-14 10:13:13 +02:00
file:
2019-06-15 17:07:01 +02:00
path: "{{ drone_sqlite_dir }}"
2019-06-14 10:13:13 +02:00
state: directory
mode: 0755
2019-06-15 17:07:01 +02:00
when: drone_database_driver == "sqlite"
register: drone_sqlite_folder
2019-06-14 10:13:13 +02:00
tags:
- drone-server
2019-06-15 17:55:37 +02:00
- name: run drone server with sqlite database
2019-06-14 10:13:13 +02:00
docker_container:
name: drone-server
image: "drone/drone:{{ drone_version }}"
state: started
restart_policy: always
ports:
- "{{ drone_host_port }}:80"
volumes:
2019-06-15 17:07:01 +02:00
- "{{ drone_sqlite_dir }}:/data"
2019-06-14 17:30:07 +02:00
env_file: /etc/drone/drone-server.env
labels:
traefik.enable: "true"
traefik.basic.frontend.rule: "Host:{{ drone_server_host }}"
traefik.basic.port: "80"
traefik.basic.protocol: "http"
2019-06-18 18:53:57 +02:00
when: ((drone_server_config is defined and drone_server_config.changed) or
(drone_sqlite_folder is defined and drone_sqlite_folder.changed)) and
2019-06-15 17:55:37 +02:00
drone_database_driver == "sqlite"
tags:
- drone-server
- skip_ansible_lint
2019-06-15 17:55:37 +02:00
- name: run drone server with postgres or mysql database
docker_container:
name: drone-server
image: "drone/drone:{{ drone_version }}"
state: started
restart_policy: always
ports:
- "{{ drone_host_port }}:80"
links:
- "{{ drone_database_driver }}"
volumes:
- "{{ drone_sqlite_dir }}:/data"
env_file: /etc/drone/drone-server.env
labels:
traefik.enable: "true"
traefik.basic.frontend.rule: "Host:{{ drone_server_host }}"
traefik.basic.port: "80"
traefik.basic.protocol: "http"
2019-06-18 18:53:57 +02:00
when: ((drone_server_config is defined and drone_server_config.changed) or
2021-02-21 00:23:18 +01:00
(drone_postgres_backup_dir_state is defined and drone_postgres_backup_dir_state.changed) or
drone_server_force) and
2019-06-15 17:55:37 +02:00
drone_database_driver != "sqlite"
2019-06-14 10:13:13 +02:00
tags:
- drone-server
- skip_ansible_lint