From c7a8f87858c0b163cf76c17810cae141355174bb Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 14 Jun 2019 16:13:13 +0800 Subject: [PATCH] feat: init task --- defaults/main.yml | 18 +++++++++++++++++- tasks/drone-agent.yml | 15 +++++++++++++++ tasks/drone-server.yml | 34 ++++++++++++++++++++++++++++++++++ tasks/main.yml | 5 ++++- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tasks/drone-agent.yml create mode 100644 tasks/drone-server.yml diff --git a/defaults/main.yml b/defaults/main.yml index b9f00db..c20aa8d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,18 @@ --- -# defaults file for ansible-drone \ No newline at end of file +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" diff --git a/tasks/drone-agent.yml b/tasks/drone-agent.yml new file mode 100644 index 0000000..2086b25 --- /dev/null +++ b/tasks/drone-agent.yml @@ -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 diff --git a/tasks/drone-server.yml b/tasks/drone-server.yml new file mode 100644 index 0000000..79b55cc --- /dev/null +++ b/tasks/drone-server.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 94063ed..703bc50 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,5 @@ --- -# tasks file for ansible-drone \ No newline at end of file + - include: drone-server.yml + when: drone_server_enable == "true" + - include: drone-agent.yml + when: drone_agent_enable == "true"