更新套件

  1. 修改腳本 deploy3.yml 為 deploy4.yml,增加任務在 test 更新open開頭的套件。
    [deyu1@kvm19 ansible]$ cat deploy4.yml
    ---
    - hosts: dev test
      tasks:
      - name: install package
        yum: 
          name:
          - php
          - mariadb
          state: latest
      - block:
        - name: install the '@RPM Development Tools' package group
          yum:
            name: "@RPM Development Tools"
            state: present
        - name: upgrade all packages
          yum:
            name: 'open*' 
            state: latest    
        when: "'test' in group_names"
    
  2. 命令列使用 ansible-playbook 執行 deploy4.xml 腳本。
    [deyu1@kvm19 ansible]$ ansible-playbook deploy4.yml 
    
    PLAY [dev test] ****************************************************************
    
    TASK [Gathering Facts] *********************************************************
    ok: [kvm12]
    ok: [kvm11]
    
    TASK [install package] *********************************************************
    ok: [kvm11]
    ok: [kvm12]
    
    TASK [install the '@RPM Development Tools' package group] **********************
    skipping: [kvm11]
    ok: [kvm12]
    
    TASK [upgrade all packages] ****************************************************
    skipping: [kvm11]
    ok: [kvm12]
    
    PLAY RECAP *********************************************************************
    kvm11 : ok=2 changed=0 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
    kvm12 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0