簡體   English   中英

ansible 中 Inventory.py 的正則表達式否定

[英]Regex Negation for Inventory.py in ansible

我需要幫助來否定我的 ansible 劇本中的特定字符串。

我想排除將應用程序標記為 haproxy 的服務器。 不知道如何用正則表達式來實現。 我嘗試了以下方法,但不起作用

要求: 1. 獲取所有環境為 qa 的服務器 2. 但不包括 haproxy 服務器。

1.tag_Environment_qa:!&tag_apps_*haproxy*"

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

請在下面查看,這是您需要的嗎?

- 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" 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM