mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-04-16 10:13:26 +02:00
105 lines
2.8 KiB
YAML
105 lines
2.8 KiB
YAML
---
|
|
|
|
- name: Install needed tools
|
|
package:
|
|
name:
|
|
- tar
|
|
- zstd
|
|
- unzip
|
|
tags: nomad
|
|
|
|
- name: Install task driver packages
|
|
package: name={{ nomad_task_driver_packages[item] }}
|
|
loop: "{{ nomad_enabled_task_drivers }}"
|
|
when: nomad_task_driver_packages[item] is defined and nomad_conf.client.enabled
|
|
notify: restart nomad
|
|
tags: nomad
|
|
|
|
- when: nomad_install_mode == 'upgrade'
|
|
name: Clear plugin dir on upgrades
|
|
file: path={{ nomad_root_dir }}/plugins state={{ item }} owner={{ nomad_user }} group={{ nomad_user }}
|
|
loop:
|
|
- absent
|
|
- directory
|
|
tags: nomad
|
|
|
|
- when: nomad_install_mode != 'none'
|
|
block:
|
|
- name: Download nomad
|
|
get_url:
|
|
url: "{{ nomad_archive_url }}"
|
|
dest: "{{ nomad_root_dir }}/tmp"
|
|
checksum: sha256:{{ nomad_archive_sha256 }}
|
|
|
|
- name: Extract the archive
|
|
unarchive:
|
|
src: "{{ nomad_root_dir }}/tmp/nomad_{{ nomad_version }}_linux_amd64.zip"
|
|
dest: "{{ nomad_root_dir }}/tmp"
|
|
remote_src: True
|
|
|
|
- name: Install nomad binary
|
|
copy:
|
|
src: "{{ nomad_root_dir }}/tmp/nomad"
|
|
dest: "{{ nomad_root_dir }}/bin/nomad"
|
|
remote_src: True
|
|
mode: 755
|
|
notify: restart nomad
|
|
|
|
- name: Link in /usr/local/bin
|
|
file: src={{ nomad_root_dir }}/bin/nomad dest=/usr/local/bin/nomad state=link force=True
|
|
|
|
- name: Download plugins
|
|
get_url:
|
|
url: "{{ nomad_plugins[item].archive_url }}"
|
|
dest: "{{ nomad_root_dir }}/tmp"
|
|
checksum: sha256:{{ nomad_plugins[item].sha256 }}
|
|
register: nomad_plugin_dl
|
|
loop: "{{ nomad_plugins.keys() | list }}"
|
|
|
|
- name: Extract nomad plugins
|
|
unarchive:
|
|
src: "{{ item.dest }}"
|
|
dest: "{{ nomad_root_dir }}/plugins/"
|
|
remote_src: True
|
|
loop: "{{ nomad_plugin_dl.results }}"
|
|
notify: restart nomad
|
|
|
|
tags: nomad
|
|
|
|
# Nomad looks for the qemu-system-x86_64 bin in $PATH
|
|
# so it needs to be available for Nomad to detect it
|
|
- name: Link qemu-kvm to qemu-system-x86_64
|
|
file:
|
|
src: /usr/libexec/qemu-kvm
|
|
dest: /usr/local/bin/qemu-system-x86_64
|
|
state: link
|
|
when: nomad_conf.client.enabled and 'qemu' in nomad_enabled_task_drivers
|
|
tags: nomad
|
|
|
|
- name: Install bash completion support
|
|
copy:
|
|
content: |
|
|
complete -C {{ nomad_root_dir }}/bin/nomad nomad
|
|
dest: /etc/bash_completion.d/nomad
|
|
mode: 755
|
|
tags: nomad
|
|
|
|
- name: Deploy systemd service unit
|
|
template: src=nomad.service.j2 dest=/etc/systemd/system/nomad.service
|
|
register: nomad_unit
|
|
notify: restart nomad
|
|
tags: nomad
|
|
|
|
- name: Reload systemd
|
|
systemd: daemon_reload=True
|
|
when: nomad_unit.changed
|
|
tags: nomad
|
|
|
|
- name: Install backup hooks
|
|
template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/nomad mode=755
|
|
loop:
|
|
- pre
|
|
- post
|
|
tags: nomad
|
|
|