ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit a98a2ca3394b4a694d2bc3ebc8a692637b62f3e7
parent 0f5252790190f0eddbf79b95dc059b0437bdbf98
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:05:21 +0100

roles/gitolite: split tasks into multiple files
5 files changed, 85 insertions(+), 0 deletions(-)
A
roles/gitolite/meta/main.yml
|
4
++++
A
roles/gitolite/tasks/checks.yml
|
12
++++++++++++
A
roles/gitolite/tasks/configure.yml
|
38
++++++++++++++++++++++++++++++++++++++
A
roles/gitolite/tasks/install.yml
|
15
+++++++++++++++
A
roles/gitolite/tasks/remove.yml
|
16
++++++++++++++++
diff --git a/roles/gitolite/meta/main.yml b/roles/gitolite/meta/main.yml
@@ -0,0 +1,4 @@
+---
+
+dependencies:
+  - openssh
diff --git a/roles/gitolite/tasks/checks.yml b/roles/gitolite/tasks/checks.yml
@@ -0,0 +1,11 @@
+---
+
+- fail: msg="Gitolite depends on OpenSSH, which is not enabled!"
+  when:
+    - services.gitolite.enable is true
+    - services.openssh.enable is false
+
+- fail: msg="Option 'gitolite.initalKey' has to be defined!"
+  when:
+    - services.gitolite.enable is true
+    - services.gitolite.initialKey is not defined+
\ No newline at end of file
diff --git a/roles/gitolite/tasks/configure.yml b/roles/gitolite/tasks/configure.yml
@@ -0,0 +1,38 @@
+---
+
+- name: copy initial ssh-key to destination host
+  copy:
+    content: "{{ services.gitolite.initialKey }}"
+    dest: /var/lib/git/first-user-key.pub
+    owner: git
+    group: git
+
+- name: Initial setup of gitolite
+  become: yes
+  become_user: git
+  command:
+    cmd: gitolite setup -pk /var/lib/git/first-user-key.pub
+    creates: /var/lib/git/.gitolite
+
+- name: Delete first-user-key.pub
+  file:
+    path: /var/lib/git/first-user-key.pub
+    state: absent
+
+- name: Unlock the git user
+  ignore_errors: yes
+  command:
+    cmd: passwd -u git
+
+- name: fix gitolite.rc to set correct permissons
+  patch:
+    src: gitolite.rc.patch
+    dest: /var/lib/git/.gitolite.rc
+
+- name: set permissions for git dir
+  file:
+    path: /var/lib/git
+    state: directory  
+    mode: 0755
+    owner: git
+    group: git
diff --git a/roles/gitolite/tasks/install.yml b/roles/gitolite/tasks/install.yml
@@ -0,0 +1,15 @@
+---
+
+- name: "[Alpine] Install package: gitolite"
+  apk:
+    name: gitolite, git
+    state: present
+  when: 
+    - ansible_distribution == "Alpine" 
+
+- name: "[Archlinux] Install package: gitolite"
+  apk:
+    name: gitolite, git
+    state: present
+  when: 
+    - ansible_distribution == "Archlinux" 
diff --git a/roles/gitolite/tasks/remove.yml b/roles/gitolite/tasks/remove.yml
@@ -0,0 +1,15 @@
+---
+
+- name: "[Alpine] Remove package: gitolite"
+  apk:
+    name: gitolite
+    state: absent
+  when: 
+    - ansible_distribution == "Alpine"
+
+- name: "[Archlinux] Remove package: gitolite"
+  apk:
+    name: gitolite
+    state: absent
+  when: 
+    - ansible_distribution == "Archlinux"+
\ No newline at end of file