Answers: <p>For Ubuntu 16.04 should be something like this</p>
  
  <pre><code>tasks
  - name: Install Certbot.
    package: "name=letsencrypt state=present"
  </code></pre>
  
  <p>Or you can use a role from Github: <a href="https://github.com/geerlingguy/ansible-role-certbot" rel="nofollow noreferrer">https://github.com/geerlingguy/ansible-role-certbot</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-26T18:25:52.350Z
Answers: I'm fairly certain that the role mentioned does in fact install Certbot.
Answers: colan
Answers: CC BY-SA 4.0
Answers: 2019-01-08T13:18:38.943Z
Answers: this does not install certbot
Answers: numediaweb
Answers: CC BY-SA 3.0
Answers: 2018-01-23T09:58:25.877Z
Answers: 2018-01-23T09:58:25.877Z
Answers: Maksim
Answers: <p>This is how I do it:</p>
  
  <pre><code>- name: Add certbot repository
    apt_repository:
      repo: 'ppa:certbot/certbot'
  
  - name: Install Certbot's Apache package
    apt:
      name: python-certbot-apache
      state: present
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-01-08T13:27:24.683Z
Answers: 2019-01-08T13:27:24.683Z
Answers: numediaweb
Answers: <p>chipping in with ansible task to install letsencrypt certbot on debian stretch</p>
  
  <pre><code>---
  - name: Add "stretch-backports" to APT sources (required for Certbot)
    become: yes
    apt_repository:
      repo: deb http://httpredir.debian.org/debian stretch-backports main
      state: present
      update_cache: yes
  
  - name: "Check LetsEncrypt/Certbot is installed"
    become: yes
    apt:
      name: 
        - certbot
        - python-certbot-apache # https://github.com/certbot/certbot/issues/3854
      state: present
      default_release: stretch-backports
      cache_valid_time: 3600
      update_cache: yes
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-03T13:02:19.680Z
Answers: 2019-10-03T13:02:19.680Z
Answers: Rafa
Answers: <p>Here is the direct Ansible translation of your bash install script:</p>
  
  <pre><code>- apt_repository:
      repo: 'ppa:certbot/certbot'
  
  - apt:
      name: "{{ item }}"
      update_cache: yes
    with_items:
      - nginx
      - python-certbox-nginx
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-09-03T10:35:06.647Z
Answers: In Ubuntu 18.04 with Ansible 2.5.1, the first 2 rows raises: ``Warning: apt-key output should not be parsed``. However, I found that adding the repo is not needed in Ubuntu 18.04. You can install it directly with ``become: yes`` and ``apt: name: python-certbot-nginx``
Answers: Juha Untinen
Answers: CC BY-SA 3.0
Answers: 2018-01-26T23:26:26.700Z
Answers: 2018-01-26T23:26:26.700Z
Answers: Xiong Chiamiov
Body: <p>This is how I install Certbot in a Bash script:</p>
  
  <pre><code>apt-get update -y &amp;&amp; add-apt-repository ppa:certbot/certbot -y &amp;&amp; apt-get update -y
  apt-get upgrade nginx python-certbot-nginx -y
  </code></pre>
  
  <hr>
  
  <p>That's the playbook syntax I found to install Nginx in default conf:</p>
  
  <pre><code>- hosts: localhost
      connection: local
      become: true
  
  tasks:
      - name: install nginx
      apt: pkg=nginx state=installed update_cache=true
  </code></pre>
  
  <p>Is there no Ansible task to install Certbot as well, instead the above "heavier" Bash code?</p>
  
Comments: CC BY-SA 3.0
Comments: 2018-01-23T06:37:57.823Z
Comments: Did you check ansible galaxy?
Comments: 030
Comments: CC BY-SA 3.0
Comments: 2018-01-23T06:39:13.830Z
Comments: No, just heard of that from you... :)
Comments: Arcticooling
Comments: CC BY-SA 3.0
Comments: 2018-01-23T06:41:14.807Z
Comments: Hmm, just ran "certbot" in the Ansible Galaxy search engine... Sadly zero results.
Comments: Arcticooling
Tags: <ansible>
Title: How to install Certbot via Ansible playbook?
UserDisplayName: Arcticooling
ThreadText: # How to install Certbot via Ansible playbook?
  
  (Asked by: username_0 on 2018-01-23)
  
  This is how I install Certbot in a Bash script:
  
  ```
  apt-get update -y && add-apt-repository ppa:certbot/certbot -y && apt-get update -y
  apt-get upgrade nginx python-certbot-nginx -y
  
  ```
  
  ---
  
  That's the playbook syntax I found to install Nginx in default conf:
  
  ```
  - hosts: localhost
      connection: local
      become: true
  
  tasks:
      - name: install nginx
      apt: pkg=nginx state=installed update_cache=true
  
  ```
  
  Is there no Ansible task to install Certbot as well, instead the above "heavier" Bash code?
  
  **Tags:** ansible
  
  > **Comments:**
  > **username_1**: Did you check ansible galaxy?  
  > **username_0**: No, just heard of that from you... :)  
  > **username_0**: Hmm, just ran "certbot" in the Ansible Galaxy search engine... Sadly zero results.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_6 on 2018-01-26. Score: 5 | Accepted answer
  
  Here is the direct Ansible translation of your bash install script:
  
  ```
  - apt_repository:
      repo: 'ppa:certbot/certbot'
  
  - apt:
      name: "{{ item }}"
      update_cache: yes
    with_items:
      - nginx
      - python-certbox-nginx
  
  ```
  
  > **Comments:**
  > **username_7**: In Ubuntu 18.04 with Ansible 2.5.1, the first 2 rows raises: ``Warning: apt-key output should not be parsed``. However, I found that adding the repo is not needed in Ubuntu 18.04. You can install it directly with ``become: yes`` and ``apt: name: python-certbot-nginx``  
  
  ---
  
  ### Answer by username_2 on 2018-01-23. Score: 4
  
  For Ubuntu 16.04 should be something like this
  
  ```
  tasks
  - name: Install Certbot.
    package: "name=letsencrypt state=present"
  
  ```
  
  Or you can use a role from Github: <https://github.com/geerlingguy/ansible-role-certbot>
  
  > **Comments:**
  > **username_4**: this does not install certbot  
  > **username_3**: I'm fairly certain that the role mentioned does in fact install Certbot.  
  
  ---
  
  ### Answer by username_4 on 2019-01-08. Score: 0
  
  This is how I do it:
  
  ```
  - name: Add certbot repository
    apt_repository:
      repo: 'ppa:certbot/certbot'
  
  - name: Install Certbot's Apache package
    apt:
      name: python-certbot-apache
      state: present
  
  ```
  
  
  ---
  
  ### Answer by username_5 on 2019-10-03. Score: -1
  
  chipping in with ansible task to install letsencrypt certbot on debian stretch
  
  ```
  ---
  - name: Add "stretch-backports" to APT sources (required for Certbot)
    become: yes
    apt_repository:
      repo: deb http://httpredir.debian.org/debian stretch-backports main
      state: present
      update_cache: yes
  
  - name: "Check LetsEncrypt/Certbot is installed"
    become: yes
    apt:
      name: 
        - certbot
        - python-certbot-apache # https://github.com/certbot/certbot/issues/3854
      state: present
      default_release: stretch-backports
      cache_valid_time: 3600
      update_cache: yes
  
  ```
  
  
  ---
  
  