From 15dfaea8db18c9361a7174e6e99ec548fb615e1a Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 4 May 2025 23:35:58 -0700 Subject: [PATCH] Nomad completely setup with --tags nomad now --- ansible/nuc.yaml | 12 +------ .../roles/local-server-head/tasks/main.yaml | 10 +++++- .../roles/local-server-head/tasks/nomad.yaml | 34 +++++++++++++++++++ .../templates/hashicorp.list | 1 + 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 ansible/roles/local-server-head/tasks/nomad.yaml create mode 100644 ansible/roles/local-server-head/templates/hashicorp.list diff --git a/ansible/nuc.yaml b/ansible/nuc.yaml index 9f1202a..0313d4a 100644 --- a/ansible/nuc.yaml +++ b/ansible/nuc.yaml @@ -5,16 +5,6 @@ - name: Setup basic role on nigel tags: - setup + - nomad ansible.builtin.include_role: name: local-server-head - apply: - tags: - - setup - - name: Setup the docker based services - tags: - - services - ansible.builtin.include_role: - name: services - apply: - tags: - - services diff --git a/ansible/roles/local-server-head/tasks/main.yaml b/ansible/roles/local-server-head/tasks/main.yaml index 0fa527d..d7e9ec0 100644 --- a/ansible/roles/local-server-head/tasks/main.yaml +++ b/ansible/roles/local-server-head/tasks/main.yaml @@ -12,4 +12,12 @@ ansible.builtin.lineinfile: path: /etc/sudoers state: present - line: "nigel ALL=(ALL) NOPASSWD:ALL" \ No newline at end of file + line: "nigel ALL=(ALL) NOPASSWD:ALL" +- name: Run through nomad installation steps + tags: nomad + ansible.builtin.include_tasks: + file: nomad.yaml + apply: + become: true + tags: + - nomad \ No newline at end of file diff --git a/ansible/roles/local-server-head/tasks/nomad.yaml b/ansible/roles/local-server-head/tasks/nomad.yaml new file mode 100644 index 0000000..6d2e07e --- /dev/null +++ b/ansible/roles/local-server-head/tasks/nomad.yaml @@ -0,0 +1,34 @@ +- 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 nomad package + ansible.builtin.apt: + pkg: nomad \ No newline at end of file diff --git a/ansible/roles/local-server-head/templates/hashicorp.list b/ansible/roles/local-server-head/templates/hashicorp.list new file mode 100644 index 0000000..ecfd154 --- /dev/null +++ b/ansible/roles/local-server-head/templates/hashicorp.list @@ -0,0 +1 @@ +deb [signed-by={{ keyfile }}] https://apt.releases.hashicorp.com jammy main \ No newline at end of file