【问题标题】:Regex Negation for Inventory.py in ansibleansible中Inventory.py的正则表达式否定
【发布时间】:2019-10-14 11:15:17
【问题描述】:

我需要帮助来否定我的 ansible playbook 中的特定字符串。

我想排除将应用程序标记为 haproxy 的服务器。不知道如何用正则表达式来实现。 我尝试了以下方法,但不起作用

要求: 1. 获取所有环境为 qa 的服务器 2. 但是排除haproxy服务器。

1.tag_Environment_qa:!&tag_apps_*haproxy*"

2.tag_apps_(?<!*haproxy*):&tag_Environment_qa

【问题讨论】:

  • 您能否发布一个文本示例以及输出应该是什么?只是为了确保我们得到正确的想法

标签: python regex ansible ansible-inventory


【解决方案1】:

请检查下面,这是您需要的吗?

- name: get qa servers tag
  command: some command to get tag
  register: tag
- name: exclude the haproxy servers
  command: some command
  when: "'haproxy' not in tag.stdout" 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多