- rename manager node and update host FQDNs in inventory - enable multiple worker nodes by commenting out secondary disk - standardize k8s configuration file paths with numeric prefixes - disable k9s permissions step in manager role - upgrade Longhorn chart to v1.12.0 and Traefik chart to v41.0.2 - update Traefik port_map with protocol and add forgejo service - refine Traefik logging configuration to use new JSON format - increase Longhorn disk probe retries and delays - add placeholder directory for k8s_manager files
134 lines
3.7 KiB
YAML
134 lines
3.7 KiB
YAML
---
|
|
- name: System | Set hostname
|
|
ansible.builtin.hostname:
|
|
name: "{{ inventory_hostname }}"
|
|
|
|
- name: System | Set timezone
|
|
community.general.timezone:
|
|
name: "{{ k8s_manager_timezone }}"
|
|
|
|
# Fix #8: explicit full upgrade is opt-in (k8s_manager_upgrade_packages: true)
|
|
# to prevent unintended kernel/system updates on prod runs
|
|
- name: System | Update cache
|
|
ansible.builtin.dnf:
|
|
update_cache: true
|
|
|
|
- name: System | Upgrade all packages # noqa: package-latest
|
|
ansible.builtin.dnf:
|
|
name: "*"
|
|
state: latest
|
|
when: k8s_manager_upgrade_packages | bool
|
|
|
|
- name: System | Install extra packages
|
|
ansible.builtin.dnf:
|
|
name: "{{ k8s_manager_extra_packages }}"
|
|
state: present
|
|
|
|
- name: kubectl | Get latest stable version
|
|
ansible.builtin.uri:
|
|
url: https://dl.k8s.io/release/stable.txt
|
|
return_content: true
|
|
register: _kubectl_latest
|
|
when: not kubectl_version
|
|
check_mode: false
|
|
|
|
- name: kubectl | Set version fact (latest)
|
|
ansible.builtin.set_fact:
|
|
_kubectl_version: "{{ _kubectl_latest.content | trim }}"
|
|
when: not kubectl_version
|
|
|
|
- name: kubectl | Set version fact (pinned)
|
|
ansible.builtin.set_fact:
|
|
_kubectl_version: "{{ kubectl_version }}"
|
|
when: kubectl_version
|
|
|
|
- name: kubectl | Download binary
|
|
ansible.builtin.get_url:
|
|
url: "https://dl.k8s.io/release/{{ _kubectl_version }}/bin/linux/amd64/kubectl"
|
|
dest: /usr/local/bin/kubectl
|
|
mode: "0755"
|
|
owner: root
|
|
group: root
|
|
|
|
- name: kubectl | Enable bash completion
|
|
ansible.builtin.shell: /usr/local/bin/kubectl completion bash > /etc/bash_completion.d/kubectl
|
|
args:
|
|
creates: /etc/bash_completion.d/kubectl
|
|
|
|
- name: helm | Install EPEL repository
|
|
ansible.builtin.dnf:
|
|
name: epel-release
|
|
state: present
|
|
|
|
- name: helm | Install via DNF
|
|
ansible.builtin.dnf:
|
|
name: helm
|
|
state: present
|
|
|
|
- name: helm | Enable bash completion
|
|
ansible.builtin.shell: helm completion bash > /etc/bash_completion.d/helm
|
|
args:
|
|
creates: /etc/bash_completion.d/helm
|
|
|
|
- name: k9s | Install via DNF
|
|
ansible.builtin.dnf:
|
|
name: "https://github.com/derailed/k9s/releases/latest/download/k9s_linux_amd64.rpm"
|
|
state: present
|
|
disable_gpg_check: true
|
|
|
|
|
|
#- name: k9s | Set permissions
|
|
# ansible.builtin.file:
|
|
# path: /usr/local/bin/k9s
|
|
# mode: "0755"
|
|
# owner: root
|
|
# group: root
|
|
|
|
- name: kubectx/kubens | Download kubectx
|
|
ansible.builtin.get_url:
|
|
url: https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx
|
|
dest: '{{ role_path }}/files/kubectx'
|
|
mode: "0755"
|
|
delegate_to: localhost
|
|
run_once: true
|
|
|
|
- name: kubectx/kubens | Download kubens
|
|
ansible.builtin.get_url:
|
|
url: https://raw.githubusercontent.com/ahmetb/kubectx/master/kubens
|
|
dest: '{{ role_path }}/files/kubens'
|
|
mode: "0755"
|
|
delegate_to: localhost
|
|
run_once: true
|
|
|
|
- name: kubectx/kubens | Install binaries
|
|
ansible.builtin.copy:
|
|
src: "{{ role_path }}/files/{{ item }}"
|
|
dest: /usr/local/bin/{{ item }}
|
|
mode: "0755"
|
|
owner: root
|
|
group: root
|
|
loop:
|
|
- kubectx
|
|
- kubens
|
|
|
|
- name: kubeconfig | Ensure .kube directory exists
|
|
ansible.builtin.file:
|
|
path: "{{ kubeconfig_dir }}"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: "0700"
|
|
|
|
- name: dashboard | Install Kubernetes Dashboard
|
|
ansible.builtin.include_tasks: dashboard.yml
|
|
|
|
- name: bash | Add kubectl alias and kubeconfig to profile
|
|
ansible.builtin.blockinfile:
|
|
path: "/home/{{ ansible_user }}/.bashrc"
|
|
marker: "# {mark} ANSIBLE MANAGED — k8s aliases"
|
|
block: |
|
|
export KUBECONFIG="{{ kubeconfig_dir }}/config"
|
|
source /usr/share/bash-completion/bash_completion
|
|
alias k=kubectl
|
|
complete -o default -F __start_kubectl k
|