211 Commits

Author SHA1 Message Date
Aleksei Sviridkin
826c53975d fix(ansible): replace deprecated entities and sync version requirements (#478)
* refactor(ansible): replace deprecated with_items and ansible facts

Replace deprecated `with_items` with `loop` keyword across all roles.
Migrate from legacy `ansible_*` top-level facts to `ansible_facts['*']`
syntax to prepare for ansible-core 2.24 where INJECT_FACTS_AS_VARS
will default to False.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>

* chore(ansible): sync minimum version requirements to 2.15

Align version checks in prereq and airgap roles with README requirement
of ansible-core 2.15+.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>

---------

Signed-off-by: Aleksei Sviridkin <f@lex.la>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-22 10:11:29 -08:00
ppascente
e11ff62d8f fix token management task to include regex_escape for special characters (#481)
Signed-off-by: Pete Pascente <ppascente@allete.com>
Co-authored-by: Pete Pascente <ppascente@allete.com>
2025-12-22 09:36:23 -08:00
Aleksei Sviridkin
49b810c948 feat(k3s_upgrade): regenerate service files from templates instead of restoring backups (#474)
* feat(k3s_upgrade): regenerate service files from templates instead of restoring backups

The k3s_upgrade role previously restored backup service files after binary
upgrade, which meant any changes to extra_server_args or extra_agent_args
would not be applied during upgrades.

This change:
- Replaces backup restoration with template-based service file regeneration
- Reuses templates from k3s_server role via symlink
- Adds necessary defaults for template variables

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2025-12-11 10:54:58 -08:00
Derek Nola
6737051311 Improve capture regex for k3s-agent service replacement (#470)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-12-04 12:14:23 -08:00
Phillip Thurston
11e99b0b7f Add ability to move kubeconfig to control node on demand (#467)
Signed-off-by: Phillip Thurston <phil@goinvictus.com>
2025-12-04 12:14:04 -08:00
Softplus+
c23ef774e4 refactor(prereq): use ansible_os_family for broader RHEL support (#469)
Changed the condition from checking specific 'ansible_distribution' names to 'ansible_os_family == "RedHat"'. This correctly targets all RHEL-based systems (including AlmaLinux, Rocky, CentOS) and ensures dependencies like 'kernel-modules-extra' are installed without listing each distribution manually.

Signed-off-by: Hanseung Kim <u72mlzb@gmail.com>
2025-12-04 10:32:00 -08:00
fch-aa
3b34d679e5 fix(upgrade): Implement airgap support for the upgrade flow. (#465)
Signed-off-by: fch-aa <21101725+fch-aa@users.noreply.github.com>

---------

Signed-off-by: fch-aa <21101725+fch-aa@users.noreply.github.com>
Co-authored-by: fch-aa <21101725+fch-aa@users.noreply.github.com>
2025-12-04 10:29:28 -08:00
Luis Salgado Alves
f06b042aab Refactor task to add compatibility with cmdline changes on ubuntu 25 (#461)
Signed-off-by: lufisaal <lalves.fs@gmail.com>
2025-11-17 10:31:27 -08:00
Riccardo Pressiani
9c945da3cc feat: add ufw allow inter-node ports (#460)
Signed-off-by: Riccardo Pressiani <riccardo.pressiani@gmail.com>
2025-11-10 09:31:11 -08:00
Jonathan Hanson
7209114690 allow for opt_tls_san to be undefined, since it's optionally defined (#456)
Signed-off-by: Jonathan Hanson <jonathan@jonathan-hanson.org>
2025-10-24 10:03:47 -07:00
too-gee
43c2fde96e Trim strings to prevent coercion warning
Signed-off-by: too-gee <116376+too-gee@users.noreply.github.com>
2025-10-06 10:00:05 -07:00
too-gee
d9e64c0511 Remove vars from task names
Signed-off-by: too-gee <116376+too-gee@users.noreply.github.com>
2025-10-06 10:00:05 -07:00
Derek Nola
8c38db014c Consolidate server templates into a single one (#443)
- Fix linting to achieve production level for k3s-server role

Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-09-15 14:24:01 -07:00
Derek Nola
b77e0049c8 Fix linting to bring back 'production' status for all non-server k3s roles
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-09-15 12:46:37 -07:00
Derek Nola
d397c5c3dd Remove agent jinja template
* Remove opt_tls_san for agents, it is not a valid agent argument
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-09-15 12:46:37 -07:00
Guillaume A
f2aed3ba47 Automatically inject tls-san when api_endpoint differs from hostname (#434)
* Auto-add --tls-san={{ api_endpoint }} when it differs from ansible_hostname
* Ensures first server generates certificate with all required SANs
* Add .ansible/ and PR_DESCRIPTION.md to gitignore

Signed-off-by: Guillaume Andre <mail@guillaumea.fr>
2025-09-15 11:21:20 -07:00
Vadim Radu
cb640b853f Fix ipv4 lookup for firewalld (#440)
Signed-off-by: Vadim Radu <vadim@printarescu.ro>
2025-09-08 09:52:26 -07:00
David Barnett
fad5c05cb4 fix k3s_upgrade error (#439)
Signed-off-by: David Barnett <davidb@rnett.nz>
2025-09-04 15:01:05 -07:00
Derek Nola
cd543a660d Inject installation envs for install script (#433)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-08-26 09:57:53 -07:00
Derek Nola
8b3845f9a4 Add missing RHEL 10 kernel module (#431)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-08-20 08:58:55 -07:00
Derek Nola
c239874136 Don't update_cache if airgapped (#430)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-08-12 11:13:54 -07:00
Claiyc
e9dbf66cef Distribute multiple image archives (#428)
Signed-off-by: Claiyc <claiyc@outlook.com>
2025-08-12 11:13:02 -07:00
fch-aa
66385e35eb fix(agent): Use proper env file path during provisioning. (#421)
Signed-off-by: fch-aa <21101725+fch-aa@users.noreply.github.com>
Co-authored-by: fch-aa <21101725+fch-aa@users.noreply.github.com>
2025-07-10 09:35:25 -07:00
Zero King
1067f630f5 Add service environment variables to all hosts (#416)
Signed-off-by: Zero King <l2dy@icloud.com>
2025-06-04 08:54:25 -06:00
Al West
f1d53c65e0 Disable repo check when installing SELinux RPM in airgapped environment (#413)
Currently when installed SELinux RPM, DNF will update repos.

Signed-off-by: Al West <al@tsew.net>
2025-05-22 10:44:33 -07:00
Stefan Haun
e3fe7ec450 Fix condition evaluation on ansible_all_ipv6_addresses to have a Boolean result (#404)
The condition `when: ansible_all_ipv6_addresses` evaluates to a list, which in
term evaluates to True,  but it seems that more recent Ansible versions do not
accept that anymore:

```
Conditional result was "['fe80::...']" of type 'list', which evaluates to True. Conditionals must have a boolean result.
```

This commit adds a length check to create a real Boolean result.

Signed-off-by: Stefan Haun <mail@tuxathome.de>
2025-04-18 09:07:40 -07:00
Rafael Alexandre
f3d8cc0b18 fix: rewrite ufw exceptions condition (#403)
Signed-off-by: Rafael Alexandre <r.alexandre99@gmail.com>
2025-04-18 09:07:23 -07:00
mbathe19
6809dc8913 feat: add check_mode false to run upgrade tests (#402)
Signed-off-by: Michel Bathe <michel.bathe.1996@googlemail.com>
2025-04-18 09:07:05 -07:00
Michal Stanke
078b031941 fix: make the roles work even when hosts are aliased in the inventory (#399)
Signed-off-by: Michal Stanke <michal@stanke.cz>
2025-03-27 09:28:16 -07:00
Derek Nola
c38327927b Only apply K3s autocomplete when ansible_user is defined (#398)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-03-20 10:49:03 -07:00
Derek Nola
2c3bc06537 Escape regex special characters in token value (#391)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-02-13 09:07:24 -08:00
alankan-finocomp
978bc50b3e Fix kubeconfig merge with existing config (#351)
* Fix kubeconfig merge with existing config

Signed-off-by: alankan-finocomp <79436574+alankan-finocomp@users.noreply.github.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
2025-02-06 09:06:04 -08:00
Will
c8527cc9ee improve check mode support, allow for agent config yaml, restart service if config changed (#388)
Signed-off-by: Will Brown <will@wbrwn.co>
Co-authored-by: Will Brown <will@wbrwn.co>
2025-01-28 09:15:09 -08:00
Saksham Garg
e3603884a7 fix: fixing k3s uninstallation failures when k3s is installed via airgap role (#384)
Signed-off-by: SakshamAbhi <saksham.garg.988@gmail.com>
Co-authored-by: sgarg <s.garg@f5.com>
2024-12-27 10:13:00 -08:00
Derek Nola
2a5a89a5ad Set default empty extra_server_args and extra_agent_args (#377)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-11-12 09:11:34 -08:00
anon-software
c10b84f0f4 enable autogenerating token (#375)
* Generate token

If a token is not explicitly provided, let the first server generate a
random one. Such a token is saved on the first server and the playbook
can retrieve it from there and store it a a fact. All other servers and
agents can use that token later to join the cluster. It will be saved
into their environment file as usual.

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>

* Document that token is (mostly) optional now

The token is still required when using Vagrant.

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>
2024-11-11 13:07:31 -08:00
Derek Nola
9d7fd7a70b Remove irrelevant kubectl symlink (#376)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-11-08 10:58:30 -08:00
Derek Nola
2d38507c70 Fix order of operations when install agent airgap (#373)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-10-28 11:43:06 -07:00
Derek Nola
c82a2f9b8e Don't modify existing airgap k3s-install script (#372)
* Check for existing k3s install script during airgap deployment

Signed-off-by: Derek Nola <derek.nola@suse.com>

* Update vagrant file to newer OS

Signed-off-by: Derek Nola <derek.nola@suse.com>

---------

Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-10-18 09:33:01 -07:00
Derek Nola
99fa632acb Fix failure when not using airgap (#370)
* Fix failure when not using airgap

Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-10-08 14:57:08 -07:00
Derek Nola
1cfe59728a Handle multiple architectures when distributing airgap binary (#367)
* Handle multiple architectures when distributing airgap binary

Signed-off-by: Derek Nola <derek.nola@suse.com>

* yamllint fix

Signed-off-by: Derek Nola <derek.nola@suse.com>

* ansiblelint fix

Signed-off-by: Derek Nola <derek.nola@suse.com>

---------

Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-10-08 14:10:05 -07:00
anon-software
040d37878b Prevent multiple tokens in k3s.service.env (#364)
* Prevent multiple tokens in k3s.service.env

If site.yml playbook is executed multiple times with different tokens,
they will all accumulate in k3s.service.env. They won't do any harm
because the last one wins, however it is a matter of good housekeeping
to delete the old before inserting a new one.

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>

* Selectively remove existing token from the environment file

If the existing token in the environment file is the same as the token
used for the playbook run, leave it in the file to avoid false changed
status from the task.

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>

---------

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>
2024-10-07 09:44:28 -07:00
Derek Nola
19f99f71ed Don't require a bogus k3s_version for airgap installs (#363)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-09-16 09:15:05 -07:00
Derek Nola
848e22cb72 Handle both new and old cmdline.txt locations in Raspbian (#362)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2024-09-13 10:49:53 -07:00
james-otten
bc03d1c0d0 Fix adding token to existing cluster (#360)
Signed-off-by: James Otten <jamesotten1@gmail.com>
2024-09-12 09:54:11 -07:00
anon-software
2d98982809 Security exposure related to the token (#356)
* Security exposure related to the token

The installation playbook saves the token into the systemd unit
configuration file /etc/systemd/system/k3s.service. The problem is that
according to K3s' documentation "the server token should be guarded
carefully" (https://docs.k3s.io/cli/token), yet the configuration file
is readable by anybody. A better solution is to save the token into its
corresponding environment file /etc/systemd/system/k3s.service.env which
is readable by the super user only. This is what the standard K3s'
installation script (https://get.k3s.io) does.

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>

* Restore the server URL into systemd configuration file

There aren't any security implications in keeping it there.

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>

---------

Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>
2024-09-04 14:02:52 -07:00
Lihai Tu
61ba8b57a3 Cleanup redundant conditions (#355)
Signed-off-by: tu1h <lihai.tu@daocloud.io>
2024-08-22 14:13:06 -07:00
anon-software
04c8ae9a57 More flexible cgroup settings (#352)
* More flexible cgroup settings

If there are already required cgroup boot parameters present but in a
different order than specified, the script will add them again. It is
better to test for the individual parameter in a loop and selectively
add them as necessary.

Signed-off-by: Marko Vukovic <anonsoftware@gmail.com>

Signed-off-by: Marko Vukovic <anonsoftware@gmail.com>
Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>
2024-08-15 10:32:22 -07:00
Peter Klijn
e53d895428 Introduce copy of k3s.yaml file to detect changes and skip control node changes (#347)
Signed-off-by: Peter Klijn <pjmklijn@gmail.com>
2024-07-15 13:55:31 -07:00
Peter Klijn
4f769544b3 Add a handler to restart the K3s Server when the service file changes (#344)
* Add a handler to restart the K3s Server when the service file changes

Signed-off-by: Peter Klijn <pjmklijn@gmail.com>
2024-07-15 10:00:25 -07:00