套件管理 - yum 模組

  1. yum 模組可以做套件管理,完整文件可用 ansible-doc 查詢 yum 模組文件。
    [root@kvm19 ansible]# ansible-doc yum
    
  2. 確認 dev 群組裡所有主機,套件 vim 還沒安裝,回傳成功。
    [deyu1@kvm19 ansible]$ ansible dev -m yum -a "name=vim state=absent"
    kvm11 | SUCCESS => {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/libexec/platform-python"
        },
        "changed": false,
        "msg": "Nothing to do",
        "rc": 0,
        "results": []
    }
    
  3. 使用 yum 模組安裝 vim 至最新版本,回傳成功,含相依套件共安裝了 4 的套件。
    [deyu1@kvm19 ansible]$ ansible dev -m yum -a "name=vim state=latest"
    kvm11 | CHANGED => {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/libexec/platform-python"
        },
        "changed": true,
        "msg": "",
        "rc": 0,
        "results": [
            "Installed: gpm-libs-1.20.7-15.el8.x86_64",
            "Installed: vim-enhanced-2:8.0.1763-10.el8.x86_64",
            "Installed: vim-filesystem-2:8.0.1763-10.el8.noarch",
            "Installed: vim-common-2:8.0.1763-10.el8.x86_64"
        ]
    }