--- - name: Ensure Kubernetes directories exist when: item.state == 'directory' ansible.builtin.file: path: "{{ repository_path }}/ansible/{{ item.path }}" state: directory mode: "0755" with_community.general.filetree: ["../templates/ansible/"] - name: Template Ansible unencrypted files when: item.state == 'file' and 'sops' not in item.path and '.DS_Store' not in item.path ansible.builtin.template: src: "{{ item.src }}" dest: "{{ repository_path }}/ansible/{{ item.path | regex_replace('.j2$', '') }}" mode: "0644" with_community.general.filetree: ["../templates/ansible/"] - name: Template Ansible encrypted files block: - name: Disable Sops config ansible.builtin.include_tasks: file: ../sops/disable.yaml - name: Template Ansible encrypted files when: item.state == 'file' and 'sops' in item.path community.sops.sops_encrypt: path: "{{ repository_path }}/ansible/{{ item.path | replace('.j2', '') }}" encrypted_regex: ^(data|stringData)$ age: ["{{ bootstrap_age_public_key }}"] content_yaml: "{{ lookup('ansible.builtin.template', item.src) | from_yaml }}" mode: "0644" force: true with_community.general.filetree: ["../templates/ansible/"] - name: Template encrypted node secrets community.sops.sops_encrypt: path: "{{ repository_path }}/ansible/inventory/host_vars/{{ item.name }}.sops.yaml" age: ["{{ bootstrap_age_public_key }}"] content_yaml: "{{ lookup('ansible.builtin.template', 'templates/node.sops.yaml.j2', template_vars=dict(password=item.password)) | from_yaml }}" mode: "0644" force: true loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}" loop_control: label: "{{ item.address }}" - name: Enable Sops config ansible.builtin.include_tasks: file: ../sops/enable.yaml rescue: - name: Enable Sops config ansible.builtin.include_tasks: file: ../sops/enable.yaml