-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add install from repo rather than bins
- Loading branch information
Showing
5 changed files
with
135 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
# File: install_linux_repo.yml - package installation tasks for Nomad | ||
|
||
- name: Install OS packages | ||
ansible.builtin.package: | ||
name: "{{ item }}" | ||
state: present | ||
with_items: "{{ nomad_os_packages }}" | ||
tags: installation | ||
when: not ansible_facts['os_family'] == "VMware Photon OS" | ||
|
||
- name: Populate service facts | ||
ansible.builtin.service_facts: | ||
|
||
- name: Gather the package facts | ||
ansible.builtin.package_facts: | ||
manager: auto | ||
|
||
- name: Clean up previous nomad data | ||
block: | ||
- name: Stop service nomad, if running | ||
ansible.builtin.service: | ||
name: nomad | ||
state: stopped | ||
when: ansible_facts.services | join is match('.*nomad.*') | ||
|
||
- name: Remove nomad service unit files from previous installation | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: absent | ||
loop: | ||
- /usr/lib/systemd/system/nomad.service | ||
- /etc/init.d/nomad | ||
|
||
- name: Remove the user 'nomad' | ||
ansible.builtin.user: | ||
name: nomad | ||
state: absent | ||
remove: yes | ||
|
||
when: "'nomad' not in ansible_facts.packages" | ||
become: true | ||
|
||
- name: Install repository | ||
block: | ||
- name: Add Redhat/CentOS/Fedora/Amazon Linux repository | ||
ansible.builtin.command: "yum-config-manager --add-repo {{ nomad_repo_url }}" | ||
args: | ||
creates: /etc/yum.repos.d/hashicorp.repo | ||
when: "ansible_os_family|lower == 'redhat'" | ||
|
||
- name: Add an Apt signing key, uses whichever key is at the URL | ||
ansible.builtin.apt_key: | ||
url: "{{ nomad_repo_url }}/gpg" | ||
state: present | ||
when: "ansible_os_family|lower == 'debian'" | ||
|
||
- name: Add Debian/Ubuntu Linux repository | ||
ansible.builtin.apt_repository: | ||
repo: "deb {{ nomad_repo_url }} {{ ansible_distribution_release }} main" | ||
state: present | ||
update_cache: true | ||
when: "ansible_os_family|lower == 'debian'" | ||
|
||
when: "ansible_os_family|lower in [ 'debian', 'redhat' ]" | ||
become: true | ||
|
||
- name: Install nomad package | ||
ansible.builtin.package: | ||
name: "nomad{{ '=' if ansible_pkg_mgr == 'apt' else '-' }}{{ nomad_version }}" | ||
state: present | ||
become: true | ||
|
||
- name: Remove default configuration on first install | ||
ansible.builtin.file: | ||
dest: "{{ nomad_config_dir }}/nomad.hcl" | ||
state: absent | ||
when: "'nomad' not in ansible_facts.packages" | ||
become: true | ||
notify: | ||
- restart nomad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters