Skip to content

Commit

Permalink
Remove unsupported command module "warn" parameter (#218)
Browse files Browse the repository at this point in the history
* Remove unsupported command module "warn" parameter

As of ansible-core 2.14.0, the builtin command module no longer
has a "warn" parameter. Using it causes a fatal error that stops
playbook completion.

Signed-off-by: Brian Brookman <[email protected]>
Signed-off-by: Derek Nola <[email protected]>

* Relax yamllint rules on spaces inside braces

Signed-off-by: Derek Nola <[email protected]>

* Fix lint

Signed-off-by: Derek Nola <[email protected]>

---------

Signed-off-by: Brian Brookman <[email protected]>
Signed-off-by: Derek Nola <[email protected]>
Co-authored-by: Julien DOCHE <[email protected]>
Co-authored-by: Derek Nola <[email protected]>
  • Loading branch information
3 people authored Nov 7, 2023
1 parent 7ec3049 commit 8b5b6e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ rules:
level: warning
truthy:
allowed-values: ['true', 'false', 'yes', 'no']
braces:
max-spaces-inside: 1
2 changes: 1 addition & 1 deletion roles/k3s/master/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
ansible_user: root
k3s_server_location: /var/lib/rancher/k3s
server_init_args: >-
k3s_server_init_args: >-
{% if groups['master'] | length > 1 %}
{% if ansible_host == hostvars[groups['master'][0]]['ansible_host'] | default(groups['master'][0]) %}
--cluster-init
Expand Down
10 changes: 3 additions & 7 deletions roles/k3s/master/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@
failed_when: false

- name: Clean previous runs of k3s-init
ansible.builtin.command: systemctl reset-failed k3s-init
ansible.builtin.command: systemctl reset-failed k3s-init # noqa: command-instead-of-module
failed_when: false
changed_when: false
args:
warn: false # The ansible systemd module does not support reset-failed

- name: Init cluster inside the transient k3s-init service
ansible.builtin.command:
cmd: "systemd-run -p RestartSec=2 \
-p Restart=on-failure \
--unit=k3s-init \
k3s server {{ server_init_args }}"
k3s server {{ k3s_server_init_args }}"
creates: "{{ systemd_dir }}/k3s.service"
args:
warn: false # The ansible systemd module does not support transient units

- name: Verification
block:
Expand Down Expand Up @@ -98,7 +94,7 @@
owner: "{{ ansible_user }}"
mode: "u=rw,g=,o="

- name: Configure kubectl cluster to https://{{ apiserver_endpoint }}:{{ apiserver_port | default(6443) }}
- name: Configure kubectl cluster to server endpoint
ansible.builtin.command: >-
/usr/local/bin/k3s kubectl config set-cluster default
--server=https://{{ apiserver_endpoint }}:{{ apiserver_port | default(6443) }}
Expand Down

0 comments on commit 8b5b6e2

Please sign in to comment.