Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I use ansible to shutdown hyper-v cluster guest #1

Open
mattluk168 opened this issue Sep 5, 2019 · 0 comments
Open

how can I use ansible to shutdown hyper-v cluster guest #1

mattluk168 opened this issue Sep 5, 2019 · 0 comments

Comments

@mattluk168
Copy link

Dear Glenn,
May I know how to write a playbook to shutdown hyper-v cluster guest?
powershell script:

$a = Get-ClusterGroup | Where-Object {$.Name -like "server1" -and $.State -eq 'Online'}
$b = $a.OwnerNode
Stop-VM -Name "vm1" -ComputerName $b

I try to write the playbook but get error.

  • 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

In job template extra variable:
vm: vmgest1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant