Interact with argocd API
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Danny Bessems 2022-07-14 11:04:35 +02:00
parent 39cc83ac57
commit 81847d3b93
2 changed files with 43 additions and 13 deletions

View File

@ -155,14 +155,14 @@
force_basic_auth: yes force_basic_auth: yes
body: body:
name: token_init_{{ lookup('password', '/dev/null length=5 chars=ascii_letters,digits') }} name: token_init_{{ lookup('password', '/dev/null length=5 chars=ascii_letters,digits') }}
register: api_token register: gitea_api_token
- name: Create organization(s) - name: Create organization(s)
ansible.builtin.uri: ansible.builtin.uri:
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs
method: POST method: POST
headers: headers:
Authorization: token {{ api_token.json.sha1 }} Authorization: token {{ gitea_api_token.json.sha1 }}
body: "{{ item }}" body: "{{ item }}"
loop: loop:
- full_name: Meta-cluster - full_name: Meta-cluster
@ -185,7 +185,7 @@
url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs/{{ item.organization }}/repos url: https://git.{{ vapp['metacluster.fqdn'] }}/api/v1/orgs/{{ item.organization }}/repos
method: POST method: POST
headers: headers:
Authorization: token {{ api_token.json.sha1 }} Authorization: token {{ gitea_api_token.json.sha1 }}
body: "{{ item.body }}" body: "{{ item.body }}"
loop: loop:
- organization: mc - organization: mc
@ -209,15 +209,45 @@
status_code: [200, 201] status_code: [200, 201]
body_format: json body_format: json
- name: Install argo-cd chart - block:
kubernetes.core.helm:
name: argo-cd - name: Install argo-cd chart
chart_ref: /opt/metacluster/helm-charts/argo-cd kubernetes.core.helm:
release_namespace: argo-cd name: argo-cd
create_namespace: yes chart_ref: /opt/metacluster/helm-charts/argo-cd
wait: yes release_namespace: argo-cd
kubeconfig: "{{ kubeconfig.path }}" create_namespace: yes
values: "{{ components.argocd.chart_values }}" wait: yes
kubeconfig: "{{ kubeconfig.path }}"
values: "{{ components.argocd.chart_values }}"
- name: Ensure argo-cd API availability
ansible.utils.cli_parse:
command: curl -k https://gitops.{{ vapp['metacluster.fqdn'] }}/api/version
parser:
name: ansible.utils.json
set_fact: api_readycheck
ignore_errors:
until: api_readycheck.Version is defined
retries: 3
delay: 30
- name: Generate argo-cd API token
ansible.builtin.uri:
url: https://gitops.{{ vapp['metacluster.fqdn'] }}/api/v1/account/admin/token
method: POST
force_basic_auth: yes
body:
token: token_init_{{ lookup('password', '/dev/null length=5 chars=ascii_letters,digits') }}
username: admin
password: "{{ vapp['guestinfo.rootpw'] }}"
register: argocd_api_token
module_defaults:
ansible.builtin.uri:
validate_certs: no
status_code: [200, 201]
body_format: json
- name: Cleanup tempfile - name: Cleanup tempfile
ansible.builtin.file: ansible.builtin.file:

View File

@ -6,7 +6,7 @@ platform:
packaged_components: packaged_components:
- name: traefik - name: traefik
namespace: kube-system namespace: kube-system
config: |4 config: |2
ports: ports:
ssh: ssh:
port: 8022 port: 8022