自动化运维工具Ansible实战(五)playbook使用
# vim update_bash.yml- hosts: all
remote_user: root
gather_facts: True
tasks:
- name: update bash in redhat 6 version
yum: name=http://mirrors.aliyun.com/centos/6.6/os/x86_64/Packages/bash-4.1.2
-29.el6.x86_64.rpm.rpm state=present
when: ansible_os_family == "RedHat" and ansible_distribution_version|int >=6
- name: update bash in redhat 5 version
yum: name=http://mirrors.hustunique.com/centos/5/updates/x86_64/RPMS/bash-3.
2-33.el5.1.x86_64.rpm state=present
when: ansible_os_family == "RedHat" and ansible_distribution_version|int <=5
# ansible
ansible ansible-doc ansible-playbookansible-vault
ansible-console ansible-galaxy ansible-pull
# ansible-playbook update_bash.yml
PLAY *********************************************************************
TASK *******************************************************************
ok:
ok:
ok:
ok:
ok:
ok:
ok:
ok:
TASK *****************************************
fatal: : FAILED! => {"changed": false, "failed": true, "msg": "Failure downloading http://mirrors.aliyun.com/centos/6.6/os/x86_64/Packages/bash-4.1.2-29.el6.x86_64.rpm.rpm, 'NoneType' object has no attribute 'read'"}
skipping:
TASK *****************************************
fatal: : FAILED! => {"changed": false, "failed": true, "msg": "Failure downloading http://mirrors.hustunique.com/centos/5/updates/x86_64/RPMS/bash-3.2-33.el5.1.x86_64.rpm, 'NoneType' object has no attribute 'read'"}
to retry, use: --limit @/etc/ansible/update_bash.retry
PLAY RECAP *********************************************************************
192.168.180.10 : ok=1 changed=0 unreachable=0 failed=1
192.168.180.2 : ok=1 changed=0 unreachable=0 failed=1
192.168.180.23 : ok=1 changed=0 unreachable=0 failed=1
192.168.180.4 : ok=1 changed=0 unreachable=0 failed=1
192.168.180.5 : ok=1 changed=0 unreachable=0 failed=1
192.168.180.6 : ok=1 changed=0 unreachable=0 failed=1
Server5 : ok=1 changed=0 unreachable=0 failed=1
Server6 : ok=1 changed=0 unreachable=0 failed=1
页:
[1]