From 62660c8d6cfad4eebd070284a4c59b3885b7b17e Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Sat, 7 Jan 2023 11:58:58 +0100 Subject: [PATCH] Switch tty message to systemd service;Add missing kubeconfig;Refactor tty script --- .../roles/cleanup/tasks/service.yml | 8 ++++-- .../ansible_payload/roles/tty/tasks/main.yml | 28 ++++++++++++------- .../workloadcluster/tasks/clusterapi.yml | 5 +++- .../files/ansible_payload/templates/tty.j2 | 11 ++++++-- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/service.yml b/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/service.yml index 05c61ab..acba5a7 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/service.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/cleanup/tasks/service.yml @@ -20,7 +20,11 @@ loop_control: label: "{{ item.src }}" -- name: Enable tarball compression service +- name: Enable/Start services ansible.builtin.systemd: - name: compressTarballs + name: "{{ item }}" enabled: yes + state: started + loop: + - compressTarballs + - ttyConsoleMessage diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/tty/tasks/main.yml b/ansible/roles/firstboot/files/ansible_payload/roles/tty/tasks/main.yml index 24a1f4a..cca4d18 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/tty/tasks/main.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/tty/tasks/main.yml @@ -5,16 +5,24 @@ loop: - /opt/firstboot -- name: Save tty script file +- name: Create tty console message service ansible.builtin.template: - src: tty.j2 - dest: /opt/firstboot/tty.sh + src: "{{ item.src }}" + dest: "{{ item.dest }}" owner: root group: root - mode: 0700 - -- name: Create @reboot crontab job - ansible.builtin.cron: - name: tty.consolemessage - special_time: reboot - job: /opt/firstboot/tty.sh + mode: "{{ item.mode | default(omit) }}" + vars: + _template: + service: + name: ttyConsoleMessage + executable: /opt/firstboot/tty.sh + workingdir: /tmp/ + loop: + - src: tty.j2 + dest: "{{ _template.service.executable }}" + mode: o+x + - src: systemdunit.j2 + dest: /etc/systemd/system/{{ _template.service.name }}.service + loop_control: + label: "{{ item.src }}" diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml index b180474..032bc34 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml @@ -112,7 +112,10 @@ - name: Retrieve kubeconfig ansible.builtin.command: - cmd: clusterctl get kubeconfig {{ vapp['workloadcluster.name'] | lower }} + cmd: >- + clusterctl get kubeconfig \ + {{ vapp['workloadcluster.name'] | lower }} \ + --kubeconfig {{ kubeconfig.path }} register: capi_kubectl_config - name: Store kubeconfig in tempfile diff --git a/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 b/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 index b64dab7..b67e01e 100644 --- a/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 +++ b/ansible/roles/firstboot/files/ansible_payload/templates/tty.j2 @@ -17,11 +17,16 @@ COMPONENTS=('ca' 'storage' 'registry' 'git' 'gitops') FQDN='{{ vapp['metacluster.fqdn'] }}' IPADDRESS='{{ vapp['guestinfo.ipaddress'] }}' -# Waiting to allow boot sequence to finish; crude! -sleep 30 -clear > /dev/tty1 +I=10 while /bin/true; do + if [[ $I -lt 9 ]]; then + clear > /dev/tty1 + I=0 + else + I=$(( $I + 1 )) + fi + echo -e "${PRST}" > /dev/tty1 echo -e "\n\n\t${DFLT}To manage this appliance, please connect to one of the following:${LCLR}\n" > /dev/tty1