shared gitea checkouts
This commit is contained in:
1 parent
fffc009ab9
commit
26449924b8
6 files changed
+79
-34
No files matched your search
@@ -0,0 +1,2 @@
|
||||
gitea_ssh: gitea@git.hoekveen.net
|
||||
gitea_https: https://git.hoekveen.net
|
||||
@@ -37,7 +37,7 @@ fail2ban_ignoreip:
|
||||
- home.hoekveen.net
|
||||
|
||||
stroopwafel_dir: /opt/stroopwafel
|
||||
stroopwafel_repo: gitea@git.hoekveen.net:mark/stroopwafel.git
|
||||
stroopwafel_repo: mark/stroopwafel
|
||||
stroopwafel_version: master
|
||||
|
||||
backup_dump_dir: /var/backups/aurbis
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
remote_user: nerevar
|
||||
tasks:
|
||||
- import_tasks: tasks/scripts.yml
|
||||
tags: scripts
|
||||
- name: Setup zsh
|
||||
hosts: debian
|
||||
become: true
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# Shared checkout of a gitea repo: root seeds and fast-forwards it over anonymous
|
||||
# https, aurbis members push and pull over ssh with their own gitea key.
|
||||
- name: Create {{ checkout_repo }} directory
|
||||
file:
|
||||
path: "{{ checkout_dest }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: aurbis
|
||||
mode: "02775"
|
||||
- name: Seed {{ checkout_repo }}
|
||||
ansible.builtin.git:
|
||||
repo: "{{ gitea_https }}/{{ checkout_repo }}.git"
|
||||
dest: "{{ checkout_dest }}"
|
||||
version: "{{ checkout_version | default('master') }}"
|
||||
update: false
|
||||
force: false
|
||||
- name: Point {{ checkout_repo }} origin at git-over-ssh
|
||||
community.general.git_config:
|
||||
name: remote.origin.url
|
||||
scope: local
|
||||
repo: "{{ checkout_dest }}"
|
||||
value: "{{ gitea_ssh }}:{{ checkout_repo }}.git"
|
||||
- name: Have git keep {{ checkout_repo }} group-writable
|
||||
community.general.git_config:
|
||||
name: core.sharedRepository
|
||||
scope: local
|
||||
repo: "{{ checkout_dest }}"
|
||||
value: group
|
||||
- name: Add {{ checkout_repo }} to safe.directory
|
||||
community.general.git_config:
|
||||
name: safe.directory
|
||||
scope: system
|
||||
add_mode: add
|
||||
value: "{{ checkout_dest }}"
|
||||
# ff-only, so unpushed commits or conflicting edits on the host fail the run instead of being lost.
|
||||
- name: Fast-forward {{ checkout_repo }}
|
||||
ansible.builtin.shell:
|
||||
chdir: "{{ checkout_dest }}"
|
||||
cmd: |
|
||||
set -e
|
||||
umask 002
|
||||
before=$(git rev-parse HEAD)
|
||||
git fetch -q {{ gitea_https }}/{{ checkout_repo }}.git +refs/heads/{{ checkout_version | default('master') }}:refs/remotes/origin/{{ checkout_version | default('master') }}
|
||||
git merge -q --ff-only origin/{{ checkout_version | default('master') }}
|
||||
[ "$before" = "$(git rev-parse HEAD)" ] || echo updated
|
||||
register: checkout_pull
|
||||
changed_when: "'updated' in checkout_pull.stdout"
|
||||
when: checkout_update | default(true)
|
||||
- name: Give aurbis write access to {{ checkout_repo }}
|
||||
file:
|
||||
path: "{{ checkout_dest }}"
|
||||
state: directory
|
||||
recurse: true
|
||||
group: aurbis
|
||||
mode: g+rwX
|
||||
- name: Make {{ checkout_repo }} directories hand their group to new files
|
||||
ansible.builtin.command:
|
||||
cmd: "find {{ checkout_dest }} -type d ! -perm -g+s -print -exec chmod g+s {} +"
|
||||
register: checkout_setgid
|
||||
changed_when: checkout_setgid.stdout != ""
|
||||
+4
-15
@@ -1,15 +1,4 @@
|
||||
- name: Git clone
|
||||
ansible.builtin.git:
|
||||
repo: https://git.hoekveen.net/mark/scripts.git
|
||||
dest: /opt/scripts
|
||||
force: true
|
||||
- name: Set permissions and ownership for scripts folder
|
||||
file:
|
||||
path: /opt/scripts
|
||||
state: directory
|
||||
recurse: true
|
||||
group: aurbis
|
||||
mode: "0775"
|
||||
- name: Add scripts directory to safe.directory
|
||||
ansible.builtin.command:
|
||||
cmd: git config --system --add safe.directory /opt/scripts
|
||||
- import_tasks: gitea_checkout.yml
|
||||
vars:
|
||||
checkout_repo: mark/scripts
|
||||
checkout_dest: /opt/scripts
|
||||
+11
-18
@@ -1,31 +1,19 @@
|
||||
# Pulling needs to have git access; root does not.
|
||||
- name: Include stroopwafel vault
|
||||
include_vars:
|
||||
dir: stroopwafel
|
||||
files_matching: vault.yml
|
||||
- name: Create stroopwafel directory
|
||||
file:
|
||||
path: "{{ stroopwafel_dir }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: "{{ service_group | default('aurbis') }}"
|
||||
mode: "0775"
|
||||
- name: Check out stroopwafel source
|
||||
ansible.builtin.git:
|
||||
repo: "{{ stroopwafel_repo }}"
|
||||
dest: "{{ stroopwafel_dir }}"
|
||||
version: "{{ stroopwafel_version }}"
|
||||
update: "{{ stroopwafel_update | default(false) }}"
|
||||
accept_hostkey: true
|
||||
force: false
|
||||
become_user: "{{ stroopwafel_git_user | default(omit) }}"
|
||||
- import_tasks: gitea_checkout.yml
|
||||
vars:
|
||||
checkout_repo: "{{ stroopwafel_repo }}"
|
||||
checkout_dest: "{{ stroopwafel_dir }}"
|
||||
checkout_version: "{{ stroopwafel_version }}"
|
||||
- name: Deploy stroopwafel .env
|
||||
copy:
|
||||
content: "{{ stroopwafel_env_b64 | b64decode }}"
|
||||
dest: "{{ stroopwafel_dir }}/.env"
|
||||
owner: root
|
||||
group: "{{ service_group | default('aurbis') }}"
|
||||
mode: "0640"
|
||||
mode: "0660"
|
||||
when: stroopwafel_env_b64 is defined
|
||||
no_log: true
|
||||
- name: Copy docker-compose file
|
||||
@@ -39,3 +27,8 @@
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ stroopwafel_dir }}"
|
||||
build: policy
|
||||
- name: Restart stroopwafel on new code
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ stroopwafel_dir }}"
|
||||
state: restarted
|
||||
when: checkout_pull is changed
|
||||
Reference in new issue
Block a user