role_hugo/tasks/installation.yml
2023-06-18 12:54:56 +02:00

51 lines
1.4 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') |
selectattr('browser_download_url', 'search', '.tar.gz') |
selectattr('browser_download_url', 'match', '(?i)' + hugo_os) |
selectattr('browser_download_url', 'match', '(?i)' + hugo_architecture) |
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