Implemented working version of drone w/nginx https
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1 +1,2 @@
|
||||
.pass.sh filter=git-crypt diff=git-crypt
|
||||
ansible/vars/vault.yml filter=git-crypt diff=git-crypt
|
||||
|
||||
18
Makefile
18
Makefile
@@ -10,9 +10,12 @@ VENV_BIN=.venv/bin
|
||||
PIP=${VENV_BIN}/pip
|
||||
ANSIBLE=${VENV_BIN}/ansible-playbook
|
||||
ANSIBLE_VAULT=${VENV_BIN}/ansible-vault
|
||||
|
||||
LINT_ANSIBLE=${VENV_BIN}/ansible-lint
|
||||
LINT_YAML=${VENV_BIN}/yamllint
|
||||
|
||||
VAULT_PASS_FILE=.ansible-vaultpass
|
||||
VAULT_FILE=ansible/vars/vault.yml
|
||||
|
||||
# Variables
|
||||
ANSIBLE_INVENTORY=ansible/inventories/home/hosts.yml
|
||||
@@ -29,16 +32,19 @@ ${ANSIBLE} ${ANSIBLE_VAULT} ${LINT_YAML} ${LINT_ANSIBLE}: ${VENV} requirements.t
|
||||
${VAULT_PASS_FILE}: ${ANSIBLE}
|
||||
. ${PASS_SRC}; pass $$PASS_LOC > $@
|
||||
|
||||
${VAULT_FILE}: ${VAULT_PASS_FILE}
|
||||
${ANSIBLE_VAULT} create --vault-password-file ${VAULT_PASS_FILE} $@
|
||||
|
||||
# Targets
|
||||
deploy: ${ANSIBLE} ${VAULT_PASS_FILE}
|
||||
deploy: ${ANSIBLE} ${VAULT_FILE}
|
||||
${ANSIBLE} --diff --private-key ${SSH_KEY} -t ${TAGS} -i ${ANSIBLE_INVENTORY} --vault-password-file ${VAULT_PASS_FILE} ansible/deploy.yml
|
||||
|
||||
check: ${ANSIBLE} ${VAULT_PASS_FILE}
|
||||
check: ${ANSIBLE} ${VAULT_FILE}
|
||||
${ANSIBLE} --check --diff --private-key ${SSH_KEY} -t ${TAGS} -i ${ANSIBLE_INVENTORY} --vault-password-file ${VAULT_PASS_FILE} ansible/deploy.yml
|
||||
|
||||
encrypt-string: ${ANSIBLE_VAULT} ${VAULT_PASS_FILE}
|
||||
${ANSIBLE_VAULT} encrypt_string --vault-password-file ${VAULT_PASS_FILE}
|
||||
vault: ${ANSIBLE_VAULT} ${VAULT_FILE}
|
||||
${ANSIBLE_VAULT} edit --vault-password-file ${VAULT_PASS_FILE} ${VAULT_FILE}
|
||||
|
||||
lint: ${LINT_YAML} ${LINT_ANSIBLE}
|
||||
@${LINT_YAML} ansible/
|
||||
@${LINT_ANSIBLE} ansible/
|
||||
${LINT_YAML} ansible/
|
||||
${LINT_ANSIBLE} ansible/
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
---
|
||||
- hosts: all
|
||||
vars_files:
|
||||
- vars/vault.yml
|
||||
roles:
|
||||
- role: common
|
||||
- role: http
|
||||
- role: drone
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
---
|
||||
deps: [
|
||||
docker,
|
||||
fail2ban
|
||||
fail2ban,
|
||||
python-docker
|
||||
]
|
||||
|
||||
fail2ban_jails: [
|
||||
|
||||
3
ansible/roles/drone/defaults/main.yml
Normal file
3
ansible/roles/drone/defaults/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
drone_server_proto: "https"
|
||||
drone_runner_capacity: "1"
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
- name: Create Drone CI container
|
||||
community.general.docker_container:
|
||||
name: drone
|
||||
image: drone/drone
|
||||
restart: true
|
||||
restart_policy: on-failure
|
||||
restart_retries: 3
|
||||
env:
|
||||
DRONE_GITHUB_CLIENT_ID: {{ drone_gh_client_id }}
|
||||
DRONE_GITHUB_CLIENT_SECRET: {{ drone_gh_client_sec }}
|
||||
DRONE_RPC_SECRET: {{ drone_rpc_secret }}
|
||||
DRONE_SERVER_HOST: {{ ci_server_name }}
|
||||
DRONE_SERVER_PROTO: {{ drone_server_proto }}
|
||||
DRONE_GIT_ALWAYS_AUTH: 'true'
|
||||
DRONE_USER_FILTER: {{ drone_user_filter }}
|
||||
|
||||
43
ansible/roles/drone/tasks/drone.yml
Normal file
43
ansible/roles/drone/tasks/drone.yml
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
- name: create drone-ci server container
|
||||
diff: false
|
||||
docker_container:
|
||||
name: drone
|
||||
image: drone/drone:latest
|
||||
recreate: true
|
||||
restart: true
|
||||
restart_policy: on-failure
|
||||
restart_retries: 3
|
||||
env:
|
||||
DRONE_GITHUB_CLIENT_ID: "{{ drone_gh_client_id }}"
|
||||
DRONE_GITHUB_CLIENT_SECRET: "{{ drone_gh_client_sec }}"
|
||||
DRONE_GIT_ALWAYS_AUTH: 'true'
|
||||
DRONE_RPC_SECRET: "{{ drone_rpc_secret }}"
|
||||
DRONE_SERVER_HOST: "{{ ci_server_name }}"
|
||||
DRONE_SERVER_PROTO: "{{ drone_server_proto }}"
|
||||
DRONE_USER_FILTER: "{{ drone_user_filter }}"
|
||||
volumes:
|
||||
- /var/lib/drone:/data
|
||||
ports:
|
||||
- "8080:80"
|
||||
tags: drone
|
||||
|
||||
- name: create drone-ci worker container
|
||||
diff: false
|
||||
docker_container:
|
||||
name: drone-runner
|
||||
image: drone/drone-runner-docker:latest
|
||||
recreate: true
|
||||
restart: true
|
||||
restart_policy: on-failure
|
||||
restart_retries: 3
|
||||
env:
|
||||
DRONE_RPC_SECRET: "{{ drone_rpc_secret }}"
|
||||
DRONE_RPC_HOST: "{{ ci_server_name }}"
|
||||
DRONE_RPC_PROTO: "{{ drone_server_proto }}"
|
||||
DRONE_RUNNER_CAPACITY: "{{ drone_runner_capacity }}"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
ports:
|
||||
- "3000:3000"
|
||||
tags: drone
|
||||
@@ -1,2 +1,2 @@
|
||||
---
|
||||
- import_tasks: docker.yml
|
||||
- import_tasks: drone.yml
|
||||
|
||||
@@ -4,6 +4,5 @@ ci_server_name: ci.bdebyl.net
|
||||
|
||||
deps: [
|
||||
certbot,
|
||||
certbot-nginx,
|
||||
nginx
|
||||
]
|
||||
|
||||
@@ -32,5 +32,5 @@ http {
|
||||
|
||||
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
|
||||
|
||||
include etc/nginx/sites-enabled/*.conf;
|
||||
include /etc/nginx/sites-enabled/*.conf;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
---
|
||||
- cron: renew certbot ssl certificate weekly
|
||||
- name: renew certbot ssl certificates weekly
|
||||
become: true
|
||||
cron:
|
||||
name: ci_bdebyl_net_renewal
|
||||
name: certbot_renew
|
||||
special_time: weekly
|
||||
job: |
|
||||
certbot --renew certonly --webroot --webroot-path=/srv/http \
|
||||
-m {{ ci_server_email }} --agree-tos \
|
||||
-d {{ ci_server_name }}
|
||||
tags: never
|
||||
certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
|
||||
tags: cron
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
- import_tasks: deps.yml
|
||||
- import_tasks: http.yml
|
||||
- import_tasks: ssl.yml
|
||||
- import_tasks: cron.yml
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
upstream drone {
|
||||
server 127.0.0.1:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name {{ ci_server_name }};
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name {{ ci_server_name }};
|
||||
|
||||
add_header Strict-Transport-Security max-age=6307200;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/{{ ci_server_name }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ ci_server_name }}/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/{{ ci_server_name }}/fullchain.pem;
|
||||
ssl_certificate /etc/letsencrypt/live/{{ ci_server_name }}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/{{ ci_server_name }}/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/{{ ci_server_name }}/fullchain.pem;
|
||||
ssl_dhparam /etc/ssl/certs/dhparam.pem;
|
||||
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
location / {
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_post;
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
proxy_pass http://127.0.0.1:4242;
|
||||
proxy_pass http://drone;
|
||||
proxy_redirect off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
|
||||
chunked_transfer_encoding off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
ansible/vars/vault.yml
Normal file
BIN
ansible/vars/vault.yml
Normal file
Binary file not shown.
Reference in New Issue
Block a user