The navigation through a bunch of config files, all with just a few lines in it is cumbersome. This change moves all the configuration into a centralized `config.ini` that way it's easier for me to get a quick overview of the setup. The `config.ini` acts as another inventory and is therefore references as such by the ansible.cfg. The `inventory.ini` (which is generated by terraform in the provisioning-step) is not affected by this change.
20 lines
649 B
YAML
20 lines
649 B
YAML
- name: Download kube-config
|
|
fetch:
|
|
src: /etc/rancher/k3s/k3s.yaml
|
|
dest: "{{ lookup('env', 'HOME') }}/.kube/config.orig"
|
|
flat: True
|
|
register: loaded_kube_config
|
|
- name: Copy kube-config to correct location
|
|
delegate_to: localhost
|
|
copy:
|
|
src: "{{ lookup('env', 'HOME') }}/.kube/config.orig"
|
|
dest: "{{ lookup('env', 'HOME') }}/.kube/config"
|
|
when: loaded_kube_config is changed
|
|
- name: Use correct ip-address for k8s-cluster
|
|
delegate_to: localhost
|
|
lineinfile:
|
|
path: "{{ lookup('env', 'HOME') }}/.kube/config"
|
|
regexp: '^(\s*server: https://).*(:\d+)$'
|
|
line: \g<1>{{ k8s_api_endpoint }}\g<2>
|
|
backrefs: yes
|