gpt4 book ai didi

module - 未创建多个 Ansible 存档

转载 作者:行者123 更新时间:2023-12-04 19:42:41 27 4
gpt4 key购买 nike

我试图通过使用归档模块从 2 个文件夹中创建 2 个归档。

不幸的是,它无法正常工作,没有任何错误。

我的任务如下所示:

  tasks:
- name: create a tarball of logfiles
archive:
path: "{{ item.path }}"
dest: /tmp/{{ ansible_hostname }}_{{ item.name }}_{{ ansible_date_time.date }}.tar.gz
register: ausgabe
with_items:
- { name: 'xxxxxx', path: '/opt/jira/xxx/xxxxxx' }
- { name: 'xxxxxxx', path: '/opt/jira/xxxx/xxxxxxx' }

输出:
TASK [create a tarball of logfiles] ************************************************************************************************************************************************
ok: [xxxxxxx] => (item={u'path': u'/opt/jira/xxx/xxxx', u'name': u'xxxxx'})
ok: [xxxxxxx] => (item={u'path': u'/opt/jira/xxx/xxxx', u'name': u'xxxxxx'})

未创建 tar.gz 文件。

有人可以帮我吗?

谢谢

哈利

最佳答案

每当您使用变量或“模板化”您的剧本时,请确保您正确使用“(反逗号)。

我已经修改了您归档模块的语句,并且得到了所需的结果。

  archive: 
dest: "/tmp/{{ ansible_hostname }}_{{ item.name }}_{{ ansible_date_time.date }}.tar.gz"
path: "{{ item.path }}"

输出:
myHost_xxxxxx_2018-06-12.tar.gz
myHost_xxxxxxx_2018-06-12.tar.gz

关于module - 未创建多个 Ansible 存档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50793069/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com