51 lines
1.5 KiB
YAML
51 lines
1.5 KiB
YAML
---
|
|
# tasks file for hugo
|
|
|
|
- name: Créer l'emplacement de stockage du binaire
|
|
ansible.builtin.file:
|
|
state: directory
|
|
path: "{{ hugo_binary_path }}"
|
|
mode: u=rwX,g=rX,o=rX
|
|
become: true
|
|
|
|
- name: Modifier l'URL pour pointer vers la version souhaitée
|
|
ansible.builtin.set_fact:
|
|
hugo_latest_url: "{{ hugo_latest_url | replace('latest', version) }}"
|
|
when: hugo_version != "latest"
|
|
vars:
|
|
version: "tags/v{{ hugo_version }}"
|
|
|
|
- name: Récupérer le contenu du fichier de version
|
|
ansible.builtin.uri:
|
|
url: "{{ hugo_latest_url }}"
|
|
return_content: true
|
|
follow_redirects: all
|
|
register: releases
|
|
|
|
- name: Extraire l'URL du paquet
|
|
ansible.builtin.set_fact:
|
|
browser_download_url: >
|
|
{{
|
|
releases.json.assets |
|
|
rejectattr('browser_download_url', 'search', 'extended', 'ignorecase=true') |
|
|
selectattr('browser_download_url', 'search', '.tar.gz', 'ignorecase=true') |
|
|
selectattr('browser_download_url', 'search', hugo_os, 'ignorecase=true') |
|
|
selectattr('browser_download_url', 'search', hugo_architecture, 'ignorecase=true') |
|
|
map(attribute='browser_download_url')
|
|
}}
|
|
|
|
- name: Extraire l'archive
|
|
ansible.builtin.unarchive:
|
|
src: "{{ browser_download_url | first }}"
|
|
dest: "{{ hugo_binary_path }}"
|
|
remote_src: true
|
|
list_files: true
|
|
mode: u=rwX,g=rX,o=rX
|
|
become: true
|
|
|
|
- name: Installer la commande
|
|
ansible.builtin.command:
|
|
cmd: install -t /usr/local/bin /opt/hugo/hugo
|
|
when: hugo_install_command
|
|
become: true
|