
--- 
- name: mf qmk.yml
  hosts: localhost
  gather_facts: True
  vars: 
    install_dir: "{{ ansible_env.HOME }}/.local/qmk"
  tasks:

   - name: apt update cache
     apt: 
       update_cache: True
       cache_valid_time: 1800 #30m
     become: True

   - name: qmk - apt install tools
     apt: 
       update_cache: True
       cache_valid_time: 1800 #30m
       state: latest
       pkg:
         - python3-pip
         - clang-format-14
         - libclang-cpp14
         - libftdi1
         - libhidapi-libusb0
         - libllvm14
         - libnewlib-dev
         - libstdc++-arm-none-eabi-dev
         - libstdc++-arm-none-eabi-newlib
         - libusb-0.1-4
         - avr-libc
         - avrdude
         - binutils-arm-none-eabi
         - binutils-avr
         - clang-format
         - clang-format-14
         - dfu-programmer
         - dfu-util
         - gcc-arm-none-eabi
         - gcc-avr
         - libclang-cpp14
         - libftdi1
         - libhidapi-hidraw0
         - libhidapi-libusb0
         - libllvm14
         - libnewlib-arm-none-eabi
         - libnewlib-dev
         - libstdc++-arm-none-eabi-dev
         - libstdc++-arm-none-eabi-newlib
         - libusb-0.1-4
         - libusb-dev
         - teensy-loader-cli
         - wget
         - zip
         # wb32-dfu-updater
         - cmake
         - libudev-dev
     become: True

   - name: qmk - python3 + venv + qmk
     pip: 
       name: qmk
       virtualenv: "{{ install_dir }}/venv"
       virtualenv_command: "python3 -m venv"

   - name: qmk - setup
     command:
       argv: 
        - "{{ install_dir }}/venv/bin/qmk"
        - "setup"
        - "--home={{ install_dir }}/qmk_firmware"
        - "--yes"
       creates: "{{ install_dir }}/qmk_firmware"

 # TODO 
 # git clone https://github.com/WestberryTech/wb32-dfu-updater.git

