2 Commits

Author SHA1 Message Date
05f085aee7 feat: Preconfigure root profile for cli tools
All checks were successful
continuous-integration/drone/push Build is passing
2023-07-15 19:09:44 +02:00
072fc56050 fix: Refactor to make step-ca initialization idempotent 2023-07-15 19:08:33 +02:00
4 changed files with 33 additions and 30 deletions

View File

@ -1,14 +1,9 @@
- block:
- name: Initialize tempfile
ansible.builtin.tempfile:
state: file
register: values_file
- name: Write chart values w/ password to tempfile
- name: Inject password into values file
ansible.builtin.copy:
dest: "{{ values_file.path }}"
content: "{{ stepca_values.stdout | regex_replace('(ca_password|provisioner_password): ', '\\1: ' ~ (vapp['metacluster.password'] | b64encode)) }}"
dest: "{{ stepconfig.path }}"
content: "{{ lookup('ansible.builtin.file', stepconfig.path) | regex_replace('(ca_password|provisioner_password): ', '\\1: ' ~ (vapp['metacluster.password'] | b64encode)) }}"
no_log: true
- name: Install step-ca chart
@ -21,13 +16,7 @@
wait: true
kubeconfig: "{{ kubeconfig.path }}"
values_files:
- "{{ values_file.path }}"
- name: Cleanup tempfile
ansible.builtin.file:
path: "{{ values_file.path }}"
state: absent
when: values_file.path is defined
- "{{ stepconfig.path }}"
- name: Retrieve configmap w/ root certificate
kubernetes.core.k8s_info:

View File

@ -12,6 +12,15 @@
- registry
- storage
- name: Create step-ca config dictionary
ansible.builtin.set_fact:
stepconfig: "{{ { 'path': ansible_env.HOME ~ '/.step/config/values.yaml' } }}"
- name: Create step-ca target folder
ansible.builtin.file:
path: "{{ stepconfig.path | dirname }}"
state: directory
- name: Initialize tempfile
ansible.builtin.tempfile:
state: file
@ -36,8 +45,8 @@
--address=:9000 \
--provisioner=admin \
--acme \
--password-file={{ stepca_password.path }}
register: stepca_values
--password-file={{ stepca_password.path }} | tee {{ stepconfig.path }}
creates: "{{ stepconfig.path }}"
- name: Cleanup tempfile
ansible.builtin.file:
@ -48,7 +57,7 @@
- name: Store root CA certificate
ansible.builtin.copy:
dest: /usr/local/share/ca-certificates/root_ca.crt
content: "{{ (stepca_values.stdout | from_yaml).inject.certificates.root_ca }}"
content: "{{ (lookup('ansible.builtin.file', stepconfig.path) | from_yaml).inject.certificates.root_ca }}"
- name: Update certificate truststore
ansible.builtin.command:

View File

@ -42,19 +42,30 @@
retries: "{{ playbook.retries }}"
delay: "{{ (storage_benchmark | int) * (playbook.delay.medium | int) }}"
- name: Install kubectl tab-completion
- name: Install tab-completion
ansible.builtin.shell:
cmd: kubectl completion bash | tee /etc/bash_completion.d/kubectl
cmd: |-
{{ item }} completion bash > /etc/bash_completion.d/{{ item }}
creates: /etc/bash_completion.d/{{ item }}
loop:
- kubectl
- helm
- step
- name: Initialize tempfile
ansible.builtin.tempfile:
state: file
register: kubeconfig
- name: Create kubeconfig dictionary
ansible.builtin.set_fact:
kubeconfig: "{{ { 'path': ansible_env.HOME ~ '/.kube/config' } }}"
- name: Create kubeconfig target folder
ansible.builtin.file:
path: "{{ kubeconfig.path | dirname }}"
state: directory
- name: Retrieve kubeconfig
ansible.builtin.command:
cmd: kubectl config view --raw
register: kubectl_config
no_log: true
- name: Store kubeconfig in tempfile
ansible.builtin.copy:

View File

@ -1,12 +1,6 @@
- import_tasks: service.yml
- import_tasks: cron.yml
- name: Cleanup tempfile
ansible.builtin.file:
path: "{{ kubeconfig.path }}"
state: absent
when: kubeconfig.path is defined
# - name: Reboot host
# ansible.builtin.shell:
# cmd: systemctl reboot