54 lines
1.5 KiB
YAML
54 lines
1.5 KiB
YAML
- name: Ensure prerequisite packages are installed
|
|
ansible.builtin.apt:
|
|
pkg:
|
|
- wget
|
|
- gpg
|
|
- coreutils
|
|
update_cache: true
|
|
- name: Hashicorp repo setup
|
|
vars:
|
|
keypath: /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
|
gpgpath: /tmp/hashicorp.gpg
|
|
block:
|
|
- name: Download the hashicorp GPG Key
|
|
ansible.builtin.get_url:
|
|
url: https://apt.releases.hashicorp.com/gpg
|
|
dest: "{{ gpgpath }}"
|
|
- name: Dearmor the hashicorp gpg key
|
|
ansible.builtin.command:
|
|
cmd: "gpg --dearmor --yes -o {{ keypath }} {{ gpgpath }}"
|
|
register: gpg
|
|
changed_when: gpg.rc == 0
|
|
- name: Add the hashicorp linux repo
|
|
vars:
|
|
keyfile: "{{ keypath }}"
|
|
ansible.builtin.template:
|
|
src: hashicorp.list
|
|
dest: /etc/apt/sources.list.d/hashicorp.list
|
|
mode: "0644"
|
|
- name: Update apt repo cache
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
- name: Install consul
|
|
ansible.builtin.apt:
|
|
name: consul
|
|
- name: Install nomad package
|
|
ansible.builtin.apt:
|
|
pkg: nomad
|
|
- name: Copy in the consul configuration
|
|
vars:
|
|
ip: "{{ ansible_default_ipv4['address'] }}"
|
|
ansible.builtin.template:
|
|
src: consul.hcl
|
|
dest: /etc/consul.d/consul.hcl
|
|
mode: "0644"
|
|
- name: Start nomad
|
|
ansible.builtin.systemd_service:
|
|
name: nomad
|
|
state: started
|
|
enabled: true
|
|
- name: Make sure the consul service is NOT available
|
|
ansible.builtin.systemd_service:
|
|
name: consul
|
|
state: stopped
|
|
enabled: true |