Install and Maintain CloudFlared Service

I am just starting with Ansible and how a question on how its best to approach installing (and updating) the CloudFlared Service.

To install CloudFlared, the instructions are:

curl -L --output cloudflared.deb && 

sudo dpkg -i cloudflared.deb && 

sudo cloudflared service install <key>

I have worked out how to download and install CloudFlared…

- name: Install Latest CloudFlared

But I am lost on how to call the cloudflared service install Can anyone help with this?

Also, I am assuming this will always download and install the package. Is this right?

I am trying to work out how to only install if the downloaded version is newer to avoid taking down the CloudFlared Service every time I run the playbook. Appreciate peoples thoughts on how to do this?

I’d suggest downloading the repo GPG key and configuring the repo using the ansible.builtin.deb822_repository module and then installing the package using the apt module.

I haven’t written a role for this for Cloudflare but feel free to copy and adjust the tasks I’ve used for others if you want, for example:

Ah thanks Chris. A bit above my experience level to understand all of this, but will try and work my way through it.