Compare commits

4 Commits

Author SHA1 Message Date
Jayson Grace 800b8189b0 Merge 4742400db8 into 1fb10faf7f 2024-02-06 07:03:30 +00:00
Jayson Grace 4742400db8 Added missing checks causing failures for agents 2024-02-06 00:03:12 -07:00
Jayson Grace ab4a261cac Introduce idiomatic practices for affected areas from previous commits
**Added:**

- Structured HTTP Proxy Configuration Block - Added a structured block in
  `http_proxy.yml` for managing HTTP proxy settings, aligning with Ansible's
  recommended practices. This includes creating directories and deploying
  configuration files in a clear, modular fashion.
- Conditional Execution for Proxy Setup - Implemented conditional execution
  for the proxy setup in `http_proxy.yml`, utilizing `proxy_env` to adhere
  to Ansible's best practices for conditional tasks.
- Improved PXE-Boot System Check Block - Introduced a more structured approach
  in `main.yml` for checking PXE-booted systems, enhancing readability and
  maintainability.

**Changed:**

- Adopted Ansible Builtin Modules - Transitioned existing tasks to use
  `ansible.builtin` modules, ensuring compatibility and future-proofing the
  role.
- Refined Task Grouping - Reorganized tasks into logical blocks, improving
  the overall structure and readability, and showcasing Ansible's capabilities
  for efficient task management.
- Updated K3s Service Configuration - Modified the K3s service configuration
  task in `main.yml` for a more streamlined approach using Ansible's template
  module, reflecting community-driven best practices.

**Removed:**

- Streamlined Task Definitions - Optimized task definitions to reduce
  redundancy, focusing on clarity and adherence to the evolving Ansible
  community standards.
2024-02-05 21:48:37 -07:00
Jayson Grace ded061af8f Add conditional snapshotter for PXE-booted systems
**Added:**

- PXE Boot Check - Introduced tasks to check if the system is PXE-booted by
  analyzing `/proc/cmdline` in `roles/k3s_agent/tasks/main.yml`.
- Conditional Snapshotter in Template - Added logic in `k3s.service.j2` template
  to conditionally set `--snapshotter native` for PXE-booted systems.

**Changed:**

- `k3s.service.j2` Template Update - Modified the `ExecStart` line to include a
  conditional check for `is_pxe_booted` fact, dynamically setting the
  `--snapshotter` option for NFS-mounted systems.
- `main.yml` Task Modification - Added tasks to set `is_pxe_booted` fact based
  on the presence of `root=/dev/nfs` in the system's boot command line.

This update allows k3s agents on PXE-booted systems to use the native snapshotter
when running on NFS, addressing compatibility issues with OverlayFS.
2024-02-05 21:45:16 -07:00
2 changed files with 6 additions and 21 deletions
+2 -21
View File
@@ -1,24 +1,4 @@
---
- name: Manage K3s HTTP Proxy Configuration
when: proxy_env is defined
block:
- name: Create k3s.service.d directory
ansible.builtin.file:
path: '{{ systemd_dir }}/k3s.service.d'
owner: root
group: root
state: directory
mode: '0755'
- name: Deploy the K3s http_proxy configuration file
ansible.builtin.template:
src: "http_proxy.conf.j2"
dest: "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
owner: root
group: root
mode: '0755'
- name: Create k3s-node.service.d directory
file:
path: '{{ systemd_dir }}/k3s-node.service.d'
@@ -26,7 +6,7 @@
owner: root
group: root
mode: '0755'
when: proxy_env is defined
- name: Copy K3s http_proxy conf file
template:
@@ -35,3 +15,4 @@
owner: root
group: root
mode: '0755'
when: proxy_env is defined
+4
View File
@@ -16,6 +16,10 @@
- name: Include http_proxy configuration tasks
ansible.builtin.include_tasks: http_proxy.yml
- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: proxy_env is defined
- name: Configure the k3s service
ansible.builtin.template:
src: "k3s.service.j2"