Ansible Tower localhost 任务的行为不同

问题描述

我正在尝试在我的 ansible 塔式服务器上以“delegate_to:localhost”和“connection:local”的形式运行任务。 我的 awx 项目目录位于默认路径 - "/var/lib/awx/projects/ITTE"

- name: Downloading  a backup outside the KSDF File System
  connection: local
  command: 'sudo curl -N -fsSu {{ ansible_ssh_user }}:{{ ansible_ssh_pass }} https://10.10.10.11/backups/{{ identifier }}.kfb -o /home/ittecef/fabric_backups/{{ backup_name }}.kfb --insecure'
  args:
   chdir: /home/ittecef/fabric_backups/
   creates: "{{ backup_name}}.kfb"
  delegate_to: localhost
  register: B

我遇到的问题是上述任务失败并出现以下错误

{
"msg": "Unable to change directory before execution: [Errno 2] No such file or directory: b'/home/ittecef/fabric_backups'","invocation": {
    "module_args": {
        "chdir": "/home/ittecef/fabric_backups/","creates": "1.11-624-2021-02-23_01:24:37.kfb",

我确定目录 /home/ittecef/fabric_backups 存在。 但是当我将任务更改为

时任务成功
- name: Downloading  a backup outside the KSDF File System
  connection: local
  command: 'sudo curl -N -fsSu {{ ansible_ssh_user }}:{{ ansible_ssh_pass }} https://10.10.10.11/backups/{{ identifier }}.kfb -o /var/lib/awx/projects/ITTE/{{ backup_name }}.kfb --insecure'
  args:
     chdir: /var/lib/awx/projects/ITTE
     creates: "{{ backup_name}}.kfb"
  delegate_to: localhost
  register: B

为什么塔无法识别 awx 中默认项目之外的路径,或者是因为我似乎做错了什么。

我真的很想了解这一点。任何答案将不胜感激。 我看到另一个类似的帖子 - https://www.reddit.com/r/ansible/comments/ik4te2/issue_with_delegate_to_localhost_and_get_url/

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)