feat: init task

This commit is contained in:
Bo-Yi Wu 2019-06-14 16:13:13 +08:00
parent 6851c4731d
commit c7a8f87858
4 changed files with 70 additions and 2 deletions

View File

@ -1,2 +1,18 @@
--- ---
# defaults file for ansible-drone drone_server_enable: "false"
drone_agent_enable: "false"
drone_version: "latest"
drone_server_host: ""
drone_server_proto: "http"
drone_tls_autocert: "false"
drone_rpc_secret: ""
drone_agents_enabled: "true"
drone_github_server: "https://github.com"
drone_github_client_id: ""
drone_github_client_secret: ""
drone_logs_pretty: "true"
drone_logs_color: "true"
drone_dir: "/var/lib/drone"
drone_rpc_server: "http://drone-server"
drone_runner_capacity: "3"
drone_host_port: "8080"

15
tasks/drone-agent.yml Normal file
View File

@ -0,0 +1,15 @@
---
- name: run drone agent
docker_container:
name: "drone-agent"
image: "drone/agent:{{ drone_version }}"
state: started
restart_policy: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
env:
DRONE_RPC_SERVER={{ drone_rpc_server }}
DRONE_RPC_SECRET={{ drone_rpc_secret }}
DRONE_RUNNER_CAPACITY={{ drone_runner_capacity }}
tags:
- drone-agent

34
tasks/drone-server.yml Normal file
View File

@ -0,0 +1,34 @@
---
- name: Creates directory
file:
path: "{{ item }}"
state: directory
mode: 0755
with_items:
- "{{ drone_dir }}"
tags:
- drone-server
- name: run drone server
docker_container:
name: drone-server
image: "drone/drone:{{ drone_version }}"
state: started
restart_policy: always
ports:
- "{{ drone_host_port }}:80"
volumes:
- "{{ drone_dir }}:/data"
env:
DRONE_SERVER_HOST: "{{ drone_server_host }}"
DRONE_SERVER_PROTO: "{{ drone_server_proto }}"
DRONE_TLS_AUTOCERT: "false"
DRONE_RPC_SECRET: "{{ drone_rpc_secret }}"
DRONE_AGENTS_ENABLED: "true"
DRONE_GITHUB_SERVER: "https://github.com"
DRONE_GITHUB_CLIENT_ID: "{{ drone_github_client_id }}"
DRONE_GITHUB_CLIENT_SECRET: "{{ drone_github_client_secret }}"
DRONE_LOGS_PRETTY: "{{ drone_logs_pretty }}"
DRONE_LOGS_COLOR: "{{ drone_logs_color }}"
tags:
- drone-server

View File

@ -1,2 +1,5 @@
--- ---
# tasks file for ansible-drone - include: drone-server.yml
when: drone_server_enable == "true"
- include: drone-agent.yml
when: drone_agent_enable == "true"