Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions roles/install_settings/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
ansible.builtin.set_fact:
clustergroup_opt: >-
{{
"" if (target_clustergroup | default("") | trim == "")
else "--set main.clusterGroupName=%s" | format(target_clustergroup)
"--set main.clusterGroupName=%s --set main.variant=null" | format(target_variant) if (_target_clustergroup_override | default("") | trim != "")
else "--set main.variant=%s --set main.clusterGroupName=null" | format(target_variant) if (_target_variant_override | default("") | trim != "")
else ""
}}

- name: Build include_crds_opt
Expand Down
33 changes: 30 additions & 3 deletions roles/install_settings/tasks/resolve_overrides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,43 @@
Alternatively, pass the remote explicitly via the 'target_origin' variable
or 'TARGET_ORIGIN' environment variable.

- name: Resolve target_clustergroup
- name: Resolve TARGET_CLUSTERGROUP override
ansible.builtin.set_fact:
target_clustergroup: >-
_target_clustergroup_override: >-
{{
target_clustergroup
| default(lookup("env", "TARGET_CLUSTERGROUP"), true)
| default(main_clustergroup, true)
| default("", true)
| trim
}}

- name: Resolve TARGET_VARIANT override
ansible.builtin.set_fact:
_target_variant_override: >-
{{
target_variant
| default(lookup("env", "TARGET_VARIANT"), true)
| default("", false)
| trim
}}

- name: Ensure TARGET_CLUSTERGROUP and TARGET_VARIANT are not both set
ansible.builtin.assert:
that: _target_clustergroup_override == "" or _target_variant_override == ""
fail_msg: |
Both target_clustergroup/TARGET_CLUSTERGROUP and target_variant/TARGET_VARIANT are set.
Please use only one of these to specify the cluster group name.

- name: Resolve target_variant
ansible.builtin.set_fact:
target_variant: >-
{{
(_target_clustergroup_override if _target_clustergroup_override != ""
else _target_variant_override if _target_variant_override != ""
else main_variant)
| trim
}}

- name: Resolve token_secret
ansible.builtin.set_fact:
token_secret: >-
Expand Down
20 changes: 14 additions & 6 deletions roles/pattern_settings/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
| default((values_global.global.pattern | string | trim), true)
}}

- name: Ensure main.clusterGroupName is set
- name: Set helper booleans for main.clusterGroupName and main.variant
ansible.builtin.set_fact:
_has_clustergroupname: "{{ (values_global.main.clusterGroupName | default('') | string | trim) != '' }}"
_has_variant: "{{ (values_global.main.variant | default('') | string | trim) != '' }}"

- name: Ensure exactly one of main.clusterGroupName or main.variant is set
ansible.builtin.assert:
that: (values_global.main.clusterGroupName | default('') | string | trim) != ""
that:
- _has_clustergroupname or _has_variant
- not (_has_clustergroupname and _has_variant)
fail_msg: |
values-global.yaml does not define .main.clusterGroupName.
Please set a value for clusterGroupName under the 'main' key.
values-global.yaml must define exactly one of .main.clusterGroupName or .main.variant (not both).
Please set one of these values under the 'main' key.

- name: Set fact for main clustergroup
- name: Set fact for main variant
ansible.builtin.set_fact:
main_clustergroup: "{{ values_global.main.clusterGroupName | string | trim }}"
main_variant: >-
{{ (values_global.main.clusterGroupName if _has_clustergroupname else values_global.main.variant) | string | trim }}
4 changes: 2 additions & 2 deletions roles/validate_prereq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

- name: Get length of target clustergroup
ansible.builtin.set_fact:
_clustergroup_name_len: "{{ target_clustergroup | length }}"
_clustergroup_name_len: "{{ target_variant | length }}"

- name: Ensure ArgoCD will have valid DNS hostname based on pattern name and clustergroup lengths
ansible.builtin.assert:
Expand All @@ -17,7 +17,7 @@
-> {%raw%}{{ .Values.clusterGroup.name }}-gitops-server-{{ .Values.global.pattern }}-{{ .Values.clusterGroup.name }}{%endraw%}
To stay under the 63-character DNS limit, the variable part of the name must be less than 47 characters:
(2 * length of 'clusterGroup.name') + length of 'global.pattern' < 47
With your current values this DNS part is '{{ target_clustergroup }}-gitops-server-{{ pattern_name }}-{{ target_clustergroup }}' and exceeds the 63 character limit.
With your current values this DNS part is '{{ target_variant }}-gitops-server-{{ pattern_name }}-{{ target_variant }}' and exceeds the 63 character limit.

- name: Ensure kubernetes python module is installed
ansible.builtin.pip:
Expand Down