k8s-clusters/ansible/k3s-node/tasks/aur.yml
2022-02-06 15:52:03 -06:00

59 lines
1.7 KiB
YAML

- name: AUR | get package metadata for {{ pkg_name }}
connection: local
become: no
uri: >
url=https://aur.archlinux.org/rpc?v=5&type=info&arg={{ pkg_name | mandatory }}
return_content=yes
timeout=6
register: api_info
- assert:
that:
- api_info.status == 200
- api_info.json is defined
- api_info.json.type == 'multiinfo'
- api_info.json.resultcount == 1
- api_info.json.results is defined
- name: AUR | download tarball for package {{ pkg_name }}
become: no
connection: local
get_url: >
url='https://aur.archlinux.org{{ api_info.json.results[0].URLPath }}'
dest='/tmp/'
register: aur_tarball
- name: AUR | cleanup old {{ pkg_name }} builds
ansible.builtin.file:
path: /tmp/{{ pkg_name }}
state: absent
- name: AUR | upload and extract package {{ pkg_name }} tarball to host
become: yes
become_user: '{{ makepkg_nonroot_user }}'
unarchive: >
src={{ aur_tarball.dest }}
dest=/tmp/
register: extracted_pkg
- name: AUR | get dependencies and build package {{ pkg_name }}
when: extracted_pkg.changed
become: yes
become_user: '{{ makepkg_nonroot_user }}'
command: >
makepkg --noconfirm --noprogressbar -mfs
chdir=/tmp/{{ pkg_name }}
register: aur_makepkg_result
- shell: 'ls -1 /tmp/{{ pkg_name | quote }} | grep pkg.tar'
register: compiled_package_name
- name: AUR | install {{ pkg_name }} with pacman
when: aur_makepkg_result.changed
become: yes
shell: >
pacman --noconfirm --noprogressbar --needed -U {{ compiled_package_name.stdout | quote }}
chdir=/tmp/{{ pkg_name }}
register: pacman_install_result
changed_when: pacman_install_result.stdout is defined and pacman_install_result.stdout.find('there is nothing to do') == -1