playbook 编写
[zhupengfei@devops-centos7-shanghai-area1 ansible]$ sudo vim yum_update.yml
---
- hosts: all
gather_facts: no
tasks:
- name: update cache # 更新yum源缓存
yum:
update_cache: yes
- name: upgrade all packages # yum update升级步骤(耗时较长)
yum:
name: '*'
state: latest
[zhupengfei@devops-centos7-shanghai-area1 ansible]$ sudo ansible-playbook yum_update.yml
PLAY [all] ****************************************************************************************************************************************************************************************************************************************************************
TASK [update cache] *******************************************************************************************************************************************************************************************************************************************************
ok: [172.17.1.10]
TASK [upgrade all packages] ***********************************************************************************************************************************************************************************************************************************************
changed: [172.17.1.10]
PLAY RECAP ****************************************************************************************************************************************************************************************************************************************************************
172.17.1.10 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0