Files
ansible-edge/roles/setup/tasks/hashicorp_vagrant.yml
Tuan-Dat Tran 40a7e1dab7 initial commit
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2025-01-21 23:13:01 +01:00

44 lines
1.4 KiB
YAML

---
# roles/setup/tasks/hashicorp_vagrant.yml
- name: Download Hashicorp GPG key
ansible.builtin.get_url:
url: https://apt.releases.hashicorp.com/gpg
dest: /tmp/hashicorp_gpg
mode: "0644"
register: hashicorp_gpg_download
- name: Dearmor Hashicorp GPG key
ansible.builtin.command:
cmd: gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg /tmp/hashicorp_gpg
args:
creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
when: hashicorp_gpg_download.changed
- name: Remove temporary Hashicorp GPG key file
ansible.builtin.file:
path: /tmp/hashicorp_gpg
state: absent
when: hashicorp_gpg_download.changed
- name: Add Hashicorp APT repository
ansible.builtin.apt_repository:
repo: "deb [arch={{ ansible_architecture }} signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ ansible_lsb.codename }} main"
filename: hashicorp
state: present
vars:
ansible_lsb:
codename: "{{ ansible_facts['lsb']['codename'] }}"
ansible_architecture: "{{ ansible_facts['architecture'] }}"
when: hashicorp_gpg_download.changed
- name: Update apt cache after adding Hashicorp repository
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 3600 # Cache validity in seconds
- name: Install Vagrant
ansible.builtin.apt:
name: vagrant
state: present