【发布时间】:2019-08-27 09:21:27
【问题描述】:
我在运行 playbook 时遇到语法错误。
错误!加载 YAML 时出现语法错误。没有找到预期的'-' 指示器 错误似乎在 '/var/lib/awx/projects/_39__common/Hyper-V_Shutdown_VM.yml':第 8 行, 第 5 列,但可能在文件中的其他位置,具体取决于确切的 语法问题。
违规行似乎是:
- win_shell: |
$a = Get-ClusterGroup | Where-Object {$_.Name -like "{{ vm }}" -and $_.State -eq 'Online'}
^ here
我们可能是错的,但这个看起来可能是一个问题
缺少引号。总是引用模板表达式括号
开始一个值。例如:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
我的编码........
---
- name: Hyper-V shutdown VM
hosts: all
gather_facts: no
tasks:
win_shell: |
$a = Get-ClusterGroup | Where-Object {$_.Name -like "{{ vm }}" -and $_.State -eq 'Online'}
$b = $a.OwnerNode
Stop-VM -Name "{{ vm }}" -ComputerName $b
【问题讨论】:
标签: ansible