42 lines
801 B
YAML
42 lines
801 B
YAML
---
|
|
- name: 部署Nomad服务器配置模板
|
|
hosts: nomad_servers
|
|
become: yes
|
|
|
|
tasks:
|
|
- name: 部署Nomad配置文件
|
|
template:
|
|
src: nomad-server.hcl.j2
|
|
dest: /etc/nomad.d/nomad.hcl
|
|
backup: yes
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
|
|
- name: 重启Nomad服务
|
|
systemd:
|
|
name: nomad
|
|
state: restarted
|
|
enabled: yes
|
|
|
|
- name: 等待Nomad服务启动
|
|
wait_for:
|
|
port: 4646
|
|
host: "{{ ansible_host }}"
|
|
timeout: 30
|
|
|
|
- name: 显示Nomad服务状态
|
|
systemd:
|
|
name: nomad
|
|
register: nomad_status
|
|
|
|
- name: 显示服务状态
|
|
debug:
|
|
msg: "{{ inventory_hostname }} Nomad服务状态: {{ nomad_status.status.ActiveState }}"
|
|
|
|
|
|
|
|
|
|
|
|
|