|
| 1 | +--- |
| 2 | + |
| 3 | +# ---- git clone & git checkout ---- |
| 4 | + |
| 5 | +- name: Clone gitlab-shell source code |
| 6 | + git: repo={{ gitlab_source_address + gitlab_source_repository.shell }} |
| 7 | + dest={{ gitlab_sources + '/' + gitlab_source_repository.shell }} |
| 8 | + version={{ gitlab_version_map[gitlab_version].shell }} |
| 9 | + bare=yes update=yes |
| 10 | + sudo_user: '{{ gitlab_user }}' |
| 11 | + register: gitlab_register_shell_source |
| 12 | + |
| 13 | +- name: Check if gitlab-shell is checked out |
| 14 | + stat: path={{ gitlab_home }}/gitlab-shell |
| 15 | + register: gitlab_register_shell_directory |
| 16 | + |
| 17 | +- name: Create gitlab-shell directory |
| 18 | + file: path={{ gitlab_home }}/gitlab-shell state=directory |
| 19 | + owner={{ gitlab_user }} group={{ gitlab_group }} mode=0755 |
| 20 | + when: (gitlab_register_shell_source is defined and gitlab_register_shell_source.changed == True) or |
| 21 | + (gitlab_register_shell_directory is defined and gitlab_register_shell_directory.stat.exists == False) |
| 22 | + |
| 23 | +- name: Prepare gitlab-shell worktree |
| 24 | + template: src=srv/users/git/gitlab-shell/git.j2 dest={{ gitlab_home }}/gitlab-shell/.git |
| 25 | + owner={{ gitlab_user }} group={{ gitlab_group }} mode=0644 |
| 26 | + when: (gitlab_register_shell_source is defined and gitlab_register_shell_source.changed == True) or |
| 27 | + (gitlab_register_shell_directory is defined and gitlab_register_shell_directory.stat.exists == False) |
| 28 | + |
| 29 | +- name: Checkout gitlab-shell |
| 30 | + shell: GIT_WORK_TREE={{ gitlab_home }}/gitlab-shell git checkout -f {{ gitlab_version_map[gitlab_version].shell }} |
| 31 | + chdir={{ gitlab_sources + '/' + gitlab_source_repository.shell }} |
| 32 | + sudo_user: '{{ gitlab_user }}' |
| 33 | + register: gitlab_register_shell_checkout |
| 34 | + when: (gitlab_register_shell_source is defined and gitlab_register_shell_source.changed == True) or |
| 35 | + (gitlab_register_shell_directory is defined and gitlab_register_shell_directory.stat.exists == False) |
| 36 | + |
| 37 | + |
| 38 | +# ---- gitlab-shell/config.yml ---- |
| 39 | + |
| 40 | +- name: Check gitlab-shell configuration for changes |
| 41 | + shell: sha1sum {{ gitlab_home }}/gitlab-shell/config.yml.example | cut -d" " -f1 |
| 42 | + register: gitlab_register_shell_config_checksum |
| 43 | + when: gitlab_register_shell_checkout is defined and gitlab_register_shell_checkout.changed == True |
| 44 | + |
| 45 | +- name: Fail if gitlab-shell configuration changed |
| 46 | + fail: msg="gitlab-shell configuration changed, check it and update checksum" |
| 47 | + when: (gitlab_register_shell_checkout is defined and gitlab_register_shell_checkout.changed == True) and |
| 48 | + (gitlab_register_shell_config_checksum.stdout != gitlab_checksums.shell[gitlab_version_map[gitlab_version].shell].config) |
| 49 | + |
| 50 | +- name: Configure gitlab-shell |
| 51 | + template: src=srv/users/git/gitlab-shell/{{ gitlab_config_map[gitlab_version].shell }}/config.yml.j2 |
| 52 | + dest={{ gitlab_home }}/gitlab-shell/config.yml |
| 53 | + owner={{ gitlab_user }} group={{ gitlab_group }} mode=0644 |
| 54 | + when: gitlab_register_shell_checkout is defined and gitlab_register_shell_checkout.changed == True |
| 55 | + |
| 56 | + |
| 57 | +# ---- Setup ---- |
| 58 | + |
| 59 | +- name: Setup gitlab-shell |
| 60 | + shell: ./bin/install chdir={{ gitlab_home }}/gitlab-shell |
| 61 | + sudo_user: '{{ gitlab_user }}' |
| 62 | + when: gitlab_register_shell_checkout is defined and gitlab_register_shell_checkout.changed == True |
| 63 | + |
| 64 | +- name: Add GitLab host to SSH known hosts |
| 65 | + shell: ssh-keyscan -t rsa,ecdsa -H {{ gitlab_domain }} > {{ gitlab_home }}/.ssh/known_hosts |
| 66 | + sudo_user: '{{ gitlab_user }}' |
| 67 | + when: gitlab_register_shell_checkout is defined and gitlab_register_shell_checkout.changed == True |
| 68 | + |
0 commit comments