softshipper
softshipper

Reputation: 34119

How to install -t?

I have the following statement, that I would like to translate into Ansible:

$ curl -L https://github.com/drone/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz | tar zx
$ sudo install -t /usr/local/bin drone  

How to build an Ansible task for it?

I've tried:

 - name: Extract droner exec runner into /usr/local/bin
   unarchive:
     src: drone_linux_amd64.tar.gz
     dest: /usr/local/bin/
     mode: "0664"

But it does not work as expected.

Upvotes: 1

Views: 239

Answers (2)

franklinsijo
franklinsijo

Reputation: 18300

install command manages the permissions of the file, making sure the execute permissions are added to the file during installation.

unarchive just extracts the contents of the archive file to the destination. Set the desired mode to the task, in this case to make it executable add the +x permission.

- name: Extract droner exec runner into /usr/local/bin
   unarchive:
     src: drone_linux_amd64.tar.gz
     dest: /usr/local/bin/
     mode: "a+x"

a+x, giving execute permission for all expecting the drone command will be used across users.

Upvotes: 1

Shreyash
Shreyash

Reputation: 456

- hosts: localhost
  become: yes
  gather_facts: no
  tasks:
     - name: Get the file from github
       get_url:
            url: "https://github.com/drone/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz"
            dest: /tmp/drone_linux_amd64.tar.gz
     - name: Unarchive the file
       unarchive:
            src: /tmp/drone_linux_amd64.tar.gz
            dest: /tmp
            mode: 0664
     - name: Install
       shell:
            cmd: install -t /usr/local/bin drone
            chdir: /tmp

Task 1: Fetching the file form the github with get_url. you can also you shell module. get_url module
Task 2: Unarchive the file using unarchive module. unarchive module
Task 3: Install with shell command shell module

I have unarchive it in the tmp folder. and then installed it.

Upvotes: 1

Related Questions