大网数据广告活动
服务器运维问答

Where do I find the latest ansible error log

· 52CE 我爱测

I used an ansible script to bring a server configuration up. I was running the script from inside the server and doing everything at the localhost inventory. Now the ssh connection I had to the server closed and I cannot find the…

问题原文

原帖链接 · Felipe · CC BY-SA 3.0

I used an ansible script to bring a server configuration up. I was running the script from inside the server and doing everything at the localhost inventory.

Now the ssh connection I had to the server closed and I cannot find the log file. Where is the standard log path for this? Under /var/log there is no ansible file.

I am running the script again, and I expect the error to come again, but this is not a great solution since the script takes a few hours to run to the error point.

已采纳解答

原帖链接 · Duncan Lock · CC BY-SA 4.0

Ansible doesn't create its own logs by default - you have to tell it to do so, using an ansible.cfg file. Ansible does do some logging to syslog by default:

Note that ansible will, without this setting, record module arguments called to the syslog of managed machines.

So that'll log module args to the syslog of the machines you're managing.

To switch on full logging on your control machine, you can create an ansible.cfg file that looks like this:

[defaults]
log_path = ./ansible.log

Then save it somewhere ansible will look for it. Ansible checks these locations for ansible.cfg files, in this order:

  • ANSIBLE_CONFIG (an environment variable)
  • ansible.cfg (in the current directory)
  • .ansible.cfg (in the home directory)
  • /etc/ansible/ansible.cfg

An alternative option is to set the ANSIBLE_LOG_PATH environment variable, to the path you want to log to—it's equivalent to setting the log_path option in the ansible.cfg file.

See here for more information: http://docs.ansible.com/intro_configuration.html

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-08-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。