39 lines
892 B
YAML
39 lines
892 B
YAML
---
|
|
- name: 配置Nomad客户端节点
|
|
hosts: nomad_clients
|
|
become: yes
|
|
vars:
|
|
nomad_config_dir: /etc/nomad.d
|
|
|
|
tasks:
|
|
- name: 创建Nomad配置目录
|
|
file:
|
|
path: "{{ nomad_config_dir }}"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
|
|
- name: 复制Nomad客户端配置模板
|
|
template:
|
|
src: ../templates/nomad-client.hcl
|
|
dest: "{{ nomad_config_dir }}/nomad.hcl"
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
|
|
- name: 启动Nomad服务
|
|
systemd:
|
|
name: nomad
|
|
state: restarted
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
|
|
- name: 检查Nomad服务状态
|
|
command: systemctl status nomad
|
|
register: nomad_status
|
|
changed_when: false
|
|
|
|
- name: 显示Nomad服务状态
|
|
debug:
|
|
var: nomad_status.stdout_lines |