Giter VIP home page Giter VIP logo

ansible-role-tailscale's Introduction

Hello there.

I've been a security engineer and penetration tester and currently trick companies into letting me lead Application Security programs.

I tend to build open source projects around improving the user experience of security tooling and integrations. The secure thing should be the easiest thing for a developer to do.

Some of my active projects include:

trophy

Artis3n's github stats

ansible-role-tailscale's People

Contributors

aleohl avatar artis3n avatar cmmarslender avatar cnkk avatar dependabot[bot] avatar fredrikekre avatar frodera avatar h3poteto avatar hamishforbes avatar hollow avatar jamdoog avatar jonvmey avatar kaiyou avatar markstos avatar mcsim85 avatar mhitza avatar mnaser avatar mprasil avatar nitper avatar panos-- avatar pellegrino avatar ramblurr avatar relrod avatar toadjaune avatar wormi4ok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-role-tailscale's Issues

Add a shorter timeout if tailscale up fails.

If tailscale up is successful, it would take very little time to return. But if something is wrong (say wrong key), the it takes forever before failing. It would save a few mins if this timeout can be implemented.

Add Molecule OracleLinux container

#111 adds support for OraceLinux. To add this distro to the CI checks, make an Ansible+Molecule-packaged image from https://hub.docker.com/_/oraclelinux , looks like 8-slim is the image we want. They do not use latest.

A subscription is required but not clear if I can still use that in these tests. Alternatively, we do not test this distro and it is supported on a best-effort basis.

Should be similar Dockerfile to https://github.com/geerlingguy/docker-centos8-ansible.

Support Tailscale installation without running `up`

Support installing Tailscale onto a host without running authentication.

New flow:

tailscale_auth_key is required unless tailscale_up_skip is present and set to true. If tailscale_up_skip is set to true, then skip the "Bring Tailscale Up" task.

Use case is to run this role as part of a Packer AMI build without authenticating the node until a server is actually created from that AMI.

Role installs a very old version on Arch Linux

On Arch, this role installs tailscale 1.2.10. The current version is 1.4.2.

TASK [artis3n.tailscale : Tailscale Version] ***********************************
ok: [instance] => {
    "msg": [
        "1.2.10",
        "  tailscale commit: e480f8ddf6f7334fda1b3d0dd1b500f2f01f961b",
        "  go version: go1.15.7"
    ]
}

Support PopOS

Follow the Ubuntu format, except the distribution name retrieved from ansible_facts will need to change from 'PopOS!' to 'Ubuntu'.

Parallelize Molecule docker tests

How? Molecule has the --parallel flag that "enables parallelization." It creates UUIDs and seems to require the user to leverage other tools (tox?) to run tests in parallel.

This is only beneficial to local testing, as the GitHub Actions workflow already runs the Molecule tests in parallel.

[BUG] Recent commit breaks previous installations (and makes the role very difficult to use

Describe the bug

This commit added the role variables to vars/main.yml. This makes the role very very difficult to use, and in fact breaks instances where the role was working fine before.

The problem is one of variable precedence. Variables defined in vars/main.yml have very very high precdence, see this list from the ansible docs: https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable

Notably vars in vars/main.yml override host_vars, group_vars, and play vars (and a bunch more, but these are the most commonly used).

To Reproduce

Inventory host vars file:

# host_vars/myhost.yml
---
tailscale_auth_key: my encrypted key

Playbook

- hosts: myhost
  pre_tasks:
   # this prints out 'my encrypted key' showing that the var is indeed set in the hostvars
    - debug:
        msg: "{{ hostvars[inventory_hostname].tailscale_auth_key }}"
  roles:
    - role: artis3n.tailscale

Result:

TASK [artis3n.tailscale : Tailscale Auth Key Required] *********************************************
Wednesday 25 August 2021  11:17:51 +0200 (0:00:00.332)       0:00:38.857 ****** 
fatal: [myhost]: FAILED! => changed=false 
  msg: |-
    You must include a Node Authorization auth key. Set a `tailscale_auth_key` ansible-vault encrypted variable. You can create this key from: https://login.tailscale.com/admin/authkeys.

Expected behavior

It should work without error

Target (please complete the following information):

  • OS: Fedora
  • Ansible version: 2.10.4
  • artis3n.tailscale version: 1.31.1

Proposed Solution

IMHO, the correct way is to leave the vars/main.yml empty in this case, and specify the variable defaults in defaults/main.yml.

I see the comment in vars/main.yml says "Variables that a user may want to modify." I understand why you did this. It seems natural to put variables that the user should/must define in vars/main.yml as a sort of declaration, but this is not how ansible works (unfortunately). In reality declaring variables in that file makes it more difficult to modify them.

Ansible has no real mechanism to "declare" variables that have no sane default, except by documenting them in the docs and raising runtime errors when variables are not well defined.

You can always use the following to guard against undefined variables.

     when: tailscale_auth_key is not defined or tailscale_auth_key == None and not tailscale_up_skip | bool

Debian 11/Bullseye: No package matching 'python-apt' is available

Now that bullseye is no longer testing, the following condition fails:

when: (ansible_distribution_major_version | int < 20) and ansible_distribution_major_version != "testing"

TASK [artis3n.tailscale : Debian | Legacy Apt Dependencies] ********************************************************************************************************************
fatal: [xxx]: FAILED! => {"changed": false, "msg": "No package matching 'python-apt' is available"}

I'm not sure what the best solution would be to update that condition, as it should match all the distributions...

In my personal debian base role, I have the following shell task:

"apt update; RC=$?; [ \"$RC\" = \"100\" ] || [ \"$RC\" = \"0\" ] && apt install -y python{{ ansible_python['version']['major'] if ansible_python['version']['major'] > 2 }}-apt"

Thats definitely not the cleanest solution, however after a fresh installation of Proxmox VE the apt update fails (Enterprise repo without accompanying credentials configured), so the apt module can't handle it itself without failing.

Bringing Tailscale up fails

Describe the bug
Been using this role for a while. Recently, I guess something in Tailscale changed, because there's now a problem bringing up the Tailscale connection, which fails every time (I'm using tailscale_args to set subnet routes).

