ansible esxi 批量运行命令


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
- name: wwn task
  hosts: all
  vars_files:
          - wwn.yml
  tasks:
          - name: shell get host ip in reslut and register
            shell:
                    cmd: esxcli network ip interface ipv4 get | awk  '{print $2}' |sed -n '3p'
            register: hostip
          - name: show esxi host ip
            debug:
                  var: hostip.stdout
          - name: wwn1 in shell command
            shell:
                  cmd: esxcli elxmgmt hba firmware download -w "{{ item.wwn1 }}" -f /vmfs/volumes/HDS-VSP5000-1-CORE-2Q-LUN01/ISO/lancerg6_A14.0.326.17.grp
            when:  hostip.stdout == "{{ item.host }}"
            loop: "{{ esxi }}"
          - name: wwn2 in shell command
            shell:
                  cmd: esxcli elxmgmt hba firmware download -w "{{ item.wwn2 }}" -f /vmfs/volumes/HDS-VSP5000-1-CORE-2Q-LUN01/ISO/lancerg6_A14.0.326.17.grp
            when:  hostip.stdout == "{{item.host}}"
            loop: "{{ esxi }}"<br /><br />匹配wwn.yml里面的主机!<br />
阅读剩余
THE END