Here we will install unzip, get a zip file from a URL and unzip and install at the destination location.

Below is the example code

sudo nano install-unzip-terraform.yml
---
- hosts: fileservers
  become: true
  tasks:
  - name: install unzip on centos
    tags: "terraform,unzip"
    dnf:
      name: unzip
      state: latest
    when: ansible_distribution == 'CentOS'

- hosts: fileservers
  become: true
  tasks:
  - name: Install terraform from zip
    tags: "terraform,unzip"
    unarchive:
      src: https://releases.hashicorp.com/terraform/1.12.2/terraform_1.12.2_linux_386.zip
      dest: /usr/local/bin
      remote_src: yes
      mode: 07555
      owner: root
      group: root
    when: ansible_distribution == 'CentOS'
ansible-playbook --ask-become-pass install-unzip-terraform.yml

screenshots below

before and after screenshots from managed node (destination)

By Kad

Leave a Reply

Your email address will not be published. Required fields are marked *