diff --git a/tasks/build-binary-v0.2.yml b/tasks/build-binary-v0.2.yml new file mode 100644 index 0000000..61bf0d5 --- /dev/null +++ b/tasks/build-binary-v0.2.yml @@ -0,0 +1,53 @@ +--- +- name: "Install packages (Ubuntu)" + apt: + pkg: + - git + - golang-go + - libcap-dev + - make + state: latest + when: ansible_os_family != "RedHat" + +- name: "Install packages (CentOS/RedHat)" + yum: + name: + - git + - golang + - libcap-devel + - make + state: latest + when: ansible_os_family == "RedHat" + +- set_fact: + acmetool_build_dir: /tmp/acmetool-tmp + +- name: "Create build dir" + file: + path: "{{ acmetool_build_dir }}" + state: directory + +- name: "Remove old build dir" + file: + path: "{{ acmetool_build_dir }}/acme" + state: absent + +- name: "Set git options" + command: git config --global http.followRedirects true + +- name: "Clone acmetool repository" + git: + repo: https://github.com/hlandau/acme + dest: "{{ acmetool_build_dir }}/acme" + +- name: "Build acmetool" + make: + chdir: "{{ acmetool_build_dir }}/acme" + +- name: "Install and backup old binary" + copy: + remote_src: yes + mode: 0755 + src: "{{ acmetool_build_dir }}/acme/bin/acmetool" + dest: /usr/bin/acmetool + backup: yes diff --git a/tasks/main.yml b/tasks/main.yml index af0c441..d17110e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,9 +39,34 @@ state: "directory" tags: acmetool-install +- name: "Get the version of the installed acmetool package (RH/CentOS)" + shell: rpm -qa --queryformat '%{version}' acmetool + args: + warn: false + register: acmetool_version_centos + when: ansible_os_family == "RedHat" + tags: acmetool-install + +- name: "Get the version of the installed acmetool package (Debian)" + shell: dpkg-query -f='${Version}' -W 'acmetool' | sed 's/-.*$//' + register: acmetool_version_ubuntu + when: ansible_os_family == "Debian" + tags: acmetool-install + +- set_fact: + installed_acmetool_version: > + "{{ acmetool_version_centos.stdout | + default(acmetool_version_ubuntu.stdout) }}" + tags: acmetool-install + +- name: "Install acmetool v0.2 workaround (RH/CentOS)" + include_tasks: "build-binary-v0.2.yml" + when: installed_acmetool_version is version('0.2.0', '<') + tags: acmetool-install + - set_fact: acmetool_responses_method: "stateless" - when: acmetool_websrv == "nginx" + when: acmetool_websrv == "nginx" tags: - acmetool-install - acmetool-websrv @@ -49,7 +74,7 @@ - set_fact: acmetool_responses_method: "proxy" - when: acmetool_websrv == "apache" + when: acmetool_websrv == "apache" tags: - acmetool-install - acmetool-websrv @@ -59,7 +84,7 @@ template: src: "response-file.yml.j2" dest: "/var/lib/acme/conf/responses" - tags: + tags: - acmetool-install - acmetool-update-response-file @@ -88,5 +113,5 @@ include: "nginx-stateless-disable-temp-site.yml" tags: acmetool-websrv when: - - acmetool_want is defined - - acmetool_websrv == "nginx" + - acmetool_want is defined + - acmetool_websrv == "nginx"