简介
sudo最近出了漏洞,需要升级版本,服务器比较多,需要使用ansible进行批量更新。
![](https://s5.51cto.com/oss/202102/03/8c3a251e303c990c7e7af0bb815e13d1.png)
ansible playbook
- vim update_sudo.yml
- - name: 更新sudo
- hosts: "{{ hosts }}"
- remote_user: root
- tasks:
- - name: CentOS 7 更新sudo
- yum:
- name: sudo
- state: latest
- when: ansible_distribution_major_version == "7"
- - name: CentOS 6 更新sudo
- shell: rpm -q sudo-1.9.5-3.el6.x86_64 || rpm -Uvh https://github.com/sudo-project/sudo/releases/download/SUDO_1_9_5p2/sudo-1.9.5-3.el6.x86_64.rpm
- when: ansible_distribution_major_version == "6"
CentOS6已经停止更新了,可以从github上直接下载新的版本,如果下载速度慢,可以先下载下来,放到本地共享的web目录i进行下载比较快。
![](https://s6.51cto.com/oss/202102/03/e6017604ef0e7b143a1c2ab69a229de1.png)
使用
- ansible-playbook -i /etc/ansible/hosts -e hosts=192.168.100.3,192.168.100.34 update_sudo.yml