From e579edc7583cd3272db8932ce2e33db4a174ca0b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 5 Sep 2020 16:24:47 +0100 Subject: [PATCH] Use lsyncd to push files to gitlab pages server Server itself in future commit --- ansible/roles/gitlab/files/docker-compose.yml | 14 ++++++++++++++ ansible/roles/gitlab/files/gitlab.rb | 6 ++++++ ansible/roles/gitlab/files/lsyncd.lua | 19 +++++++++++++++++++ ansible/roles/gitlab/tasks/main.yml | 9 +++++++++ 4 files changed, 48 insertions(+) create mode 100644 ansible/roles/gitlab/files/lsyncd.lua diff --git a/ansible/roles/gitlab/files/docker-compose.yml b/ansible/roles/gitlab/files/docker-compose.yml index 78f12b4..a9ccfbe 100644 --- a/ansible/roles/gitlab/files/docker-compose.yml +++ b/ansible/roles/gitlab/files/docker-compose.yml @@ -14,6 +14,7 @@ services: volumes: - /mnt/tank/app-data/gitlab/config:/etc/gitlab - /mnt/tank/app-data/gitlab/data:/var/opt/gitlab + - /mnt/tank/app-data/gitlab/pages:/mnt/pages tmpfs: - /var/log/gitlab restart: unless-stopped @@ -45,3 +46,16 @@ services: restart: unless-stopped volumes: - /mnt/tank/dbs/redis/gitlab:/data + + lsyncd: + image: theorangeone/lsyncd:latest + environment: + - PUID=998 + - PGID=998 + restart: unless-stopped + volumes: + - /mnt/tank/app-data/gitlab/pages:/mnt/pages:ro + - /mnt/tank/app-data/gitlab/lsyncd/lsyncd.lua:/config/lsyncd.lua:ro + - /mnt/tank/app-data/gitlab/lsyncd/id_ed25519.pub:/config/.ssh/id_ed25519.pub + - /mnt/tank/app-data/gitlab/lsyncd/id_ed25519:/config/.ssh/id_ed25519 + - /mnt/tank/app-data/gitlab/lsyncd/known_hosts:/config/.ssh/known_hosts diff --git a/ansible/roles/gitlab/files/gitlab.rb b/ansible/roles/gitlab/files/gitlab.rb index 37f8751..eb90db2 100644 --- a/ansible/roles/gitlab/files/gitlab.rb +++ b/ansible/roles/gitlab/files/gitlab.rb @@ -28,3 +28,9 @@ gitlab_rails['gitlab_default_theme'] = 2 nginx['real_ip_trusted_addresses'] = ['0.0.0.0/0'] nginx['real_ip_header'] = 'X-Forwarded-For' + +gitlab_pages['enable'] = false +pages_external_url "https://pages.theorangeone.net" +pages_nginx['enable'] = false +gitlab_rails['pages_path'] = "/mnt/pages" +gitlab_pages['external_http'] = ['0.0.0.0:8808'] diff --git a/ansible/roles/gitlab/files/lsyncd.lua b/ansible/roles/gitlab/files/lsyncd.lua new file mode 100644 index 0000000..1985c07 --- /dev/null +++ b/ansible/roles/gitlab/files/lsyncd.lua @@ -0,0 +1,19 @@ +settings { + logfile = "/tmp/lsyncd.log", + statusFile = "/tmp/lsyncd.status", +} + +sync { + default.rsyncssh, + source = "/mnt/pages", + host = "user@{{ wireguard.clients.walker.ip }}", + targetdir = "/config/pages", + delay = 10, + rsync = { + archive = true, + compress = true + }, + ssh = { + port = 8222 + } +} diff --git a/ansible/roles/gitlab/tasks/main.yml b/ansible/roles/gitlab/tasks/main.yml index f47c5ea..fe8228d 100644 --- a/ansible/roles/gitlab/tasks/main.yml +++ b/ansible/roles/gitlab/tasks/main.yml @@ -15,3 +15,12 @@ validate: /usr/bin/docker-compose -f %s config notify: restart gitlab become: true + +- name: Install lsyncd config + template: + src: files/lsyncd.lua + dest: /mnt/tank/app-data/gitlab/lsyncd/lsyncd.lua + mode: "{{ docker_compose_file_mask }}" + owner: "998" + notify: restart gitlab + become: true