--- # Run with tailscale_update=true (tag: update). - name: Refresh APT cache before checking for Tailscale updates become: true ansible.builtin.apt: update_cache: true tags: [tailscale, update] - name: Determine latest available Tailscale candidate version ansible.builtin.command: apt-cache policy {{ tailscale_package | quote }} register: __tailscale_apt_policy changed_when: false # Read-only, so it also runs in the --check preview, which needs its stdout. check_mode: false tags: [tailscale, update] - name: Extract latest Tailscale candidate version ansible.builtin.set_fact: __tailscale_candidate_version: >- {{ __tailscale_apt_policy.stdout | regex_search('Candidate:\s+(\S+)', '\1') | default([''], true) | first }} tags: [tailscale, update] - name: Fail if Tailscale has no installable candidate ansible.builtin.fail: msg: >- No installable candidate version found for {{ tailscale_package }} (apt-cache policy reported '{{ __tailscale_candidate_version }}'). Check that the Tailscale APT repository is reachable. when: __tailscale_candidate_version in ['', '(none)'] tags: [tailscale, update] # Pinned to the resolved candidate version (never state=latest), so the task stays idempotent and # passes ansible-lint's package-latest rule. - name: Update Tailscale package to latest candidate version become: true ansible.builtin.apt: name: "{{ tailscale_package }}={{ __tailscale_candidate_version }}" state: present notify: Restart tailscaled tags: [tailscale, update]