artis3n/ansible-role-tailscale

[BUG] sudo: not found on Proxmox system

sebdanielsson opened this issue · 9 comments

Describe the bug
I tried to run this role to bring up Tailscale on Proxmox and got this error message:

TASK [artis3n.tailscale : Debian | Apt Dependencies] ************************************
fatal: [hogsmeade]: FAILED! => {"changed": false, "module_stderr": "Shared connection to hogsmeade closed.\r\n", "module_stdout": "/bin/sh: 1: sudo: not found\r\nexit status 127\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

To Reproduce

- name: Install and configure Tailscale
   role: artis3n.tailscale
     tailscale_args: "--ssh"
     vars:
       tailscale_authkey: <KEY>

Run this on Proxmox 7.3 and see the error.

Expected behavior
Tailscale should install and start.

Target (please complete the following information):

  • OS: Proxmox 7.3
  • Ansible version: 2.14.1
  • artis3n.tailscale version: 3.5.0
  • Tailscale version (set verbose to true): Should be latest for Debian?

Looks like sudo isn't available on the target system. Before invoking this role, I'd run

apt update && apt install sudo
usermod -aG sudo <your_username>

or:

- name: Install sudo
  ansible.builtin.apt:
    name: sudo
    cache_valid_time: 3600

- name: Add user to sudo group
  ansible.builtin.user:
    name: <your_username>
    append: true
    groups: sudo

Does that resolve the error?

Really don't want to install sudo only to use this role. Maybe you could add a variable for the role to disable the use of sudo?

I'm confused - are you running as root on your target server, therefore sudo isn't necessary for you?

Correct. I'm running my Playbook on a freshly installed Proxmox server where the only default user in root.

I'm not familiar with proxmox but I did a little poking and it seems like bin/su is installed by default - is that correct? In that case, can you set the become method to ansible.builtin.su? You can do this as a host variable, which sounds appropriate for your use case - ansible_become_method=su.

This role is not doing anything directly with sudo or escalating privileges, it relies on Ansible's become feature. You can run ansible-doc -t become -l to see what become plugins exist in your installation (and can therefore be set as the become_method). This is what I see:
image

Thank you! Changing the become_method solves the issue but a new appeared.

TASK [artis3n.tailscale : Debian | Apt Dependencies] ************************************
[WARNING]: Could not find apt-mark binary, not marking package(s) as manually installed.
ok: [hogsmeade]

TASK [artis3n.tailscale : Debian | Legacy Apt Dependencies] *****************************
skipping: [hogsmeade]

TASK [artis3n.tailscale : Debian | Add Tailscale Signing Key] ***************************
ok: [hogsmeade]

TASK [artis3n.tailscale : Debian | Add Tailscale Deb] ***********************************
[WARNING]: Module invocation had junk after the JSON data: exit status 1
fatal: [hogsmeade]: FAILED! => {"changed": false, "msg": "Either apt-key or gpg binary is required, but neither could be found"}

Seems to be a common issue but couldn't really find a solution.

Yeah I'm just going to be googling for this as well. I'm curious, does https://stackoverflow.com/a/62086891 help?

I do see https://tailscale.com/kb/1130/lxc-unprivileged/ and https://tailscale.com/kb/1133/proxmox/ from the Tailscale folks. But neither seem to address the errors you're currently seeing.

I had already commented out the enterprise repo but after reading your link I also tried to delete the file but that didn't work. Also already had the no-subscription-repo so that doesn't seem to be the issue.🤔

Runnig apt dist-upgrade and restarting fixed the problem I was having. Again, thank you for your help and this awesome role!