Fix var reference;Housekeeping;Improve UX

This commit is contained in:
Danny Bessems 2023-01-25 10:28:28 +01:00
parent dd802e0620
commit e21b11a37a
13 changed files with 37 additions and 28 deletions

View File

@ -83,4 +83,4 @@
# mode: 0600 # mode: 0600
# loop: "{{ lookup('ansible.builtin.dict', components) | map(attribute='value.manifests') | list | select('defined') | flatten }}" # loop: "{{ lookup('ansible.builtin.dict', components) | map(attribute='value.manifests') | list | select('defined') | flatten }}"
# loop_control: # loop_control:
# label: "{{ item.type + '/' + item.name }}" # label: "{{ item.type ~ '/' ~ item.name }}"

View File

@ -62,7 +62,7 @@
- key: root_ca.crt - key: root_ca.crt
value: "{{ stepca_cm_certs.resources[0].data['root_ca.crt'] | b64encode }}" value: "{{ stepca_cm_certs.resources[0].data['root_ca.crt'] | b64encode }}"
loop_control: loop_control:
label: "{{ item.kind + '/' + item.name + ' (' + item.namespace + ')' }}" label: "{{ item.kind ~ '/' ~ item.name ~ ' (' ~ item.namespace ~ ')' }}"
- name: Configure step-ca passthrough ingress - name: Configure step-ca passthrough ingress
ansible.builtin.template: ansible.builtin.template:

View File

@ -120,7 +120,7 @@
# default_branch: main # default_branch: main
description: GitOps manifests description: GitOps manifests
loop_control: loop_control:
label: "{{ item.organization + '/' + item.body.name }}" label: "{{ item.organization ~ '/' ~ item.body.name }}"
- name: Rebase/Push source gitops repository - name: Rebase/Push source gitops repository
ansible.builtin.shell: ansible.builtin.shell:

View File

@ -1,7 +1,7 @@
- name: Configure fallback name resolution - name: Configure fallback name resolution
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/hosts path: /etc/hosts
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 # TODO: Make this list dynamic

View File

@ -1,4 +1,7 @@
- block: - block:
# Below tasks circumvent usernames with `<domain>\<username>` format, which causes CAPV to
# incorrectly interpret the backslash (despite automatic escaping) as an escape sequence.
# `vcenter_session.user` will instead contain the username in `<username>@<domain>` format.
- name: Generate vCenter API token - name: Generate vCenter API token
ansible.builtin.uri: ansible.builtin.uri:
@ -13,7 +16,7 @@
url: https://{{ vapp['hv.fqdn'] }}/api/session url: https://{{ vapp['hv.fqdn'] }}/api/session
method: GET method: GET
headers: headers:
vmware-api-session-id: "{{ vcenter_api_token.json }}" vmware-api-session-id: "{{ vcenterapi_token.json }}"
register: vcenter_session register: vcenter_session
module_defaults: module_defaults:
@ -51,7 +54,7 @@
- name: Update image references to use local registry - name: Update image references to use local registry
ansible.builtin.replace: ansible.builtin.replace:
dest: "{{ item.root + '/' + item.path }}" dest: "{{ item.root ~ '/' ~ item.path }}"
regexp: '([ ]+image:[ "]+)(?!({{ _template.pattern }}|"{{ _template.pattern }}))' regexp: '([ ]+image:[ "]+)(?!({{ _template.pattern }}|"{{ _template.pattern }}))'
replace: '\1{{ _template.pattern }}' replace: '\1{{ _template.pattern }}'
vars: vars:
@ -82,7 +85,7 @@
- name: Store custom cluster-template - name: Store custom cluster-template
ansible.builtin.copy: ansible.builtin.copy:
dest: /opt/metacluster/cluster-api/custom-cluster-template.yaml dest: /opt/metacluster/cluster-api/custom-cluster-template.yaml
content: "{{ lookup('kubernetes.core.kustomize', dir='/opt/metacluster/cluster-api/infrastructure-vsphere/' + components.clusterapi.management.version.infrastructure_vsphere ) }}" content: "{{ lookup('kubernetes.core.kustomize', dir='/opt/metacluster/cluster-api/infrastructure-vsphere/' ~ components.clusterapi.management.version.infrastructure_vsphere ) }}"
- name: Initialize Cluster API management cluster - name: Initialize Cluster API management cluster
ansible.builtin.shell: ansible.builtin.shell:

View File

@ -68,7 +68,7 @@
--portgroup "{{ vcenter_info.network }}" \ --portgroup "{{ vcenter_info.network }}" \
--startaddress {{ vapp['ippool.startip'] }} \ --startaddress {{ vapp['ippool.startip'] }} \
--endaddress {{ vapp['ippool.endip'] }} \ --endaddress {{ vapp['ippool.endip'] }} \
--netmask {{ (vapp['guestinfo.ipaddress'] + '/' + vapp['guestinfo.prefixlength']) | ansible.utils.ipaddr('netmask') }} \ --netmask {{ (vapp['guestinfo.ipaddress'] ~ '/' ~ vapp['guestinfo.prefixlength']) | ansible.utils.ipaddr('netmask') }} \
{{ vapp['guestinfo.dnsserver'] | split(',') | map('trim') | map('regex_replace', '^', '--dnsserver ') | join(' ') }} \ {{ vapp['guestinfo.dnsserver'] | split(',') | map('trim') | map('regex_replace', '^', '--dnsserver ') | join(' ') }} \
--dnsdomain {{ vapp['metacluster.fqdn'] }} \ --dnsdomain {{ vapp['metacluster.fqdn'] }} \
--gateway {{ vapp['guestinfo.gateway'] }} \ --gateway {{ vapp['guestinfo.gateway'] }} \

