【问题标题】:While rebooting the remote server its reboot the ansible server itself while executing below playbook在重新启动远程服务器时,它会在执行以下剧本时重新启动 ansible 服务器本身
【发布时间】:2020-05-27 23:12:22
【问题描述】:

  • 名称:重新启动 主机:检查点 任务:
    • 名称:重启检查点 命令:重启 注册:save_uptime
    • 调试: 味精:“重启完成”

它显示为“远程端意外关闭网络连接”它重新启动了 ansible 服务器而不是我的目标服务器。如何解决

【问题讨论】:

  • 嗨。您能否编辑您的问题并正确格式化您的代码?编辑屏幕右侧有格式化辅助工具。

标签: ssh ansible ansible-inventory checkpoint


【解决方案1】:

由于命令模块在所有选定的远程主机 (https://docs.ansible.com/ansible/latest/modules/command_module.html) 上运行指定的命令,我怀疑主机文件可能是您的问题。

另外,您可以使用模块重启 (https://docs.ansible.com/ansible/latest/modules/reboot_module.html) 来执行操作(假设您使用的是 Ansible 2.7+)

【讨论】:

  • 我正在使用 ansible 2.7,因为我在运行该剧本时也使用了 reboot 模块,它显示错误为“ FAILED!=> {“changed”:false,“elapsed”:0,“ msg": "使用本地连接运行 reboot 会重启控制节点。", "rebooted": false} "
  • 嗯,错误消息说您正在尝试使用 ansible 重新启动机器,(如预期的那样),所以我会检查主机文件。很可能错误就在这里。在 playbook 使用过程中查看警告,有时会出现这样的错误:[WARNING]: Unable to parse /path/to/hosts/file as an inventory source。之后你通常可以看到[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'。如果这是你的情况,那么主机文件就是问题
  • 在我的主机文件中,我得到了服务器详细信息,如 ansible_connection=local 和 ansible_username 和 ansible_password,如果我删除了 ansible_connection,它会显示错误为“ UNREACHABLE!=> {“changed”:false,“ msg": "身份验证或权限失败。在某些情况下,您可能已经能够进行身份验证并且没有目标目录的权限。考虑将 ansible.cfg 中的远程 tmp 路径更改为以 \"/tmp\" 为根的路径。 " 同时给出 ansible_connection= ssh 也显示相同的错误。
猜你喜欢
  • 2019-08-23
  • 2015-08-19
  • 1970-01-01
  • 1970-01-01
  • 2011-04-21
  • 1970-01-01
  • 1970-01-01
  • 2015-01-31
相关资源
最近更新 更多