Skip to content

Commit

Permalink
BC-7854 - split Ansible Jobs by Tags (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamutmk5 authored Aug 19, 2024
1 parent b3e3d0c commit a438694
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ansible/roles/schulcloud-calendar-core/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
name: "pg-calendar-secret"
register: db_secret_present
when: WITH_BRANCH_POSTGRES_DB_MANAGEMENT is defined and WITH_BRANCH_POSTGRES_DB_MANAGEMENT
tags:
- 1password

- name: Create Secret for the database (if not existing)
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: secret-database.yml.j2
when: WITH_BRANCH_POSTGRES_DB_MANAGEMENT is defined and WITH_BRANCH_POSTGRES_DB_MANAGEMENT and db_secret_present.resources|length == 0
tags:
- 1password

- name: Create ConfigMap with database configuration script
kubernetes.core.k8s:
Expand All @@ -21,37 +25,49 @@
template: configmap-database-init.yml.j2
apply: yes
when: WITH_BRANCH_POSTGRES_DB_MANAGEMENT is defined and WITH_BRANCH_POSTGRES_DB_MANAGEMENT
tags:
- configmap

- name: Create/execute database configuration script
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: job-database-init.yml.j2
when: WITH_BRANCH_POSTGRES_DB_MANAGEMENT is defined and WITH_BRANCH_POSTGRES_DB_MANAGEMENT
tags:
- job

- name: Service
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: svc.yml.j2
tags:
- service

- name: Configmap
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: configmap.yml.j2
apply: yes
tags:
- configmap

- name: Secret by 1Password
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: onepassword.yml.j2
when: ONEPASSWORD_OPERATOR is defined and ONEPASSWORD_OPERATOR|bool
tags:
- 1password


- name: Deployment
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: deployment.yml.j2
tags:
- deployment
10 changes: 10 additions & 0 deletions ansible/roles/schulcloud-calendar-init/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
namespace: "{{ NAMESPACE }}"
template: configmap_file_init_db.yml.j2
when: WITH_CALENDAR_INIT
tags:
- configmap

- name: Calendar db init job config map
kubernetes.core.k8s:
Expand All @@ -14,6 +16,8 @@
kind: ConfigMap
name: calendar-db-init-file
when: not WITH_CALENDAR_INIT
tags:
- configmap

- name: Test if init job exists
kubernetes.core.k8s_info:
Expand All @@ -24,13 +28,17 @@
name: calendar-db-init-job
register: calendar_init_job_present
when: WITH_CALENDAR_INIT
tags:
- job

- name: Calendar db init job
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: job_init_db.yml.j2
when: WITH_CALENDAR_INIT and calendar_init_job_present.resources|length == 0
tags:
- job

- name: Calendar db init job
kubernetes.core.k8s:
Expand All @@ -41,3 +49,5 @@
kind: Job
name: calendar-db-init-job
when: not WITH_CALENDAR_INIT
tags:
- job

0 comments on commit a438694

Please sign in to comment.