ansible批量升级sudo版本

操作

[root@ansible-centos7-shanghai-area0 ~]# vim  /etc/ansible/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.6-2.el7.x86_64 || rpm -Uvh https://github.com/sudo-project/sudo/releases/download/SUDO_1_9_6p1/sudo-1.9.6-2.el7.x86_64.rpm 
          when: ansible_distribution_major_version == "6" 

[root@ansible-centos7-shanghai-area0 ~]# ansible-playbook -i /etc/ansible/hosts  -e hosts=192.168.122.102  /etc/ansible/update_sudo.yml
[WARNING]: Found variable using reserved name: hosts

PLAY [更新sudo版本] *****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
ok: [192.168.122.102]

TASK [CentOS 7 更新sudo版本] ********************************************************************************************************************************************************************************************************************
ok: [192.168.122.102]

TASK [CentOS 6 更新sudo版本] ********************************************************************************************************************************************************************************************************************
skipping: [192.168.122.102]

PLAY RECAP **********************************************************************************************************************************************************************************************************************************
192.168.122.102            : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
上一篇
下一篇