回答:存档模块未考虑exclude_path参数

时间:2018-11-12 11:19:39

标签: ansible

我要存档以下目录:

function sym(...args) {
  const counts = args.reduce((a, arr) => {
    arr.forEach((num) => {
      a[num] = (a[num] || 0) + 1;
    });
    return a;
  }, {});
  return Object.entries(counts)
    .filter(([, count]) => count === 1)
    .map(([key]) => key);
}
console.log(sym([1, 2, 3], [2, 3, 4])) // [1, 4]
console.log(sym([1, 2, 3], [2, 3, 4], [0, 1])) // [0, 4], since 1 was duplicated

哪里

temp_build_directory: /tmp/mdr-upgrade

任务是:

$ ls -1 /tmp/mdr-upgrade
ansible
atr
composefiles
data
images
packs
wheelhouse

还有- name: archive_artifacts.yml --> Archive artifacts archive: path: "{{ temp_build_directory }}/*" dest: "{{ target_tmp_dir }}/{{ artifacts_file_name }}" exclude_path: "{{ target_tmp_dir }}/{{ ansible_dir }}"

Tarball最终始终包含ansible_dir: ansible文件夹。

那是为什么?

修改:我正在使用ansible

1 个答案:

答案 0 :(得分:1)

exclude_path需要绝对路径(请参见docs)。 再试一次:

- name: archive_artifacts.yml --> Archive artifacts
    archive:
      path: "{{ temp_build_directory }}/*"
      dest: "{{ target_tmp_dir }}/{{ artifacts_file_name }}"
      exclude_path: "{{ temp_build_directory }}/{{ ansible_dir }}"