-3

I currently have a doubt for my last line of code to make it work in Ansible, the code is the following:

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install apache2 python-letsencrypt-apache

sudo letsencrypt --apache

sudo apt-get install python-software-properties

sudo apt-get install software-properties-common

sudo add-apt-repository ppa:certbot/certbot

sudo apt-get install python-certbot-apache

sudo certbot --webroot-path /var/www/html -d www.web.tk

Now I would like to convert it to Ansible:

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

- apt:
    name: "{{ item }}"
    update_cache: yes
  with_items:
    - all items above

But I have a problem as the line sudo letsencrypt --apache requires user interaction and I would like to give it the website and email from Ansible inventory file

3
  • Please add the error logs
    – 030
    Mar 25 '18 at 8:03
  • There is no error log, when I do it manually I have no error whatsoever just the translation to Ansible code to execute the raw code with the email and address automatically.
    – Brask
    Mar 25 '18 at 9:11
  • I suggest to not reinvent the wheel and use an ansible role from galaxy like galaxy.ansible.com/030/certbot
    – 030
    Mar 25 '18 at 12:37
1

If you really want to create the role yourself, you have to use --agree-tos --noninteractive to disable user interaction.

See https://certbot.eff.org/docs/using.html for more details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.