簡體   English   中英

Ansible:將命令標准輸出與不同位置的現有文件夾進行比較

[英]Ansible : compare commands stdout with an existing folder at different location

我正在搜索 VM1 中可用的現有軟件版本,並嘗試使用 ansible 手冊將其版本與 vm2 中可用的最新版本(最新版本存儲在 vm2 中的特定文件夾中)進行比較

我正在嘗試在 Linux 服務器中運行 playbook 並搜索當前安裝的最新版本(存儲在特定文件夾中)

ok: [gxd5488] => {
    "msg": {
        "changed": true,
        "cmd": "rpm -qa | grep Tanium*",
        "delta": "0:00:01.274237",
        "end": "2019-10-25 13:09:37.579902",
        "failed": false,
        "rc": 0,
        "start": "2019-10-25 13:09:36.305665",
        "stderr": "",
        "stderr_lines": [],
        "stdout": "TaniumClient-7.2.314.3476-1.rhe7.x86_64",
        "stdout_lines": [
            "TaniumClient-7.2.314.3476-1.rhe7.x86_64" ------ (wanted to take this out put  and compare )
        ],
        "warnings": [
            "Consider using yum, dnf or zypper module rather than running rpm"
        ]
    }
}

如果您使用“注冊”將上述示例存儲在變量名稱“版本”下,則在 VM1 中更新版本時使用以下條件。 (考慮VM2版本為8.0.0)

when: "version.stdout.split('.')[0] >= '8.0.0'"

或者如果您存儲了 VM2 最新版本的變量,請使用它進行比較。

when: "version.stdout.split('.')[0] >= {{ VM2 version }}"

暫無
暫無

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

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