mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2024-12-14 06:40:21 +01:00
de1bd094e5
* fix(ansible-lint): FQDN and `name` * fix(ansible-lint): add `name` and FQDN for module call * fix(ansible-lint): add `name` to tasks and FQDN for module * fix(ansible-lint): add task `name` and FQDN for module calls * fix(ansible-lint): last `include_tasks` * fix(ansible-lint): add task names and FQDN * refactor: `Ensure` to `Run` * [skip ci]refactor: add exist and seperate ensure installed node task, mention build cluster * [skip ci]refactor: Pipe seperator * [skip ci]refactor: run * refactor: remove quotes as other files don't use them For templated vars in task name * [skip ci]refactor: task names, use `Run` * [skip ci]refactor: use variable name in task name * [skip ci]refactor: task names * [skip ci]refactor: add service mgr in task name * [skip ci]refactor: add task names and module FQDNs * [skip ci]refactor: fix task name * [skip ci]refactor: add - * [skip ci]refactor: include task names and FQDNs * [skip ci]refactor: add task names and FQDNs * [skip ci]: ignore `name[template]` * refactor: `when` clause for `block` should be before `block` * fix: https://github.com/ansible-community/molecule/issues/3883 * refactor: molecule lint command was removed in version `5.0.0` Use separate CI job step to run linting instead. * [skip ci]refactor: noqa for command tasks Subject to change * refactor: use Ubuntu 22.04 Suspect issues with Molecule tests are related to cgroups v2.
108 lines
3.4 KiB
YAML
108 lines
3.4 KiB
YAML
---
|
|
|
|
- name: "Ensure cluster token is captured from {{ k3s_control_delegate }}"
|
|
ansible.builtin.slurp:
|
|
path: "{{ k3s_runtime_config['data-dir'] | default(k3s_data_dir) }}/server/token"
|
|
register: k3s_slurped_cluster_token
|
|
delegate_to: "{{ k3s_control_delegate }}"
|
|
when:
|
|
- k3s_control_token is not defined
|
|
- not ansible_check_mode
|
|
become: "{{ k3s_become }}"
|
|
|
|
- name: Ensure cluster token is formatted correctly for use in templates
|
|
ansible.builtin.set_fact:
|
|
k3s_control_token_content: "{{ k3s_control_token | default(k3s_slurped_cluster_token.content | b64decode) }}"
|
|
when:
|
|
- k3s_control_token is not defined
|
|
- not ansible_check_mode
|
|
|
|
- name: Ensure dummy cluster token is defined for ansible_check_mode
|
|
ansible.builtin.set_fact:
|
|
k3s_control_token_content: "{{ k3s_control_delegate | to_uuid }}"
|
|
check_mode: false
|
|
when:
|
|
- ansible_check_mode
|
|
|
|
- name: Ensure the cluster token file location exists
|
|
ansible.builtin.file:
|
|
path: "{{ k3s_token_location | dirname }}"
|
|
state: directory
|
|
mode: 0755
|
|
become: "{{ k3s_become }}"
|
|
|
|
- name: Ensure k3s cluster token file is present
|
|
ansible.builtin.template:
|
|
src: cluster-token.j2
|
|
dest: "{{ k3s_token_location }}"
|
|
mode: 0600
|
|
become: "{{ k3s_become }}"
|
|
notify:
|
|
- "Restart k3s {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
|
|
- name: Ensure k3s service unit file is present
|
|
ansible.builtin.template:
|
|
src: k3s.service.j2
|
|
dest: "{{ k3s_systemd_unit_dir }}/k3s.service"
|
|
mode: 0644
|
|
become: "{{ k3s_become }}"
|
|
when:
|
|
- k3s_service_handler[ansible_service_mgr] == 'systemd'
|
|
notify:
|
|
- "Reload {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
- "Restart k3s {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
|
|
- name: Ensure k3s service file is present
|
|
ansible.builtin.template:
|
|
src: k3s.openrc.j2
|
|
dest: "{{ k3s_openrc_service_dir }}/k3s"
|
|
mode: 0744
|
|
when:
|
|
- k3s_service_handler[ansible_service_mgr] == 'service'
|
|
notify:
|
|
- "Reload {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
- "Restart k3s {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
become: "{{ k3s_become }}"
|
|
|
|
- name: Ensure k3s logrotate file is present
|
|
ansible.builtin.template:
|
|
src: k3s.logrotate.j2
|
|
dest: "{{ k3s_logrotate_dir }}/k3s"
|
|
mode: 0640
|
|
when:
|
|
- k3s_service_handler[ansible_service_mgr] == 'service'
|
|
notify:
|
|
- "Reload {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
- "Restart k3s {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
become: "{{ k3s_become }}"
|
|
|
|
- name: Ensure k3s config file exists
|
|
ansible.builtin.template:
|
|
src: config.yaml.j2
|
|
dest: "{{ k3s_config_file }}"
|
|
mode: 0644
|
|
notify:
|
|
- "Reload {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
- "Restart k3s {{ k3s_service_handler[ansible_service_mgr] }}"
|
|
become: "{{ k3s_become }}"
|
|
|
|
- name: Ensure secondary controllers are started
|
|
ansible.builtin.include_tasks: ensure_control_plane_started_{{ ansible_service_mgr }}.yml
|
|
when:
|
|
- k3s_control_node
|
|
- not k3s_primary_control_node
|
|
|
|
- name: Run control plane post checks
|
|
ansible.builtin.import_tasks: post_checks_control_plane.yml
|
|
when:
|
|
- not k3s_skip_validation
|
|
- not k3s_skip_post_checks
|
|
|
|
- name: Flush Handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: Run node post checks
|
|
ansible.builtin.import_tasks: post_checks_nodes.yml
|
|
when:
|
|
- not k3s_skip_validation
|
|
- not k3s_skip_post_checks
|