---
- name: Create temporary directory
  file:
    state: directory
    path: ~/kube-prompt
  register: dir

- name: Download kube-prompt
  get_url:
    url: https://github.com/c-bata/kube-prompt/releases/download/{{ kube_prompt_version }}/kube-prompt_{{ kube_prompt_version }}_linux_amd64.zip
    dest: "{{ dir.path }}/kube-prompt.zip"

- name: Unarchive kube-prompt
  unarchive:
    src: "{{ dir.path }}/kube-prompt.zip"
    dest: "{{ dir.path }}"
    remote_src: yes
    creates: "{{ dir.path }}/kube-prompt"

- name: Copy kube-prompt to bin
  copy:
    dest: /usr/bin/kprompt
    src: "{{ dir.path }}/kube-prompt"
    mode: u+x
    remote_src: yes