Add draft roles for cloudflared and tailscale

This commit is contained in:
Ryan Cavicchioni 2024-04-14 18:31:59 -05:00
parent db1ee687a7
commit 7caf443b35
13 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,10 @@
---
cloudflared_package_name: cloudflared
cloudflared_package_state: present
cloudflared_service_name: cloudflared.service
cloudflared_service_enabled: true
cloudflared_service_state: started
cloudflared_apt_repository_repo: "deb [signed-by=/etc/apt/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared {{ ansible_lsb.codename }} main"
cloudflared_apt_repository_state: present

Binary file not shown.

View File

@ -0,0 +1,14 @@
---
- name: trust cloudflare apt respository key
ansible.builtin.copy:
src: "cloudflare-main.gpg"
dest: "/etc/apt/keyrings/cloudflare-main.gpg"
owner: root
group: root
mode: 0644
- name: configure cloudflare apt repository
ansible.builtin.apt_repository:
repo: "{{ cloudflared_apt_repository_repo }}"
state: "{{ cloudflared_apt_repository_state | default('present') }}"
filename: cloudflared

View File

@ -0,0 +1,5 @@
---
- name: install package
ansible.builtin.package:
name: "{{ cloudflared_package_name }}"
state: "{{ cloudflared_package_state | default('present') }}"

View File

@ -0,0 +1,28 @@
---
- name: gather os specific variables
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- ansible.builtin.include_tasks: install.yaml
# - ansible.builtin.include_tasks: configure.yaml

View File

View File

@ -0,0 +1,10 @@
---
# tailscale_package_name: tailscale
# tailscale_package_state: present
# tailscale_service_name: tailscaled
# tailscale_service_state: started
# tailscale_service_enabled: true
tailscale_up_args:
[]

View File

@ -0,0 +1,13 @@
---
- name: add tailscale repo
block:
- name: install apt key
ansible.builtin.get_url:
url: "https://pkgs.tailscale.com/stable/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}.noarmor.gpg"
dest: /etc/apt/trusted.gpg.d/tailscale-archive-keyring.gpg
- name: install apt repo
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/trusted.gpg.d/tailscale-archive-keyring.gpg] https://pkgs.tailscale.com/stable/{{ ansible_distribution | lower }} {{ ansible_distribution_release | lower }} main"
state: present
filename: tailscale

View File

@ -0,0 +1,11 @@
---
- name: manage service
ansible.builtin.service:
name: "{{ tailscale_service_name | default('tailscaled') }}"
state: "{{ tailscale_service_state | default('started') }}"
enabled: "{{ tailscale_service_enabled | default(true) }}"
- name: tailscale up
ansible.builtin.shell:
cmd: "tailscale up {{ tailscale_up_args | join(' ') }} --authkey {{ tailscale_authkey }}"
no_log: true

View File

View File

@ -0,0 +1,5 @@
---
- name: install
ansible.builtin.package:
name: "{{ tailscale_package_name | default('tailscale') }}"
state: "{{ tailscale_package_state | default('present') }}"

View File

@ -0,0 +1,31 @@
---
- name: gather OS specific variables
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: run os specific tasks
ansible.builtin.include_tasks: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- debug:
var: ansible_facts
- include_tasks: install.yaml
- include_tasks: configure.yaml

View File