To Reproduce
Steps to reproduce the behavior:

  1. Go to use this role to install Tailscale
  2. See failure at start-up

Expected behavior
Tailscale should start.

Screenshots
N/A.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04, 20.0

Additional context
I think Tailscale introduced extra logging as part of "tailscale up", such that the test

tailscale_status.stdout | length == 0

fails, even when the application has successfully started. As a work around, I've made the test >=, but this is clearly a hack.

[BUG] Arch fails idempotence tests in CI

While Tailscale is successfully installed and started, the install task is re-run during the idempotence test. This is a recent occurrence. Potentially due to Ansible version updates? Maybe the update_cache parameter? Investigate.

image

[BUG] Cannot update this role on Ansible Galaxy (Resolved)

I moved this repo from master to main, and Ansible Galaxy doesn't know how to handle that, it appears. I filed ansible/galaxy#2535, have to find a resolution. In the worst case, I have to return the default branch to be master, but hopefully there is a way to force re-sync the repo such that the default branch is updated on Galaxy's end.

[BUG] tailscale_up_skip does not work as expected

Describe the bug
When setting tailscale_up_skip to true similar to the example in the readme (see below), the playbook fails if tailscale_auth_key is not set. I'm not sure if this is the intended behavior.

- name: Servers
  hosts: all
  roles:
    - role: artis3n.tailscale
      vars:
        tailscale_up_skip: true

I just set a fake value to tailscale_auth_key and the playbook goes through but gets stuck at the task "Bring Tailscale Up".

Expected behavior
Just install Tailscale when tailscale_up_skip

Target (please complete the following information):

  • OS: Debian Buster
  • Ansible version: 3.0.0
  • artis3n.tailscale version: v1.9.0
  • Tailscale version (set verbose to true):

Output of tailscale status during role execution (set verbose to true):

verbose does not seem to work.

Additional context

I'm using Ansible in Packer to create a GCP image.

Packer version: 1.7.0
Python version: 3.9.1

[FEAT] advertise-exit-node support/flag

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Tailscale 1.6.0 introduced support for --advertise-exit-node https://tailscale.com/kb/1103/exit-nodes

Describe the solution you'd like
A clear and concise description of what you want to happen.

Support to run tailscale as either an exit node or using an exit node as part of the module

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

I dig into the module code and didn't really find a good place to introduce this change without a major refactor, but happy to help

Fix support for PopOS

TASK [artis3n.tailscale : Tailscale Signing Key] *********************************************
fatal: [oryx]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'pop!_os'\n\nThe error appears to be in '/home/artis3n/.ansible/roles/artis3n.tailscale/tasks/debian.yml': line 13, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Tailscale Signing Key\n  ^ here\n"}

image

[BUG]

describe the bug
Once I run the play book (see playbook.yaml) the system errors on the ansible role.

Playbook

---
- name: Setup virtual machine tools & users
  hosts: all
  remote_user: root

  tasks:
  - name: Ping machines
    ping:
  - name: Update & Upgrade ubuntu packages
    apt:
      upgrade: "yes"
      update_cache: true
      cache_valid_time: 86400

  - name: Configure Tailscale
    include_role:
      name: artis3n.tailscale
    vars:
      verbose: true
      tailscale_args: "--accept-routes=true"
      # Pulled from the env vars on the host running Ansible
      tailscale_auth_key: "{{ lookup('env', 'TAILSCALE_KEY') }}"

Error

ERROR! this task 'ansible.builtin.include_tasks' has extra params, which is only allowed in the following modules: include, include_tasks, command, meta, set_fact, add_host, import_tasks, win_shell, shell, win_command, include_role, raw, group_by, import_role, script, include_vars

The error appears to be in '/root/.ansible/roles/artis3n.tailscale/tasks/main.yml': line 55, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: CentOS and related families
  ^ here

Operating System
local machine: Windows WSL 2 (Ubuntu)
target machines: Ubuntu 20.04

I'm wondering if im doing anything wrong? I'm fairly new to Ansible, but I was trying to use the simple examples in the README.md

Support all Tailscale-supported distributions

Support all distributions located at https://pkgs.tailscale.com/stable/. This is not a prioritized list.

This ticket will track the overall state of each distribution and link to the relevant pull requests.

Supported:

  • Ubuntu 16.04 (Xenial)
  • Ubuntu 18.04 LTS (Bionic) - #2
  • Ubuntu 19.10 (Eoan)
  • Ubuntu 20.04 LTS (Focal)
  • Debian Stretch
  • Debian Buster (stable)
  • Debian Bullseye (unstable)
  • Debian Sid (testing)
  • Raspbian Buster
  • CentOS 7 - #2
  • CentOS 8
  • Fedora
  • RHEL 8
  • Amazon Linux 2
  • OpenSUSE Leap 15.1
  • OpenSUSE Leap 15.2
  • Arch Linux

Experimental:

  • Windows

Maybe:

  • Static binaries

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.