Search code examples
ansiblerke

Execute curl command in ansible playbook


I am trying to Install RKE2 with Ansible.

but the command for installing RKE2 aren't apt commands

command for installing rke2 is

curl -sfL https://get.rke2.io |  INSTALL_RKE2_VERSION=v1.21.6+rke2r1 sh -

I have no idea how to convert this command into playbook code

I did checked other posts about curl - ansible but it doesn't help on my case


Solution

  • Can this work ?

      vars:
        script_dir: mydir
      tasks:
      - file:
          state: directory
          path: "{{ script_dir }}"
      - name: download RKE2
        get_url:
          url: https://get.rke2.io
          validate_certs: false
          dest: "{{ script_dir }}/install.sh"
          mode: 0755
      - name: install RKE2
        command: "{{ script_dir }}/install.sh"
        environment:
          INSTALL_RKE2_VERSION: v1.21.6+rke2r1