From 82a3c852638570c481a2732e57cd2c1eea42a1c8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 24 Jun 2020 16:27:13 +0100 Subject: [PATCH] Install `git-mirror` container This also moves the canonical home of this repo to my gitea instance! --- .../intersect-docker/files/gitea/docker-compose.yml | 10 ++++++++++ .../files/gitea/git-mirror-repositories.toml | 3 +++ ansible/roles/intersect-docker/tasks/gitea.yml | 11 ++++++++++- ansible/roles/intersect-docker/vars/gitea.yml | 8 ++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/intersect-docker/files/gitea/git-mirror-repositories.toml diff --git a/ansible/roles/intersect-docker/files/gitea/docker-compose.yml b/ansible/roles/intersect-docker/files/gitea/docker-compose.yml index 5610dee..0556a4d 100644 --- a/ansible/roles/intersect-docker/files/gitea/docker-compose.yml +++ b/ansible/roles/intersect-docker/files/gitea/docker-compose.yml @@ -44,3 +44,13 @@ services: - POSTGRES_DB=gitea - BACKUP_KEEP_MONTHS=1 - BACKUP_KEEP_WEEKS=1 + + git-mirror: + image: theorangeone/git-mirror:latest + restart: unless-stopped + volumes: + - ./repositories.toml:/app/repositories.toml + environment: + - GITHUB_TOKEN={{ gitea.git_mirror_github_token }} + depends_on: + - gitea diff --git a/ansible/roles/intersect-docker/files/gitea/git-mirror-repositories.toml b/ansible/roles/intersect-docker/files/gitea/git-mirror-repositories.toml new file mode 100644 index 0000000..b8748a1 --- /dev/null +++ b/ansible/roles/intersect-docker/files/gitea/git-mirror-repositories.toml @@ -0,0 +1,3 @@ +[[repository]] +source = "https://git.theorangeone.net/r/infrastructure" +destination = "https://$GITHUB_TOKEN@github.com/RealOrangeOne/infrastructure" diff --git a/ansible/roles/intersect-docker/tasks/gitea.yml b/ansible/roles/intersect-docker/tasks/gitea.yml index ee13f25..ed0f87d 100644 --- a/ansible/roles/intersect-docker/tasks/gitea.yml +++ b/ansible/roles/intersect-docker/tasks/gitea.yml @@ -35,6 +35,15 @@ register: gitea_config_file become: true +- name: Install git-mirror config file + template: + src: files/gitea/git-mirror-repositories.toml + dest: /opt/gitea/repositories.toml + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + register: git_mirror_config_file + become: true + - name: Cycle gitea container docker_compose: project_src: /opt/gitea @@ -42,7 +51,7 @@ remove_orphans: true remove_volumes: true state: "{{ item }}" - when: compose_file.changed or gitea_config_file.changed + when: compose_file.changed or gitea_config_file.changed or git_mirror_config_file.changed loop: - absent - present diff --git a/ansible/roles/intersect-docker/vars/gitea.yml b/ansible/roles/intersect-docker/vars/gitea.yml index a002232..b6c8653 100644 --- a/ansible/roles/intersect-docker/vars/gitea.yml +++ b/ansible/roles/intersect-docker/vars/gitea.yml @@ -36,3 +36,11 @@ gitea: 6431663036333331350a303332366162333862616534346161316531323039643762316365333865 35383235633166353930363034373235646466336530646463616661336361393835643533343534 3235316165373239633832316438303266343639356161303439 + git_mirror_github_token: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 65633837346566306438626237396538333164356539346565303862636638623664396664303430 + 3665646436373136313364613962383939633831663735650a366432393836366534336163626162 + 36616334376666376134363561386331376134393065353039356532356466646636626634306136 + 3930396265363130310a383430383461633036623136663738323063656664346233613837653933 + 39326639623466326436323135616337386362323065306466313032616166386536323131363730 + 3034666333393933313535313037326565393262623732306465