filter - Ansible - 否定过滤器

标签 filter ansible negate

我用 find ansible 模块找到了一些文件

- find:
    paths: "/"
    patterns: ["*.service"]
    file_type: file
    hidden: True
    recurse: yes
  register: find_results
  when: ansible_service_mgr == "systemd"

现在我想检查修改某些文件的权限:

- file:
    path: "{{ item.path }}"
    owner: root
    group: root
    mode: 0644
  with_items:
    - "{{ find_results.files }}"
  when:
    - item.path | match("/sys/devices/power/events/*")
    - ansible_service_mgr == "systemd"

问题是我不想匹配。我想要与该路径不匹配的所有内容?

如何否定匹配过滤器? (!,不是等)?

最佳答案

感谢您的帮助,您还可以执行以下操作:

not (item.path | match("/sys/devices/power/events/*"))

关于filter - Ansible - 否定过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44063385/

相关文章:

linux - 我如何知道 Linux 中的下一个设备映射器?

dictionary - ansible 的 key 方法

matrix - 如何将 not 运算符应用于 Julia 中的所有矩阵元素?

javascript - AngularJS ng-repeat 和切换过滤器开/关?

php - 价格低-高/高-低过滤 PHP/Mysql

javascript - SailsJS 使用自定义 EJS 过滤器

yaml - Ansible 递增 IP 地址

jquery - 如何否定上下文

mysql - SQL WHERE 条件不等于?

python - 用于 POST 请求的 Django 休息框架自定义过滤器