12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- ---
- - name: init bundle check
- uri:
- method: GET
- return_content: true
- validate_certs: false
- url: "https://{{ api_ep }}/v1/cluster-init/init-bundles"
- headers:
- Authorization: Bearer {{ api_token }}
- Accept: application/json
- register: init_bundle_response
- - name: assume init bundle isn't there
- set_fact:
- init_bundle_present: false
- - name: unless found
- set_fact:
- init_bundle_present: true
- when:
- - init_bundle_response.json['items'] | length > 0
- - (init_bundle_response.json['items'] | items2dict(key_name='name', value_name='expiresAt'))[clusters[cluster].name] is defined
- - name: generate init bundle
- uri:
- method: POST
- return_content: true
- validate_certs: false
- url: "https://{{ api_ep }}/v1/cluster-init/init-bundles"
- headers:
- Authorization: Bearer {{ api_token }}
- Accept: application/json
- Content-Type: application/json
- body: '{"name":"{{ clusters[cluster].name | string }}"}'
- register: init_bundle_content
- when:
- - not init_bundle_present
- - name: store init bundle - operator
- copy:
- dest: "{{ ansible_facts['user_dir'] }}/{{ cluster }}-init-bundle.yaml"
- content: "{{ init_bundle_content.json.kubectlBundle | b64decode }}"
- owner: "{{ ansible_user }}"
- group: "{{ ansible_user }}"
- mode: 0600
- when:
- - not init_bundle_present
- - clusters[cluster].method == 'operator'
- - name: store init bundle - helm
- copy:
- dest: "{{ ansible_facts['user_dir'] }}/{{ cluster }}-helm-bundle.yaml"
- content: "{{ init_bundle_content.json.helmValuesBundle | b64decode }}"
- owner: "{{ ansible_user }}"
- group: "{{ ansible_user }}"
- mode: 0600
- when:
- - not init_bundle_present
- - clusters[cluster].method == 'helm'
- - name: make sure namespace is there
- kubernetes.core.k8s:
- kubeconfig: "{{ ansible_facts['user_dir'] }}/kubeconfig-{{ cluster }}"
- validate_certs: no
- api_version: v1
- kind: Namespace
- name: "{{ clusters[cluster].namespace }}"
- namespace: ""
- state: present
- - name: create init bundle
- kubernetes.core.k8s:
- kubeconfig: "{{ ansible_facts['user_dir'] }}/kubeconfig-{{ cluster }}"
- validate_certs: no
- src: "{{ ansible_facts['user_dir'] }}/{{ cluster }}-init-bundle.yaml"
- namespace: "{{ clusters[cluster].namespace }}"
- when:
- - clusters[cluster].method == 'operator'
- ...
|