# Install and Maintain CloudFlared Service

**URL:** <https://forum.ansible.com/t/install-and-maintain-cloudflared-service/6850>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [June 29, 2024, 10:50am UTC](https://forum.ansible.com/t/install-and-maintain-cloudflared-service/6850 "2024-06-29T10:50:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phil89a](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@Phil89a](https://forum.ansible.com/u/Phil89a)\
**Post date:** [June 29, 2024, 10:50am UTC](https://forum.ansible.com/t/install-and-maintain-cloudflared-service/6850/1 "2024-06-29T10:50:06Z")

</div>

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:

```auto
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb && 

sudo dpkg -i cloudflared.deb && 

sudo cloudflared service install <key>

```

I have worked out how to download and install CloudFlared…

```auto
- name: Install Latest CloudFlared
  ansible.builtin.apt:
    deb: https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb

```

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?

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [June 29, 2024, 12:02pm UTC](https://forum.ansible.com/t/install-and-maintain-cloudflared-service/6850/2 "2024-06-29T12:02:29Z")

</div>

I’d suggest downloading the [repo GPG key](https://pkg.cloudflare.com/cloudflare-main.gpg) and configuring [the repo](https://pkg.cloudflare.com/) using the [ansible.builtin.deb822\_repository module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/deb822_repository_module.html) 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:

- [Docker](https://git.coop/webarch/docker/-/blob/master/tasks/apt.yml?ref_type=heads)
- [Firefox](https://git.coop/webarch/firefox/-/blob/main/tasks/apt.yml?ref_type=heads)
- [ONLYOFFICE](https://git.coop/webarch/onlyoffice/-/blob/master/tasks/apt.yml?ref_type=heads)
- [PHP](https://git.coop/webarch/php/-/blob/main/tasks/apt.yml?ref_type=heads)

---

<div class="post-metadata">

**Author:** ![Phil89a](https://avatars.discourse-cdn.com/v4/letter/p/ce7236/32.png) [@Phil89a](https://forum.ansible.com/u/Phil89a)\
**Post date:** [June 29, 2024, 3:19pm UTC](https://forum.ansible.com/t/install-and-maintain-cloudflared-service/6850/3 "2024-06-29T15:19:30Z")

</div>

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