---
# file: roles/letsencrypt/tasks/install.yml

- name: Apt Key
  apt_key:
    url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x8C47BE8E75BCA694
    state: present

- name: Apt Repository
  apt_repository:
    repo: ppa:certbot/certbot
    state: present
    mode: 0644

- name: Install CertBot
  apt:
    pkg: certbot
    state: present
    update_cache: yes

- name: Force certbot to use Python 3
  lineinfile:
    path: '{{ item }}'
    regexp: '^#!/usr/bin/python$'
    line: '#!/usr/bin/python3'
  with_items:
    - /usr/local/bin/certbot
    - /usr/bin/certbot
  ignore_errors: yes
  failed_when: no