Added ubuntu setup
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
45
roles/ubuntu/tasks/hashicorp_vagrant.yml
Normal file
45
roles/ubuntu/tasks/hashicorp_vagrant.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
- 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
|
||||
become: true
|
||||
|
||||
- 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
|
||||
become: true
|
||||
|
||||
- name: Update apt cache after adding Hashicorp repository
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600 # Cache validity in seconds
|
||||
become: true
|
||||
|
||||
- name: Install Vagrant
|
||||
ansible.builtin.apt:
|
||||
name: vagrant
|
||||
state: present
|
||||
become: true
|
||||
Reference in New Issue
Block a user