Skip to content

Commit

Permalink
Add lego-installing role.
Browse files Browse the repository at this point in the history
  • Loading branch information
damiendart committed Sep 3, 2024
1 parent 8ba9d82 commit cbd61fa
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions playbook-provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- 'base'
- 'certbot'
- 'imagemagick'
- 'lego'
- 'livepatch'
- 'monitoring'
- 'webserver'
Expand Down
21 changes: 21 additions & 0 deletions roles/lego/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file was written by Damien Dart, <[email protected]>. This is
# free and unencumbered software released into the public domain. For
# more information, please refer to the accompanying "UNLICENCE" file.

---
# A string containing a checksum used to verify the integrity of the
# lego binary archive "lego_4.18.0_linux_amd64.tar.gz". See
# <https://github.com/go-acme/lego/releases> for archives and checksums.
lego__lego_archive_checksum: 'sha256:6f42e9ac93cd604951c0cf94a7c4a26ac98251741523ce67eea86ad72c77e6e5'

# A string containing the version of lego to install.
lego__lego_version: '4.18.0'


# The following variables will have host-specific and/or sensitive
# values and must be defined elsewhere (in an inventory, playbook, at
# runtime, etc).

# A string containing the directory where downloaded files are stored to
# prevent unnecessary downloading when tasks are rerun.
lego__download_cache_directory: '{{ undef() }}'
7 changes: 7 additions & 0 deletions roles/lego/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was written by Damien Dart, <[email protected]>. This is
# free and unencumbered software released into the public domain. For
# more information, please refer to the accompanying "UNLICENCE" file.

---
dependencies:
- role: 'webserver'
32 changes: 32 additions & 0 deletions roles/lego/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file was written by Damien Dart, <[email protected]>. This is
# free and unencumbered software released into the public domain. For
# more information, please refer to the accompanying "UNLICENCE" file.

---
- name: 'Ensure download cache directory exists'
ansible.builtin.file:
path: '{{ lego__download_cache_directory }}'
group: 'root'
mode: '0777'
owner: 'root'
state: 'directory'

- name: 'Ensure the lego binary archive is downloaded'
ansible.builtin.get_url:
checksum: '{{ lego__lego_archive_checksum }}'
dest: '{{ lego__download_cache_directory }}/lego_v{{ lego__lego_version }}_linux_amd64.tar.gz'
group: 'root'
mode: 0755
owner: 'root'
url: 'https://github.com/go-acme/lego/releases/download/v{{ lego__lego_version }}/lego_v{{ lego__lego_version }}_linux_amd64.tar.gz'

- name: 'Ensure the lego binary is installed'
ansible.builtin.unarchive:
dest: '/usr/local/bin'
include:
- 'lego'
group: 'root'
mode: 0755
owner: 'root'
remote_src: true
src: '{{ lego__download_cache_directory }}/lego_v{{ lego__lego_version }}_linux_amd64.tar.gz'

0 comments on commit cbd61fa

Please sign in to comment.