Skip to content
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

Lay groundwork for funnel poc #66

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
strategy:
matrix:
include:
- distro: debian10 # Buster

Check warning on line 49 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Lint

49:30 [comments] too few spaces before comment
playbook: converge.yml
- distro: ubuntu1804 # Bionic Beaver
playbook: converge.yml
# - distro: ubuntu1804 # Bionic Beaver

Check warning on line 51 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Lint

51:11 [comments-indentation] comment not indented like content
# playbook: converge.yml
# TODO: Failed to get D-Bus connection: No such file or directory
# - distro: centos7
# playbook: converge.yml
- distro: centos8
playbook: converge.yml
# - distro: centos8
# playbook: converge.yml

steps:
- name: Check out the codebase.
Expand All @@ -73,20 +73,32 @@
- name: Set HOSTNAME.
run: echo "HOSTNAME=$(cat /etc/hostname)" >> $GITHUB_ENV

- name: Run Molecule default test.
run: |
molecule test --scenario-name default
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_LOAD_CALLBACK_PLUGINS: true
ANSIBLE_STDOUT_CALLBACK: 'yaml'
MOLECULE_DISTRO: ${{ matrix.distro }}
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
# - name: Run Molecule default test.
# run: |
# molecule test --scenario-name default
# env:
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
# ANSIBLE_LOAD_CALLBACK_PLUGINS: true
# ANSIBLE_STDOUT_CALLBACK: 'yaml'
# MOLECULE_DISTRO: ${{ matrix.distro }}
# MOLECULE_PLAYBOOK: ${{ matrix.playbook }}

# - name: Run Molecule up test.
# run: |
# molecule test --scenario-name up
# env:
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
# ANSIBLE_LOAD_CALLBACK_PLUGINS: true
# ANSIBLE_STDOUT_CALLBACK: 'yaml'
# MOLECULE_DISTRO: ${{ matrix.distro }}
# MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
# TAILSCALE_AUTHKEY: "${{ secrets.TAILSCALE_AUTHKEY }}"

- name: Run Molecule up test.
- name: Run Molecule funnel test.
run: |
molecule test --scenario-name up
molecule test --scenario-name funnel
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Features:
- Install Tailscale.
- Register Node to Tailnet.
- (Beta Feature) Provision HTTPS certificates.
- (Beta Feature) Run Funnel.

## Requirements

Expand Down Expand Up @@ -55,6 +56,14 @@ Run `tailscale cert` with arguments. `tailscale_cert_domain` must be set.

See https://tailscale.com/kb/1153/enabling-https/.

tailscale_funnel_enabled: false

**This feature is in beta. It may be removed or changed in a future release.**

Run `tailscale funnel` with arguments.

See https://tailscale.com/kb/1223/tailscale-funnel/.

tailscale_default_options_enabled: false
tailscale_default_options_settings:
# Allow caddy user to fetch cert.
Expand Down Expand Up @@ -119,6 +128,22 @@ See https://tailscale.com/kb/1153/enabling-https/.
- jason_riddle.tailscale
```

### (Beta Feature) Run Funnel.

See https://tailscale.com/kb/1223/tailscale-funnel/.

```yaml
- hosts: all

vars:
tailscale_up_node: true
tailscale_up_authkey: "{{ lookup('env', 'TAILSCALE_AUTHKEY') }}"
tailscale_funnel_enabled: true

roles:
- jason_riddle.tailscale
```

## License

MIT
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ tailscale_cert_filename: "{{ tailscale_cert_domain }}.crt"
tailscale_cert_private_key_dir: "/usr/local/etc/ssl/private"
tailscale_cert_private_key_filename: "{{ tailscale_cert_domain }}.key"

# Funnel options.
tailscale_funnel_enabled: false

# Configure /etc/default/tailscaled options.
tailscale_default_options_enabled: false
tailscale_default_options_settings:
Expand Down
36 changes: 36 additions & 0 deletions molecule/funnel/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Converge
hosts: all
become: true

vars:
tailscale_up_node: true
tailscale_up_authkey: "{{ lookup('env', 'TAILSCALE_AUTHKEY') }}"
tailscale_up_extra_args: "--hostname=github-ci-funnel-{{ lookup('env', 'HOSTNAME') }}-{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower }}-{{ ansible_architecture | replace('_', '-') }}"

Check warning on line 9 in molecule/funnel/converge.yml

View workflow job for this annotation

GitHub Actions / Lint

9:181 [line-length] line too long (217 > 180 characters)
tailscale_funnel_enabled: true

pre_tasks:
- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
changed_when: false
when: ansible_os_family == 'Debian'

- name: Wait for systemd to complete initialization. # noqa 303
command: systemctl is-system-running
register: systemctl_status
until: >
'running' in systemctl_status.stdout or
'degraded' in systemctl_status.stdout
retries: 30
delay: 5
when: ansible_service_mgr == 'systemd'
changed_when: false
failed_when: systemctl_status.rc > 1

roles:
- role: jason_riddle.tailscale

post_tasks:
- name: Verify Tailscale is installed.
command: tailscale --version
changed_when: false
23 changes: 23 additions & 0 deletions molecule/funnel/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-debian10}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
# REF: https://www.jeffgeerling.com/blog/2022/docker-and-systemd-getting-rid-dreaded-failed-connect-bus-error
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
pre_build_image: true
provisioner:
name: ansible
# inventory:
# host_vars:
# instance:
# tailscale_up_no_log: false
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
2 changes: 1 addition & 1 deletion molecule/up/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
vars:
tailscale_up_node: true
tailscale_up_authkey: "{{ lookup('env', 'TAILSCALE_AUTHKEY') }}"
tailscale_up_extra_args: "--hostname=github-ci-{{ lookup('env', 'HOSTNAME') }}-{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower }}-{{ ansible_architecture | replace('_', '-') }}"
tailscale_up_extra_args: "--hostname=github-ci-up-{{ lookup('env', 'HOSTNAME') }}-{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower }}-{{ ansible_architecture | replace('_', '-') }}"

Check warning on line 9 in molecule/up/converge.yml

View workflow job for this annotation

GitHub Actions / Lint

9:181 [line-length] line too long (213 > 180 characters)

pre_tasks:
- name: Update apt cache.
Expand Down
8 changes: 4 additions & 4 deletions molecule/up/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ platforms:
pre_build_image: true
provisioner:
name: ansible
inventory:
host_vars:
instance:
tailscale_up_no_log: false
# inventory:
# host_vars:
# instance:
# tailscale_up_no_log: false
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
24 changes: 24 additions & 0 deletions tasks/funnel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
# - name: Assert that tailscale_up_authkey is not empty.
# assert:
# that:
# - tailscale_up_authkey | length > 0
# quiet: true

# - name: Assert that tailscale_up_timeout is not empty.
# assert:
# that:
# - tailscale_up_timeout | length > 0
# quiet: true

- name: Run serve.
command: |
tailscale serve https / http://127.0.0.1:3000
tags:
- molecule-idempotence-notest

- name: Run funnel.
command: |
tailscale funnel 443 on
tags:
- molecule-idempotence-notest
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@

- include_tasks: cert.yml
when: tailscale_cert_enabled | bool

- include_tasks: funnel.yml
when: tailscale_funnel_enabled | bool
Loading