45 lines
1.0 KiB
YAML
45 lines
1.0 KiB
YAML
---
|
|
- name: 统一配置所有Nomad节点
|
|
hosts: nomad_nodes
|
|
become: yes
|
|
|
|
tasks:
|
|
- name: 备份当前Nomad配置
|
|
copy:
|
|
src: /etc/nomad.d/nomad.hcl
|
|
dest: /etc/nomad.d/nomad.hcl.bak
|
|
remote_src: yes
|
|
ignore_errors: yes
|
|
|
|
- name: 生成统一Nomad配置
|
|
template:
|
|
src: ../templates/nomad-unified.hcl.j2
|
|
dest: /etc/nomad.d/nomad.hcl
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
|
|
- name: 重启Nomad服务
|
|
systemd:
|
|
name: nomad
|
|
state: restarted
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
|
|
- name: 等待Nomad服务就绪
|
|
wait_for:
|
|
port: 4646
|
|
host: "{{ inventory_hostname }}.tailnet-68f9.ts.net"
|
|
delay: 10
|
|
timeout: 60
|
|
ignore_errors: yes
|
|
|
|
- name: 检查Nomad服务状态
|
|
command: systemctl status nomad
|
|
register: nomad_status
|
|
changed_when: false
|
|
|
|
- name: 显示Nomad服务状态
|
|
debug:
|
|
var: nomad_status.stdout_lines
|