--- - name: 紧急修复Nomad bootstrap_expect配置 hosts: nomad_servers become: yes tasks: - name: 修复bootstrap_expect为3 lineinfile: path: /etc/nomad.d/nomad.hcl regexp: '^ bootstrap_expect = \d+' line: ' bootstrap_expect = 3' backup: yes - 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: 显示Nomad服务状态 debug: msg: "{{ inventory_hostname }} Nomad服务状态: {{ nomad_status.status.ActiveState }}"