greenhost / certbot-haproxy

HAProxy plugin for Let's Encrypt's Certbot
Other
126 stars 21 forks source link

Error: We're sorry, your OS %s %s is currently not supported #21

Closed cmonty14 closed 4 years ago

cmonty14 commented 6 years ago

Hi, I have installed this plugin on Alpine Linux 3.7 with Python 2.7, but I get this error when running certbot:

vm102-haproxy:~# certbot --dry-run 

We're sorry, your OS %s %s is currently not supported :( you may be able to get this plugin working by defining a list of CLI_DEFAULTS in our constants module. Please consider making a pull-request if you do!

This OS is obviously not included in the constants.py file, therefore I have added these lines:

CLI_DEFAULTS_ALPINE_LINUX_OPENRC_OS = dict(
    service_manager='service',
    version_cmd=['/usr/sbin/haproxy', '-v'],
    restart_cmd=['service', 'haproxy', 'restart'],
    # Needs the config file as an argument:
    conftest_cmd=['/usr/sbin/haproxy', '-c', '-f'],
    haproxy_config='/etc/haproxy/haproxy.cfg',
    # Needs to be writeable by the user that will run certbot
    crt_directory='/var/lib/certbot/haproxy_fullchains',
)

However I think this issue is caused by the coding to identify the OS version etc.

    os_info = util.get_os_info()
    distro = os_info[0].lower()
    version = os_info[1]

How can this issue be fixed?

SnijderC commented 6 years ago

Did you add the dictionary to the CLI_DEFAULTS dictionary just below?

CLI_DEFAULTS = {
    "debian": {
        '_min_version': '7',
        '_max_version': '8',
        '7': CLI_DEFAULTS_DEBIAN_BASED_PRE_SYSTEMD_OS,
        '8': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS
    },
    "ubuntu": {
        '_min_version': '14.04',
        '_max_version': '16.04',
        '14.04': CLI_DEFAULTS_DEBIAN_BASED_PRE_SYSTEMD_OS,
        '14.10': CLI_DEFAULTS_DEBIAN_BASED_PRE_SYSTEMD_OS,
        '15.04': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS,
        '15.10': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS,
        '16.04': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS
    }
}

See this docker example (simplest way I could think of to quickly spawn an alpine machine):

FROM python:3.6.6-alpine3.7
RUN apk upgrade --no-cache
RUN apk add g++ libffi-dev openssl-dev
RUN pip install certbot
CMD python -c 'from certbot import util;os_info = util.get_os_info();distro = os_info[0].lower();version = os_info[1];print("{} version {}".format(distro, version))'
$ docker build -t test-alpine .
$ docker run test-alpine
alpine version 3.7.0

So I'm guessing you can add

"alpine": {
        '_min_version': '3.6',
        '_max_version': '3.8',
        '3.6': CLI_DEFAULTS_ALPINE_LINUX_OPENRC_OS,
        '3.7': CLI_DEFAULTS_ALPINE_LINUX_OPENRC_OS,
        '3.8': CLI_DEFAULTS_ALPINE_LINUX_OPENRC_OS
    }

to CLI_DEFAULT and you should be good to go, if it works, please submit a PR and I will be glad to merge it.