-
Notifications
You must be signed in to change notification settings - Fork 1
/
gitea.yml
112 lines (101 loc) · 3.82 KB
/
gitea.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
- name: "Deploy Gitea"
hosts: all
vars_files:
- vars.local.yml
vars:
# one of letsencrypt-staging or letsencrypt-prod
kubernetes_spices_certm_issuer: letsencrypt-prod
# one of gcp or azure
acme_dns_resolver_provider: gcp
roles:
- name: kameshsampath.kubernetes_spices.gitea
- name: certm
vars:
kubernetes_spices_cert_manager_k8s_context: "mgmt"
kubernetes_spices_certm_issuer_namespace: gitea
kubernetes_spices_acme_dns_zone: kameshs.dev
tasks:
- name: Create gitea wildcard certificate
kubernetes.core.k8s:
context: "{{ kubernetes_spices_cert_manager_k8s_context }}"
state: present
namespace: gitea
template:
- path: "{{ playbook_dir }}/templates/certs/wildcard-cert.yaml.j2"
wait: yes
wait_condition:
reason: Ready
status: "True"
type: Ready
wait_sleep: 10
wait_timeout: 600
- name: "Query Git url"
kubernetes.core.k8s_info:
context: "{{ kubernetes_spices_cert_manager_k8s_context }}"
kind: Service
name: gateway-proxy
namespace: "{{ kubernetes_spices_gitea_namespace }}"
context: "{{ kubernetes_spices_gitea_k8s_context }}"
register: git_service_result
# - debug:
# var: github_template_repo
- name: "Set Gitea Hostname"
set_fact:
kubernetes_spices_gitea_host_name: "gitea.{{ kubernetes_spices_acme_dns_zone }}"
- name: "Set Gitea Service Facts"
set_fact:
git_url: "https://{{ kubernetes_spices_gitea_host_name }}"
- name: "Set Gitea Repo Facts"
set_fact:
kubernetes_spices_gitea_host_aliases:
- ip: "{{ git_service_result.resources[0] | json_query(q) | first }}"
hostnames:
- "{{ 'gitea.' + kubernetes_spices_acme_dns_zone }}"
vars:
q: "status.loadBalancer.ingress[*].ip"
- name: "Generate Gitea config"
ansible.builtin.template:
src: "{{ playbook_dir }}/templates/gitea/gitea-values.yaml.j2"
dest: "{{ work_dir }}/gitea-values.yaml"
- name: "Deploy Gitea"
kubernetes.core.helm:
release_name: gitea
chart_ref: gitea-charts/gitea
release_namespace: "{{ kubernetes_spices_gitea_namespace }}"
create_namespace: yes
chart_version: "{{ gitea_version }}"
values_files:
- "{{ work_dir }}/gitea-values.yaml"
update_repo_cache: yes
context: "{{ kubernetes_spices_gitea_k8s_context }}"
wait: yes
# Gitea external access
- name: "Create/Update Gitea Upstream and Route"
kubernetes.core.k8s:
template:
- path: "{{ playbook_dir }}/templates/gitea/gitea-upstream.yaml.j2"
- path: "{{ playbook_dir }}/templates/gitea/gitea-virtual-service.yaml.j2"
context: "{{ kubernetes_spices_gitea_k8s_context }}"
namespace: "{{ kubernetes_spices_gitea_namespace }}"
state: present
- name: "Dump Gitea Repo Details"
ansible.builtin.copy:
dest: "{{ work_dir }}/gitea_details.yaml"
mode: "u=rwx,g=rw,o="
content: |
gitea_url: {{ git_url }}
gitea_credentials: {{ gitea_admin_user }}
kubernetes_spices_gitea_host_aliases: {{ kubernetes_spices_gitea_host_aliases }}
- name: "Checking if .envrc file exists"
ansible.builtin.stat:
path: "{{ work_dir }}/.envrc"
register: st_envrc_file
- name: "Checking if .envrc file exists"
ansible.builtin.blockinfile:
path: "{{ work_dir }}/.envrc"
marker: "# {mark} ANSIBLE MANAGED BLOCK GITEA"
block: |
export GITEA_USERNAME="{{ gitea_admin_user.username }}"
export GITEA_PASSWORD="{{ gitea_admin_user.password }}"
export GITEA_URL="{{ git_url }}"
when: st_envrc_file.stat.exists