- name: Install letsencrypt
  apt: name=letsencrypt state=present
  when: letsencrypt.enabled == true

- name: Get letsencrypt cert
  command: bash -lc "letsencrypt certonly --standalone --rsa-key-size 4096 --force-renew --agree-tos --email {{ letsencrypt.email }} --text --non-interactive -d {{ letsencrypt.hostname }}"
  args:
    creates: "/etc/letsencrypt/live/{{ letsencrypt.hostname }}/privkey.pem"
  when: letsencrypt.enabled == true

- name: Set cert to renew every monday at 2:30 am
  cron:
    name: Certbot renew
    weekday: 1
    hour: 2
    minute: 30
    job: /usr/bin/letsencrypt renew --rsa-key-size 4096 --renew-hook "/usr/bin/monit restart nginx" >> /var/log/le-renew.log
    user: root
  when: letsencrypt.enabled == true

- name: Install letsencrypt
  command: bash -lc "git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt"
  args:
    creates: /opt/letsencrypt
  when: letsencrypt.enabled == true

- name: Get letsencrypt cert
  command: bash -lc "/opt/letsencrypt/letsencrypt-auto certonly --standalone --rsa-key-size 4096 --force-renew --agree-tos --email {{ letsencrypt.email }} --text --non-interactive -d {{ letsencrypt.hostname }}"
  args:
    creates: "/etc/letsencrypt/live/{{ letsencrypt.hostname }}/privkey.pem"
  when: letsencrypt.enabled == true

- name: Set cert to renew every monday at 2:30 am
  cron:
    name: Certbot renew
    weekday: 1
    hour: 2
    minute: 30
    job: /opt/letsencrypt/letsencrypt-auto renew --rsa-key-size 4096 --renew-hook "/usr/bin/monit restart nginx" >> /var/log/le-renew.log
    user: root
  when: letsencrypt.enabled == true

Use latest version of letsencrypt
Use latest version of letsencrypt
