PyratLabs / ansible-role-k3s

Ansible role for installing k3s as either a standalone server or HA cluster.
BSD 3-Clause "New" or "Revised" License
640 stars 135 forks source link

When write-kubeconfig-mode is 0640 it becomes 416 #157

Closed kenorb closed 3 years ago

kenorb commented 3 years ago

Summary

I was confused by write-kubeconfig-mode when I set to:

        k3s_server:
          write-kubeconfig-mode: 0640

then it become 416.

And when setting 0644, it becomes 420.

TASK [xanmanning.k3s : Ensure k3s config file exists] *********************************************************************************************************************************************************************************
--- before: /etc/rancher/k3s/config.yaml
+++ after: ~/.ansible/tmp/ansible-local-139192q1sfps3o/tmp637j2xa_/config.yaml.j2
@@ -8,5 +8,5 @@
 - foo=bar
 - hello=world
 with-node-id: true
+write-kubeconfig-mode: 416

Normally when you do 0640 with chmod command it works fine.

Is that expected behaviour?

Issue Type

Controller Environment and Configuration

$ ansible --version
ansible [core 2.11.5] 
$ ansible-galaxy list
- xanmanning.k3s, v2.11.0

Steps to Reproduce

---
- hosts: vm01
  roles:
    - role: xanmanning.k3s
      vars:
        k3s_become_for_install_dir: true
        k3s_become_for_usr_local_bin: true
        k3s_server:
          write-kubeconfig-mode: 0640
        k3s_state: installed
xanmanning commented 3 years ago

Have you tried quoting it?

kenorb commented 3 years ago

Have you tried quoting it?

Quoting the value seems to work fine:

TASK [xanmanning.k3s : Ensure k3s config file exists] *********************************************************************************************************************************************************************************
--- before: /etc/rancher/k3s/config.yaml
+++ after: ~/.ansible/tmp/ansible-local-14182803vupoye/tmp5usv3qnl/config.yaml.j2
@@ -8,5 +8,5 @@
-write-kubeconfig-mode: 644
+write-kubeconfig-mode: '0640'

Thank you.

kenorb commented 3 years ago

To avoid confusion and copy-paste errors, the following resources needs to be updated:

xanmanning commented 3 years ago

Fixed in main

https://github.com/PyratLabs/ansible-role-k3s/search?q=write-kubeconfig-mode