From 94da91db8e384747d6bb141a368dfc3192485299 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 7 Feb 2020 13:49:13 +0000 Subject: [PATCH] Install yourls --- .../docker/files/yourls/docker-compose.yml | 35 +++++++++++++++++++ ansible/roles/docker/tasks/main.yml | 3 ++ ansible/roles/docker/tasks/yourls.yml | 34 ++++++++++++++++++ ansible/roles/docker/vars/yourls.yml | 12 +++++++ 4 files changed, 84 insertions(+) create mode 100644 ansible/roles/docker/files/yourls/docker-compose.yml create mode 100644 ansible/roles/docker/tasks/yourls.yml create mode 100644 ansible/roles/docker/vars/yourls.yml diff --git a/ansible/roles/docker/files/yourls/docker-compose.yml b/ansible/roles/docker/files/yourls/docker-compose.yml new file mode 100644 index 0000000..01e766e --- /dev/null +++ b/ansible/roles/docker/files/yourls/docker-compose.yml @@ -0,0 +1,35 @@ +version: "3" + +services: + yourls: + image: yourls:1.7.6-apache + container_name: yourls + restart: unless-stopped + depends_on: + - mysql + environment: + - YOURLS_DB_PASS=yourls + - YOURLS_DB_USER=yourls + - YOURLS_USER=jake + - YOURLS_PASS={{ yourls.user_password }} + - YOURLS_SITE=https://go.theorangeone.net + labels: + - "traefik.enable=true" + - "traefik.http.routers.yourls.rule=Host(`go.theorangeone.net`)" + - "traefik.http.routers.yourls.tls=true" + - "traefik.http.routers.yourls.tls.certresolver=le" + + + mysql: + image: linuxserver/mariadb:110.4.11mariabionic-ls47 + environment: + - PUID={{ docker_user.id }} + - PGID={{ docker_user.id }} + - MYSQL_ROOT_PASSWORD=root + - TZ=Europe/London + - MYSQL_DATABASE=yourls + - MYSQL_USER=yourls + - MYSQL_PASSWORD=yourls + volumes: + - ./mariadb:/config + restart: unless-stopped diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml index 457cf69..e0249c0 100644 --- a/ansible/roles/docker/tasks/main.yml +++ b/ansible/roles/docker/tasks/main.yml @@ -36,3 +36,6 @@ - name: Install gitea include: gitea.yml + +- name: Install yourls + include: yourls.yml diff --git a/ansible/roles/docker/tasks/yourls.yml b/ansible/roles/docker/tasks/yourls.yml new file mode 100644 index 0000000..92d1967 --- /dev/null +++ b/ansible/roles/docker/tasks/yourls.yml @@ -0,0 +1,34 @@ +- name: Include yourls variables + include_vars: yourls.yml + +- name: Create yourls directory + file: + path: '/opt/yourls' + state: directory + owner: "{{ docker_user.name }}" + mode: "{{ docker_compose_directory_mask }}" + become: true + become_user: root + +- name: Install yourls compose file + template: + src: files/yourls/docker-compose.yml + dest: "/opt/yourls/docker-compose.yml" + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + validate: /usr/bin/docker-compose -f %s config + register: compose_file + become: true + become_user: root + +- name: Cycle yourls container + docker_compose: + project_src: /opt/yourls + pull: true + remove_orphans: true + remove_volumes: true + state: "{{ item }}" + when: compose_file.changed + loop: + - absent + - present diff --git a/ansible/roles/docker/vars/yourls.yml b/ansible/roles/docker/vars/yourls.yml new file mode 100644 index 0000000..fc70dd6 --- /dev/null +++ b/ansible/roles/docker/vars/yourls.yml @@ -0,0 +1,12 @@ +yourls: + user_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 66613263376130663031363539633863343432323330396135633639613138343139333930643030 + 3131316364323235623237373435356635333230336463660a626266396133383261353264333536 + 32356634396631323961366537393063373032373538373733663564336163376634363766613337 + 6431373166323137300a643766303932353434393266393566663738633864313934623466613235 + 33653439313766633334393433376430393138636564383861306631353633653365366432616338 + 31626535646630376666386437393633336530343265656464653164356463346135383562363965 + 34303039363662643261306139373139646264613630623362613438333466356434636166636162 + 33636662353336373838336437346233343338383731316538323366653261363265643239653536 + 36326461396235353533653136626361363631363539363830623663386435313332