首页 > 解决方案 > Ansible 创建两个文件

问题描述

我正在使用 Ansbile 2.9 和 python 3.6.9 。我创建了一个脚本来从 cisco nxos 捕获“show-tech”。

因此,在我的脚本中,我将 showtech 文件保存在 bootflash 上,而不是使用 net_get 模块将其复制到 ansible 控制器到特定文件夹中

一切似乎都工作正常,但我看到的问题是创建一个额外的输出文件,随机名称如“0d4cfa0ae57-439d-48ef-aac0-944a882ddcb”

该文件具有我从设备复制并存储在特定位置的相同数据。

所以我的问题是为什么 Ansible 会创建这个附加文件以及如何让它停止?

  - name: "creating local folder cisco-nxos-showtech"
        file:
          path: cisco-nxos-showtech
          state: directory
          mode: '777'


      - name: Copying file from nxos device to local cisco-nxos-showtech folder
        net_get:
          src: "showtech-{{ ansible_net_hostname }}
          dest: "cisco-nxos-showtech"

标签: ansible

解决方案


Ansible 在操作期间使用临时文件。检查您的 ansible.cfg 文件并根据需要指定 local_tmp 文件夹。在这里阅读更多:

https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg


推荐阅读