大家好〜我有个问题。
首先..我的英语说得不好。
实际上我有一些问题...我想通过powercli将新的NIC添加到GuestVM。然后我要在GuestVM上获取新NIC的MacAddress,然后尝试保存我的注册变量。
================================================ ===
<我的Ansible代码>
---
- name:
hosts: localhost
gather_facts: no
tasks:
- name: Get new NIC MacAddress
shell: |
Connect-VIServer -Server '$my_vCenter' -User $my_ID -Password '$my_PWD' | Out-null
$vm = get-vm | where { $_.ExtensionData.config.uuid -eq $my_UUID }
$nic = New-NetworkAdapter -VM $vm -NetworkName "vmnet_10.40.95.x" -WakeOnLan -StartConnected
$nic.MacAddress
args:
executable: /usr/bin/pwsh
register: new_macaddress
delegate_to: localhost
- debug:
var: new_macaddress.stdout_lines
================================================ =====================
但是,我的注册变量的结果不好。
================================================ =====================
<寄存器变量结果>
{
"changed": false,
"_ansible_verbose_always": true,
"new_macaddress.stdout_lines": [
"",
"",
"",
"",
"",
" 00:50:56:8a:69:11"
],
"_ansible_no_log": false
}
================================================ =====================
我只需要MacAddress(00:50:56:8a:69:11),但是有许多不必要的事情。 (例如:“”,“”,“”,......)
所以,我想知道如何只获得macaddress。
请帮我T_T