【问题标题】:Multiple Ansible archive(s) are not created未创建多个 Ansible 存档
【发布时间】:2018-11-20 10:17:40
【问题描述】:

我正在尝试使用存档模块从 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 文件。

有人可以帮我解决这个问题吗?

谢谢

哈利

【问题讨论】:

    标签: module centos ansible redhat archive


    【解决方案1】:

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

    我已经修改了你归档模块的语句,我得到了需要的结果。

      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
    

    【讨论】:

      猜你喜欢
      • 2017-02-07
      • 1970-01-01
      • 2012-12-14
      • 2013-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-26
      • 2015-01-21
      相关资源
      最近更新 更多