Remove loop redundancy
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Danny Bessems 2022-06-25 23:32:29 +02:00
parent a64b5b2325
commit 01991435ae
2 changed files with 29 additions and 34 deletions

View File

@ -0,0 +1,26 @@
---
- name: Initialize tempfolder
ansible.builtin.tempfile:
state: directory
register: archive
- name: Download, extract & install archived static binary
ansible.builtin.unarchive:
src: "{{ item.url }}"
dest: "{{ archive.path }}"
remote_src: yes
extra_opts: "{{ item.extra_opts | default(omit) }}"
- name: Install extracted binary
ansible.builtin.copy:
src: "{{ archive.path }}/{{ item.filename }}"
dest: /usr/local/bin/{{ item.filename }}
owner: root
group: root
mode: 0755
- name: Cleanup tempfolder
ansible.builtin.file:
path: "{{ archive.path }}"
state: absent
when: archive.path is defined

View File

@ -14,40 +14,9 @@
mode: 0755
loop: "{{ dependencies.static_binaries | selectattr('archive', 'undefined') }}"
- block:
- name: Initialize tempfolder
ansible.builtin.tempfile:
state: directory
register: archives
- name: Create destination sub folder
ansible.builtin.file:
path: "{{ archives.path }}/{{ item.filename }}"
state: directory
loop: "{{ dependencies.static_binaries | selectattr('archive', 'defined') | selectattr('archive', 'equalto', 'compressed') }}"
- name: Download, extract & install archived static binaries
ansible.builtin.unarchive:
src: "{{ item.url }}"
dest: "{{ archives.path }}/{{ item.filename }}"
remote_src: yes
extra_opts: "{{ item.extra_opts | default(omit) }}"
loop: "{{ dependencies.static_binaries | selectattr('archive', 'defined') | selectattr('archive', 'equalto', 'compressed') }}"
- name: Install extracted binaries
ansible.builtin.file:
src: "{{ archives.path }}/{{ item.filename }}/{{ item.filename }}"
dest: /usr/local/bin/{{ item.filename }}
owner: root
group: root
mode: 0755
loop: "{{ dependencies.static_binaries | selectattr('archive', 'defined') | selectattr('archive', 'equalto', 'compressed') }}"
- name: Cleanup tempfolder
ansible.builtin.file:
path: "{{ archives.path }}"
state: absent
when: archives.path is defined
- name: Download, extract & install archived static binaries
include_tasks: dependencies.archive_compressed.yml
loop: "{{ dependencies.static_binaries | rejectattr('archive', 'undefined') | selectattr('archive', 'equalto', 'compressed') }}"
- name: Install ansible-galaxy collections
ansible.builtin.shell: