小任务:
- name: Configure hosts
template: src=host.cfg.j2 dest=/etc/shinken/hosts/{{item.host_name}}.cfg
with_items: shinken_hosts
when: shinken_hosts is defined
notify: reload config我希望删除由此任务配置的/etc/shinken/host/中的所有其他信任(文件)。
我该怎么做?
(如果我修复‘shinken_host’中的错误并想要自动删除名称错误的旧配置,这是非常重要的。)
发布于 2015-10-08 21:43:38
您可能需要检查这,幻灯片19,这假定您知道特定dir中需要存在哪些文件,然后删除所有其他文件。
# tidy_expected: [‘conf1.cfg’, conf2.cfg’]
- find: paths={{tidy_path}} #/etc/myapp
register: existing
- file: path={{item.path}} state=absent
when: item.path|basename not in tidy_expected
with_items: “{{existing.files|default([ ])}}”
register: removed
- mail: body=“{{removed}}”https://stackoverflow.com/questions/32908310
复制相似问题