HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to install Certbot via Ansible playbook?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
installcertbotplaybookviahowansible

Problem

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?

Solution

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

Code Snippets

- apt_repository:
    repo: 'ppa:certbot/certbot'

- apt:
    name: "{{ item }}"
    update_cache: yes
  with_items:
    - nginx
    - python-certbox-nginx

Context

StackExchange DevOps Q#3155, answer score: 5

Revisions (0)

No revisions yet.