View File

@ -5,7 +5,7 @@
url: https://registry.{{ vapp['metacluster.fqdn'] }}/api/v2.0/projects url: https://registry.{{ vapp['metacluster.fqdn'] }}/api/v2.0/projects
method: POST method: POST
headers: headers:
Authorization: "Basic {{ ('admin:' + vapp['metacluster.password']) | b64encode }}" Authorization: "Basic {{ ('admin:' ~ vapp['metacluster.password']) | b64encode }}"
body: body:
project_name: kubeadm project_name: kubeadm
public: true public: true
@ -28,7 +28,7 @@
url: https://registry.{{ vapp['metacluster.fqdn'] }}/api/v2.0/projects/kubeadm/repositories/{{ ( item | regex_findall('([^:/]+)') )[-2] }}/artifacts?from=library/{{ item | replace('/', '%2F') | replace(':', '%3A') }} url: https://registry.{{ vapp['metacluster.fqdn'] }}/api/v2.0/projects/kubeadm/repositories/{{ ( item | regex_findall('([^:/]+)') )[-2] }}/artifacts?from=library/{{ item | replace('/', '%2F') | replace(':', '%3A') }}
method: POST method: POST
headers: headers:
Authorization: "Basic {{ ('admin:' + vapp['metacluster.password']) | b64encode }}" Authorization: "Basic {{ ('admin:' ~ vapp['metacluster.password']) | b64encode }}"
body: body:
from: "{{ item }}" from: "{{ item }}"
loop: "{{ kubeadm_images }}" loop: "{{ kubeadm_images }}"

View File

@ -25,7 +25,7 @@
line: 'PasswordAuthentication yes' line: 'PasswordAuthentication yes'
state: absent state: absent
loop_control: loop_control:
label: "{{ '[' + item.regex + '] ' + item.state }}" label: "{{ '[' ~ item.regex ~ '] ' ~ item.state }}"
- name: Create dedicated SSH keypair - name: Create dedicated SSH keypair
community.crypto.openssh_keypair: community.crypto.openssh_keypair:

View File

@ -17,7 +17,7 @@ COMPONENTS=('storage' 'registry' 'git' 'gitops')
FQDN='{{ _template.metacluster.fqdn }}' FQDN='{{ _template.metacluster.fqdn }}'
IPADDRESS='{{ _template.metacluster.vip }}' IPADDRESS='{{ _template.metacluster.vip }}'
I=60 I=0
while /bin/true; do while /bin/true; do
if [[ $I -gt 59 ]]; then if [[ $I -gt 59 ]]; then

View File

@ -1,7 +1,7 @@
- name: Configure fallback name resolution - name: Configure fallback name resolution
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/hosts path: /etc/hosts
line: "{{ vapp['metacluster.vip'] }} {{ item + '.' + vapp['metacluster.fqdn'] }}" line: "{{ vapp['metacluster.vip'] }} {{ item ~ '.' ~ vapp['metacluster.fqdn'] }}"
state: present state: present
loop: loop:
# TODO: Make this list dynamic # TODO: Make this list dynamic

View File

@ -1,4 +1,10 @@
#!/bin/bash #!/bin/bash
# Workaround for ansible output regression
export PYTHONUNBUFFERED=1
# Apply firstboot configuration w/ ansible # Apply firstboot configuration w/ ansible
/usr/local/bin/ansible-playbook -e "PYTHONUNBUFFERED=1" /opt/firstboot/ansible/playbook.yml | tee -a /var/log/firstboot.log > /dev/tty1 2>&1 /usr/local/bin/ansible-playbook /opt/firstboot/ansible/playbook.yml | tee -a /var/log/firstboot.log > /dev/tty1 2>&1
# Cleanup console
clear > /dev/tty1

View File

@ -106,13 +106,13 @@ PropertyCategories:
Configurations: '*' Configurations: '*'
UserConfigurable: true UserConfigurable: true
- Key: guestinfo.ntpserver # - Key: guestinfo.ntpserver
Type: string(1..) # Type: string(1..)
Label: Time server* # Label: Time server*
Description: A comma-separated list of timeservers # Description: A comma-separated list of timeservers
DefaultValue: 0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org # DefaultValue: 0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org
Configurations: '*' # Configurations: '*'
UserConfigurable: true # UserConfigurable: true
- Name: 3) Workload-cluster - Name: 3) Workload-cluster
ProductProperties: ProductProperties:

View File

@ -87,13 +87,13 @@ PropertyCategories:
Configurations: '*' Configurations: '*'
UserConfigurable: true UserConfigurable: true
- Key: guestinfo.ntpserver # - Key: guestinfo.ntpserver
Type: string(1..) # Type: string(1..)
Label: Time server* # Label: Time server*
Description: A comma-separated list of timeservers # Description: A comma-separated list of timeservers
DefaultValue: 0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org # DefaultValue: 0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org
Configurations: '*' # Configurations: '*'
UserConfigurable: true # UserConfigurable: true
- Name: 3) Common - Name: 3) Common
ProductProperties: ProductProperties: