【发布时间】:2021-03-31 16:33:39
【问题描述】:
我正在使用 Ansible AWX 发出重启命令来重启主机上的 apache2 服务。 restart 命令包含在剧本中。
---
- name: Manage Linux Services
hosts: all
tasks:
- name: Restart a linux service
command: systemctl restart '{{ service_name }}'
register: result
ignore_errors: yes
- name: Show result of task
debug:
var: result
或
---
- name: Manage Linux Services
hosts: all
tasks:
- name: Restart a linux service
ansible.builtin.service:
name: '{{ service_name }}'
state: restarted
register: result
ignore_errors: yes
- name: Show result of task
debug:
var: result
但是,当我运行命令时,我收到以下错误:
"Failed to restart apache2.service: Connection timed out",
"See system logs and 'systemctl status apache2.service' for details."
我试图找出问题所在,但还没有运气。
【问题讨论】:
标签: ansible ansible-awx