-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] add OAuth key integration and additional URL-style params to --auth-key flags (ephemeral & preauthorized) #399
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ef8a005
Add auth-key additional params
McSim85 cbdf51e
fix bool
McSim85 3364dfe
fix identation
McSim85 439ed0a
add tailscale_authkey_sting, more docs
McSim85 50986de
add key info
McSim85 fc8bfb8
Merge branch 'main' into main
artis3n ba63de9
fix headscale case and README
McSim85 0fc1026
make md linter happy
McSim85 bc5d1f4
Update README.md
McSim85 0033d3a
Update README.md
McSim85 5f924cb
Update README.md
McSim85 f49157c
Update README.md
McSim85 93e1c2e
Update README.md
McSim85 cd41e94
Update defaults/main.yml
McSim85 ce1006d
Update README.md
McSim85 af5eaaf
Update README.md
McSim85 5262e30
Apply suggestions from code review
McSim85 23f6a82
molecule fix
McSim85 1467653
fix linter
McSim85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: Cleanup | ||
hosts: instance | ||
tasks: | ||
- name: De-register Tailscale node | ||
become: true | ||
ansible.builtin.command: tailscale logout | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Converge | ||
hosts: instance | ||
tasks: | ||
- name: Init tailscale credentials variables | ||
ansible.builtin.include_tasks: init_tailscale_vars.yml | ||
|
||
- name: "Include artis3n.tailscale" | ||
ansible.builtin.include_role: | ||
name: artis3n.tailscale | ||
vars: | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# minimal Headscale configuration for local testing | ||
# See upstream example file for full description of all options: | ||
# https://github.com/juanfont/headscale/blob/main/config-example.yaml | ||
server_url: http://headscale:8080 | ||
listen_addr: 0.0.0.0:8080 | ||
metrics_listen_addr: 0.0.0.0:9090 | ||
private_key_path: /etc/headscale/private.key | ||
noise: | ||
private_key_path: /etc/headscale/noise_private.key | ||
db_type: sqlite3 | ||
db_path: /etc/headscale/db.sqlite | ||
|
||
# Default Tailscale prefixes | ||
ip_prefixes: | ||
- fd7a:115c:a1e0::/48 | ||
- 100.64.0.0/10 | ||
|
||
# Disable TLS | ||
tls_cert_path: "" | ||
tls_key_path: "" | ||
|
||
# Add DNS configuration so we can --accept-dns | ||
dns_config: | ||
override_local_dns: true | ||
nameservers: | ||
- 1.1.1.1 | ||
|
||
derp: | ||
server: | ||
enabled: true | ||
region_id: 999 | ||
region_code: "headscale" | ||
region_name: "Headscale Embedded DERP" | ||
stun_listen_addr: "0.0.0.0:3478" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: Use tailscale service | ||
ansible.builtin.set_fact: | ||
tailscale_authkey: "{{ lookup('ansible.builtin.env', 'TAILSCALE_OAUTH_CLIENT_SECRET') }}" | ||
when: not lookup('ansible.builtin.env', 'USE_HEADSCALE', default=false) | ||
|
||
- name: Fetch headscale preauth key | ||
delegate_to: localhost | ||
changed_when: false | ||
community.docker.docker_container_exec: | ||
container: headscale | ||
command: headscale preauthkeys list -u test -o json | ||
register: preauth_list | ||
when: lookup('ansible.builtin.env', 'USE_HEADSCALE', default=false) | ||
|
||
- name: Use headscale service | ||
vars: | ||
combined_args: "{{ tailscale_args|default('') }} --login-server=http://headscale:8080" | ||
ansible.builtin.set_fact: | ||
tailscale_authkey: "{{ (preauth_list.stdout|from_json)[0].key }}" | ||
tailscale_args: "{{ combined_args }}" | ||
when: lookup('ansible.builtin.env', 'USE_HEADSCALE', default=false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
options: | ||
requirements-file: requirements.yml | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: instance | ||
image: ${MOLECULE_DISTRO:-geerlingguy/docker-ubuntu2204-ansible:latest} | ||
command: ${MOLECULE_COMMAND:-/usr/sbin/init} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
docker_networks: | ||
- name: headscale | ||
networks: | ||
- name: bridge | ||
- name: headscale | ||
cgroupns_mode: host | ||
privileged: true | ||
pre_build_image: true | ||
- name: headscale | ||
image: ${HEADSCALE_IMAGE:-headscale/headscale:latest} | ||
command: headscale serve | ||
pre_build_image: true | ||
networks: | ||
- name: headscale | ||
volumes: | ||
- "${MOLECULE_PROJECT_DIRECTORY}/molecule/default/headscale.config.yaml:/etc/headscale/config.yaml" | ||
provisioner: | ||
name: ansible | ||
verifier: | ||
name: ansible | ||
scenario: | ||
name: oauth | ||
test_sequence: | ||
- dependency | ||
- destroy | ||
- syntax | ||
- create | ||
- prepare | ||
- converge | ||
- idempotence | ||
- verify | ||
- cleanup | ||
- destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: Prepare | ||
hosts: localhost | ||
gather_facts: false | ||
tasks: | ||
- name: Create Headscale user | ||
community.docker.docker_container_exec: | ||
container: headscale | ||
command: headscale users create test | ||
|
||
- name: Create preauth key | ||
community.docker.docker_container_exec: | ||
container: headscale | ||
command: headscale preauthkeys create -u test --reusable | ||
|
||
- name: Fetch Headscale container info | ||
community.docker.docker_container_info: | ||
name: headscale | ||
register: headscale_info | ||
|
||
- name: Set hosts override for Headscale | ||
delegate_to: instance | ||
ansible.builtin.lineinfile: | ||
path: /etc/hosts | ||
line: "{{ headscale_info.container.NetworkSettings.Networks.headscale.IPAddress }} headscale" | ||
unsafe_writes: true # Hosts file in the docker container can't be written to atomically |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: Verify | ||
hosts: instance | ||
tasks: | ||
- name: Get Tailscale status | ||
become: true | ||
ansible.builtin.command: tailscale status | ||
changed_when: false | ||
register: tailscale_status | ||
|
||
- name: Assertions | ||
ansible.builtin.assert: | ||
that: | ||
- "'Logged out.' not in tailscale_status.stdout" | ||
- "'not logged in' not in tailscale_status.stdout" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fine without the extra empty line, right?