Merge pull request 'refactoring' (#1) from refactoring into master
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #1
This commit is contained in:
commit
cb846a4c51
@ -1,35 +1,58 @@
|
|||||||
---
|
---
|
||||||
droneci_version: 1.6.0
|
droneci_version: 1.6.0
|
||||||
droneci_service_directory: /var/lib/docker/services/drone-ci
|
droneci_image: "drone/drone:{{ droneci_version }}"
|
||||||
|
|
||||||
|
droneci_service_directory: /var/lib/docker/services/droneci
|
||||||
droneci_docker_socket_path: /var/run/docker.sock
|
droneci_docker_socket_path: /var/run/docker.sock
|
||||||
|
droneci_container_name: droneci
|
||||||
|
droneci_restart_policy: always
|
||||||
|
droneci_service_stopped: False
|
||||||
|
|
||||||
droneci_host: http://localhost
|
droneci_host: http://localhost
|
||||||
droneci_secret: myveryownsecret
|
droneci_secret: myveryownsecret
|
||||||
|
|
||||||
# @var droneci_license_key:description Path to the license key file
|
# @var droneci_license_key:description Path to the license key file
|
||||||
# @var droneci_license_key: $ "_unset_"
|
# @var droneci_license_key: $ "_unset_"
|
||||||
|
|
||||||
droneci_restart_policy: always
|
droneci_exposed_ports:
|
||||||
|
- "127.0.0.1:8080:80"
|
||||||
|
|
||||||
droneci_server_container_name: drone-server
|
# @var droneci_volumes:description: > Define required docker volumes.
|
||||||
droneci_server_image: "drone/drone:{{ droneci_version }}"
|
# If you don't use sqlite you could remove the default volume. To enable a Drone licences
|
||||||
droneci_server_exposed_port: 8080
|
# you will need to configure a bind mount to `/etc/drone.key`.
|
||||||
droneci_server_exposed_ip: 127.0.0.1
|
# @end
|
||||||
|
# @var droneci_volumes:example: >
|
||||||
|
# droneci_volumes:
|
||||||
|
# # Instead of the name you could specify a path on the container host system,
|
||||||
|
# # but you also have to enable bind mount for this volume
|
||||||
|
# - name: data
|
||||||
|
# # target location inside the container
|
||||||
|
# dest: /var/lib/drone
|
||||||
|
# # enable bind mount, if false volume will be configured as named volume
|
||||||
|
# # keep in mind you MUST set bind in any case
|
||||||
|
# bind: True
|
||||||
|
# @end
|
||||||
|
droneci_volumes:
|
||||||
|
- name: data
|
||||||
|
dest: /var/lib/drone
|
||||||
|
bind: False
|
||||||
|
|
||||||
# @var droneci_server_memory_limit: $ "_unset_"
|
# @var droneci_networks:example: >
|
||||||
# @var droneci_server_memory_limit:example: $ "512m"
|
# droneci_networks:
|
||||||
# @var droneci_server_memory_reservation: $ "_unset_"
|
# - name: default
|
||||||
# @var droneci_server_memory_reservation:example: $ "256m"
|
# # optional network driver, defaults to 'bride'
|
||||||
|
# driver: host
|
||||||
|
# @end
|
||||||
|
droneci_networks:
|
||||||
|
- name: default
|
||||||
|
|
||||||
droneci_server_extra_hosts: []
|
droneci_networks_applied:
|
||||||
|
- default
|
||||||
|
|
||||||
droneci_agent_container_name: drone-agent
|
# @var droneci_memory_limit: $ "_unset_"
|
||||||
droneci_agent_image: "drone/drone-runner-docker:1.0.1"
|
# @var droneci_memory_limit:example: $ "512m"
|
||||||
droneci_agent_capacity: 2
|
# @var droneci_memory_reservation: $ "_unset_"
|
||||||
|
# @var droneci_memory_reservation:example: $ "256m"
|
||||||
# @var droneci_agent_memory_limit:example: $ "512m"
|
|
||||||
# @var droneci_agent_memory_limit: $ "_unset_"
|
|
||||||
# @var droneci_agent_memory_reservation:example: $ "256m"
|
|
||||||
# @var droneci_agent_memory_reservation: $ "_unset_"
|
|
||||||
|
|
||||||
droneci_db_type: sqlite
|
droneci_db_type: sqlite
|
||||||
droneci_db_server: localhost
|
droneci_db_server: localhost
|
||||||
@ -48,11 +71,10 @@ droneci_gitea_skip_verify: False
|
|||||||
# droneci_gitea_oauth_client_id: 1111-222-33333-44444 # defaults to not set
|
# droneci_gitea_oauth_client_id: 1111-222-33333-44444 # defaults to not set
|
||||||
# droneci_gitea_oauth_client_secret: 1234abcd5678efgh # defaults to not set
|
# droneci_gitea_oauth_client_secret: 1234abcd5678efgh # defaults to not set
|
||||||
|
|
||||||
# @var droneci_admin: $ "_unset_"
|
# @var droneci_admin_user: $ "_unset_"
|
||||||
# @var droneci_http_proxy: $ "_unset_"
|
# @var droneci_http_proxy: $ "_unset_"
|
||||||
# @var droneci_https_proxy: $ "_unset_"
|
# @var droneci_https_proxy: $ "_unset_"
|
||||||
|
|
||||||
# @var droneci_no_proxy: $ ["drone-server", "drone-agent"]
|
# @var droneci_no_proxy: $ ["drone-server", "drone-agent"]
|
||||||
droneci_no_proxy: []
|
droneci_no_proxy: []
|
||||||
|
droneci_extra_hosts: []
|
||||||
droneci_docker_compose_bin: /usr/local/bin/docker-compose
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Restart container
|
|
||||||
systemd:
|
|
||||||
state: restarted
|
|
||||||
daemon_reload: yes
|
|
||||||
name: drone
|
|
||||||
listen: __drone_restart
|
|
||||||
become: True
|
|
||||||
become_user: root
|
|
@ -2,9 +2,12 @@
|
|||||||
- name: Converge
|
- name: Converge
|
||||||
hosts: all
|
hosts: all
|
||||||
vars:
|
vars:
|
||||||
droneci_admin: dummy
|
dockerengine_packages_extra:
|
||||||
|
- epel-release
|
||||||
|
- python-pip
|
||||||
|
droneci_admin_user: dummy
|
||||||
|
droneci_service_stopped: True
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: xoxys.python3
|
|
||||||
- role: xoxys.docker_engine
|
- role: xoxys.docker_engine
|
||||||
- role: xoxys.droneci
|
- role: xoxys.droneci
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
---
|
---
|
||||||
- src: https://gitea.rknet.org/ansible/xoxys.python3.git
|
|
||||||
name: xoxys.python3
|
|
||||||
scm: git
|
|
||||||
version: master
|
|
||||||
|
|
||||||
- src: https://gitea.rknet.org/ansible/xoxys.docker_engine.git
|
- src: https://gitea.rknet.org/ansible/xoxys.docker_engine.git
|
||||||
name: xoxys.docker_engine
|
name: xoxys.docker_engine
|
||||||
scm: git
|
scm: git
|
||||||
version: master
|
version: refactoring
|
||||||
|
@ -10,6 +10,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
|
|
||||||
|
|
||||||
def test_droneci_compose_file(host):
|
def test_droneci_compose_file(host):
|
||||||
f = host.file('/var/lib/docker/services/drone-ci/docker-compose.yml')
|
f = host.file('/var/lib/docker/services/droneci/docker-compose.yml')
|
||||||
|
|
||||||
assert f.exists
|
assert f.exists
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
---
|
---
|
||||||
- name: Concat lists for proxy setup
|
|
||||||
set_fact:
|
|
||||||
droneci_no_proxy: "{{ __droneci_default_no_proxy }} + {{ droneci_no_proxy | default([]) }}"
|
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Ensure service directory exists
|
- name: Ensure service directory exists
|
||||||
file:
|
file:
|
||||||
@ -12,20 +8,12 @@
|
|||||||
|
|
||||||
- name: Deploy compose file to '{{ droneci_service_directory }}'
|
- name: Deploy compose file to '{{ droneci_service_directory }}'
|
||||||
template:
|
template:
|
||||||
src: "services/droneci-compose.yml.j2"
|
src: "services/droneci_compose.yml.j2"
|
||||||
dest: "{{ droneci_service_directory }}/docker-compose.yml"
|
dest: "{{ droneci_service_directory }}/docker-compose.yml"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0640
|
||||||
validate: "{{ droneci_docker_compose_bin }} -f %s config -q"
|
validate: "docker-compose -f %s config -q"
|
||||||
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
|
- name: Copy license key file is defined
|
||||||
copy:
|
copy:
|
||||||
@ -34,11 +22,14 @@
|
|||||||
mode: 0600
|
mode: 0600
|
||||||
when: droneci_license_key is defined
|
when: droneci_license_key is defined
|
||||||
|
|
||||||
- name: Ensure drone service is up and running
|
- name: Ensure Drone is up and running
|
||||||
systemd:
|
docker_compose:
|
||||||
state: started
|
project_src: "{{ droneci_service_directory }}"
|
||||||
daemon_reload: yes
|
pull: yes
|
||||||
enabled: yes
|
remove_orphans: yes
|
||||||
name: drone
|
stopped: "{{ droneci_service_stopped }}"
|
||||||
|
state: present
|
||||||
|
# temp. disable changes; breaks idempotency for whatever reason
|
||||||
|
changed_when: False
|
||||||
become: True
|
become: True
|
||||||
become_user: root
|
become_user: root
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
#jinja2:lstrip_blocks: True
|
|
||||||
{{ ansible_managed | comment }}
|
|
||||||
[Unit]
|
|
||||||
Description=Drone CI compose service
|
|
||||||
Requires=docker.service
|
|
||||||
After=docker.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Restart={{ droneci_restart_policy }}
|
|
||||||
WorkingDirectory={{ droneci_service_directory }}
|
|
||||||
|
|
||||||
ExecStartPre={{ droneci_docker_compose_bin }} pull --quiet --ignore-pull-failures
|
|
||||||
ExecStart={{ droneci_docker_compose_bin }} up --remove-orphans
|
|
||||||
|
|
||||||
ExecStop={{ droneci_docker_compose_bin }} down --remove-orphans
|
|
||||||
|
|
||||||
ExecReload={{ droneci_docker_compose_bin }} pull --quiet --ignore-pull-failures
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
@ -1,24 +1,34 @@
|
|||||||
#jinja2:lstrip_blocks: True
|
#jinja2:lstrip_blocks: True
|
||||||
{{ ansible_managed | comment }}
|
{{ ansible_managed | comment }}
|
||||||
version: '2'
|
version: "2.4"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
droneserver:
|
droneci:
|
||||||
container_name: {{ droneci_server_container_name }}
|
container_name: {{ droneci_container_name }}
|
||||||
image: {{ droneci_server_image }}
|
image: {{ droneci_image }}
|
||||||
|
restart: {{ droneci_restart_policy }}
|
||||||
|
{% if droneci_exposed_ports | default([]) %}
|
||||||
ports:
|
ports:
|
||||||
- {{ droneci_server_exposed_ip + ':' if droneci_server_exposed_ip is defined else '' }}{{ droneci_server_exposed_port }}:80
|
{% for port in droneci_exposed_ports %}
|
||||||
|
- {{ port | quote }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if droneci_volumes | default([]) %}
|
||||||
volumes:
|
volumes:
|
||||||
{% if droneci_db_type == "sqlite" %}
|
{% for volume in droneci_volumes %}
|
||||||
- droneserver-data:/var/lib/drone/
|
- "{{ volume.name }}:{{ volume.dest }}"
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if droneci_license_key is defined %}
|
{% if droneci_networks_applied | default([]) %}
|
||||||
- {{ droneci_license_key }}:/etc/drone.key
|
networks:
|
||||||
|
{% for network in droneci_networks_applied %}
|
||||||
|
- {{ network }}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if droneci_server_extra_hosts | default([]) %}
|
{% if droneci_extra_hosts | default([]) %}
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
{% for host in droneci_server_extra_hosts %}
|
{% for host in droneci_extra_hosts %}
|
||||||
- {{ '"' + host + '"' }}
|
- {{ host | quote }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
privileged: true
|
privileged: true
|
||||||
@ -27,7 +37,7 @@ services:
|
|||||||
- DRONE_SERVER_PROTO={{ droneci_host | urlsplit('scheme') }}
|
- DRONE_SERVER_PROTO={{ droneci_host | urlsplit('scheme') }}
|
||||||
- DRONE_AGENTS_ENABLED=true
|
- DRONE_AGENTS_ENABLED=true
|
||||||
- DRONE_RPC_SECRET={{ droneci_secret }}
|
- DRONE_RPC_SECRET={{ droneci_secret }}
|
||||||
- DRONE_USER_CREATE=username:{{ droneci_admin }},admin:true
|
- DRONE_USER_CREATE=username:{{ droneci_admin_user }},admin:true
|
||||||
- DRONE_LOGS_COLOR=true
|
- DRONE_LOGS_COLOR=true
|
||||||
- DRONE_LOGS_PRETTY=true
|
- DRONE_LOGS_PRETTY=true
|
||||||
- DRONE_TLS_AUTOCERT=false
|
- DRONE_TLS_AUTOCERT=false
|
||||||
@ -53,36 +63,24 @@ services:
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
- NO_PROXY={{ droneci_no_proxy | join(',') }}
|
- NO_PROXY={{ droneci_no_proxy | join(',') }}
|
||||||
- no_proxy={{ droneci_no_proxy | join(',') }}
|
- no_proxy={{ droneci_no_proxy | join(',') }}
|
||||||
{% if droneci_server_memory_limit is defined %}
|
{% if droneci_memory_limit is defined %}
|
||||||
mem_limit: {{ droneci_server_memory_limit }}
|
mem_limit: {{ droneci_memory_limit }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if droneci_server_memory_reservation is defined %}
|
{% if droneci_memory_reservation is defined %}
|
||||||
mem_reservation: {{ droneci_server_memory_reservation }}
|
mem_reservation: {{ droneci_memory_reservation }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if droneci_volumes | default([]) | rejectattr("bind") | list | length > 0 %}
|
||||||
|
|
||||||
droneagent:
|
|
||||||
container_name: {{ droneci_agent_container_name }}
|
|
||||||
image: {{ droneci_agent_image }}
|
|
||||||
depends_on:
|
|
||||||
- droneserver
|
|
||||||
volumes:
|
|
||||||
- {{ droneci_docker_socket_path }}:/var/run/docker.sock
|
|
||||||
privileged: true
|
|
||||||
environment:
|
|
||||||
- DRONE_RPC_PROTO=http
|
|
||||||
- DRONE_RPC_HOST=droneserver
|
|
||||||
- DRONE_RPC_SECRET={{ droneci_secret }}
|
|
||||||
- DRONE_RUNNER_CAPACITY={{ droneci_agent_capacity }}
|
|
||||||
# TODO: temp static value, needs to be replaced by a custom fact
|
|
||||||
- DOCKER_API_VERSION=1.26
|
|
||||||
{% if droneci_agent_memory_limit is defined %}
|
|
||||||
mem_limit: {{ droneci_agent_memory_limit }}
|
|
||||||
{% endif %}
|
|
||||||
{% if droneci_agent_memory_reservation is defined %}
|
|
||||||
mem_reservation: {{ droneci_agent_memory_reservation }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if droneci_db_type == "sqlite" %}
|
|
||||||
volumes:
|
volumes:
|
||||||
droneserver-data:
|
{% for volume in droneci_volumes | rejectattr("bind") %}
|
||||||
|
{{ volume.name }}:
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if droneci_networks | default([]) | length > 0 %}
|
||||||
|
|
||||||
|
networks:
|
||||||
|
{% for network in droneci_networks %}
|
||||||
|
{{ network.name }}:
|
||||||
|
driver: {{ network.backend | default("bridge") }}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
__droneci_default_no_proxy:
|
|
||||||
- droneserver
|
|
||||||
- droneagent
|
|
Loading…
Reference in New Issue
Block a user