---
# The retries are for random lock failures.
- name: install build-essential and musl
  become: True
  ansible.builtin.package:
    name: "{{ item }}"
    state: present
  with_items:
    - build-essential
    - musl
    - musl-tools
  register: result
  until: result is succeeded
  retries: 3
  delay: 5

- name: install rustup and musl target
  ansible.builtin.shell: |
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  -s -- --default-toolchain stable -y
    source $HOME/.cargo/env
    rustup target add x86_64-unknown-linux-musl
  args:
    creates: "{{ ansible_env.HOME }}/.cargo/env"
    executable: /bin/bash
