- name: Create local Node runtime directory
  file:
    path: "{{ courseware_node_runtime_dir }}"
    state: directory
    mode: "0755"

- name: Install contained Node runtime for web tooling
  command:
    argv:
      - npm
      - install
      - "node@{{ courseware_node_runtime_version }}"
  args:
    chdir: "{{ courseware_node_runtime_dir }}"
    creates: "{{ courseware_node_runtime_bin_dir }}/node"

- name: Allow contained Node runtime to bind low ports on Linux
  become: true
  command:
    argv:
      - setcap
      - cap_net_bind_service=+ep
      - "{{ courseware_node_runtime_bin_dir }}/node"
  when: ansible_system == "Linux"
