Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build binary when package version < 0.2 #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tasks/build-binary-v0.2.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 30 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,42 @@
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
- acmetool-update-response-file

- set_fact:
acmetool_responses_method: "proxy"
when: acmetool_websrv == "apache"
when: acmetool_websrv == "apache"
tags:
- acmetool-install
- acmetool-websrv
Expand All @@ -59,7 +84,7 @@
template:
src: "response-file.yml.j2"
dest: "/var/lib/acme/conf/responses"
tags:
tags:
- acmetool-install
- acmetool-update-response-file

Expand Down Expand Up @@ -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"