<p>One could use the <code>apt</code> module of Ansible. <a href="http://docs.ansible.com/ansible/latest/apt_module.html" rel="nofollow noreferrer">http://docs.ansible.com/ansible/latest/apt_module.html</a></p>

<p>The <code>apt</code> module uses <code>apt</code> and apt itself is able to check whether a package has already been installed and will prevent that it will be installed as it has already been installed.</p>

<p>I use this module myself as well. As the idempotence test passes it indicates that it will not install certbot if it has been installed already.</p>

<p><a href="https://github.com/030/ansible-certbot/blob/master/tasks/Debian.yml#L10" rel="nofollow noreferrer">https://github.com/030/ansible-certbot/blob/master/tasks/Debian.yml#L10</a></p>

<pre><code>- name: certbot installed
  apt:
    name: certbot
    state: latest
</code></pre>

CC BY-SA 3.0
2018-03-16T17:59:08.260Z
2018-03-16T17:59:08.260Z
030
<p>I am running an <code>ansible</code> task that will among others install a let's encrypt certificate.</p>

<p>I want the task to only run if the certificate has not been installed.</p>

<p>What is the best way to check (via cmd) if my host has a valid secure connection over https?</p>

CC BY-SA 3.0
2018-03-08T12:35:44.567Z
Certbot already ensure the certificate has to be renewed or not... why not let it handle that ?
Tensibai
CC BY-SA 3.0
2018-03-08T17:47:07.833Z
What role do you use, e.g. http://github.com/030/ansible-certbot
030
CC BY-SA 3.0
2018-03-11T17:51:09.743Z
Did the link help? If not, please post the code you have created.
030
<ansible><ssl>
Conditionally run certbot
pkaramol
# Conditionally run certbot

(Asked by: username_0 on 2018-03-08)

I am running an `ansible` task that will among others install a let's encrypt certificate.

I want the task to only run if the certificate has not been installed.

What is the best way to check (via cmd) if my host has a valid secure connection over https?

**Tags:** ansible, ssl

> **Comments:**
> **username_1**: Certbot already ensure the certificate has to be renewed or not... why not let it handle that ?  
> **username_2**: What role do you use, e.g. http://github.com/username_2/ansible-certbot  
> **username_2**: Did the link help? If not, please post the code you have created.  

---

## 1 answers

### Answer by username_2 on 2018-03-16. Score: 1

One could use the apt module of Ansible. http://docs.ansible.com/ansible/latest/apt_module.html
The apt module uses apt and apt itself is able to check whether a package has already been installed and will prevent that it will be installed as it has already been installed.
I use this module myself as well. As the idempotence test passes it indicates that it will not install certbot if it has been installed already.
https://github.com/username_2/ansible-certbot/blob/master/tasks/Debian.yml#L10
- name: certbot installed
  apt:
    name: certbot
    state: latest


---

