Add conditional to K3s installation;Populate Gitea #2
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
20ce62fb6d
commit
b6ac086a31
@ -1,3 +1,9 @@
|
|||||||
|
- block:
|
||||||
|
|
||||||
|
- name: Gather service facts
|
||||||
|
ansible.builtin.service_facts:
|
||||||
|
# Module requires no attributes
|
||||||
|
|
||||||
- name: Install K3s
|
- name: Install K3s
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: ./install.sh
|
cmd: ./install.sh
|
||||||
@ -5,10 +11,7 @@
|
|||||||
environment:
|
environment:
|
||||||
INSTALL_K3S_SKIP_DOWNLOAD: 'true'
|
INSTALL_K3S_SKIP_DOWNLOAD: 'true'
|
||||||
INSTALL_K3S_EXEC: 'server --cluster-init --disable local-storage'
|
INSTALL_K3S_EXEC: 'server --cluster-init --disable local-storage'
|
||||||
|
when: ansible_facts.services['k3s.service'] is undefined
|
||||||
- name: Install kubectl tab-completion
|
|
||||||
ansible.builtin.shell:
|
|
||||||
cmd: kubectl completion bash | tee /etc/bash_completion.d/kubectl
|
|
||||||
|
|
||||||
- name: Ensure API availability
|
- name: Ensure API availability
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
@ -21,6 +24,10 @@
|
|||||||
retries: 3
|
retries: 3
|
||||||
delay: 30
|
delay: 30
|
||||||
|
|
||||||
|
- name: Install kubectl tab-completion
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: kubectl completion bash | tee /etc/bash_completion.d/kubectl
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: Initialize tempfile
|
- name: Initialize tempfile
|
||||||
@ -61,6 +68,7 @@
|
|||||||
line: "{{ vapp['guestinfo.ipaddress'] }} {{ item + '.' + vapp['metacluster.fqdn'] }}"
|
line: "{{ vapp['guestinfo.ipaddress'] }} {{ item + '.' + vapp['metacluster.fqdn'] }}"
|
||||||
state: present
|
state: present
|
||||||
loop:
|
loop:
|
||||||
|
# TODO: Make this list dynamic
|
||||||
- git
|
- git
|
||||||
- gitops
|
- gitops
|
||||||
- registry
|
- registry
|
||||||
@ -113,6 +121,13 @@
|
|||||||
dest: /etc/rancher/k3s/registries.yaml
|
dest: /etc/rancher/k3s/registries.yaml
|
||||||
src: registries.j2
|
src: registries.j2
|
||||||
|
|
||||||
|
- block:
|
||||||
|
module_defaults:
|
||||||
|
ansible.builtin.uri:
|
||||||
|
validate_certs: no
|
||||||
|
status_code: [200, 201]
|
||||||
|
body_format: json
|
||||||
|
|
||||||
- name: Install gitea chart
|
- name: Install gitea chart
|
||||||
kubernetes.core.helm:
|
kubernetes.core.helm:
|
||||||
name: gitea
|
name: gitea
|
||||||
@ -123,8 +138,6 @@
|
|||||||
kubeconfig: "{{ kubeconfig.path }}"
|
kubeconfig: "{{ kubeconfig.path }}"
|
||||||
values: "{{ components.gitea.chart_values }}"
|
values: "{{ components.gitea.chart_values }}"
|
||||||
|
|
||||||
- block:
|
|
||||||
|
|
||||||
- name: Ensure gitea API availability
|
- name: Ensure gitea API availability
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
# Available from Gitea 1.17.x
|
# Available from Gitea 1.17.x
|
||||||
@ -140,7 +153,60 @@
|
|||||||
|
|
||||||
- name: Generate gitea API token
|
- name: Generate gitea API token
|
||||||
ansible.builtin.uri:
|
ansible.builtin.uri:
|
||||||
url: https://git.{{ vapp['metacluster.fqdn']}}
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/users/administrator/tokens
|
||||||
|
method: POST
|
||||||
|
user: administrator
|
||||||
|
password: "{{ vapp['guestinfo.rootpw'] }}"
|
||||||
|
force_basic_auth: yes
|
||||||
|
body:
|
||||||
|
name: token_init_{{ lookup('password', '/dev/null length=5 chars=ascii_letters,digits') }}
|
||||||
|
register: api_token
|
||||||
|
|
||||||
|
- name: Create organization(s)
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Authorization: token {{ api_token.json.sha1 }}
|
||||||
|
body: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- full_name: Meta-cluster
|
||||||
|
description: Meta-cluster configuration items
|
||||||
|
username: mc
|
||||||
|
website: https://git.{{ vapp['metacluster.fqdn'] }}/mc
|
||||||
|
location: '[...]'
|
||||||
|
visibility: public
|
||||||
|
- full_name: Workload-cluster
|
||||||
|
description: Workload-cluster configuration items
|
||||||
|
username: wl
|
||||||
|
website: https://git.{{ vapp['metacluster.fqdn'] }}/wl
|
||||||
|
location: '[...]'
|
||||||
|
visibility: public
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.full_name }}"
|
||||||
|
|
||||||
|
- name: Create repositories
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs/{{ item.organization }}/repos
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Authorization: token {{ api_token.json.sha1 }}
|
||||||
|
body: "{{ item.body }}"
|
||||||
|
loop:
|
||||||
|
- organization: mc
|
||||||
|
body:
|
||||||
|
name: ArgoCD.Config,
|
||||||
|
# auto_init: true
|
||||||
|
default_branch: main
|
||||||
|
description: GitOps manifests
|
||||||
|
- organization: wl
|
||||||
|
body:
|
||||||
|
name: Template.ArgoCD.Config,
|
||||||
|
# auto_init: true
|
||||||
|
default_branch: main
|
||||||
|
description: GitOps manifests
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.organization + '/' + item.body.name }}"
|
||||||
|
|
||||||
- name: Install argo-cd chart
|
- name: Install argo-cd chart
|
||||||
kubernetes.core.helm:
|
kubernetes.core.helm:
|
||||||
|
Loading…
Reference in New Issue
Block a user