-
Notifications
You must be signed in to change notification settings - Fork 1
/
hyperv_guest.py
96 lines (88 loc) · 2.54 KB
/
hyperv_guest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2016, Mike Fennemore <[email protected]>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# this is a windows documentation stub. actual code lives in the .ps1
# file of the same name
DOCUMENTATION = '''
---
module: win_chocolatey
version_added: "1.9"
short_description: Adds,deletes and performs power functions on Hyper-V VM's.
description:
- Installs packages using Chocolatey (http://chocolatey.org/). If Chocolatey is missing from the system, the module will install it. List of packages can be found at http://chocolatey.org/packages
options:
name:
description:
- Name of VM
required: true
state:
description:
- State of VM
required: false
choices:
- present
- absent
- restart
- shutdown
- start
default: present
memory:
description:
- Sets the amount of memory for the VM.
required: false
default: 512MB
hostserver:
description:
- Server to host VM
required: false
default: null
generation:
description:
- Specifies the generation of the VM
required: false
default: 2
diskpath:
description:
- Specify path of VHD/VHDX file for VM
- If the file exists it will be attached, if not then a new one will be created
require: false
default: null
version_added: '2.1'
author: "Mike Fennemore (@mikef_sa)"
'''
# TODO:
# * Better parsing when a package has dependencies - currently fails
# * Time each item that is run
# * Support 'changed' with gems - would require shelling out to `gem list` first and parsing, kinda defeating the point of using chocolatey.
EXAMPLES = '''
# Create VM
hyperv_guest:
name: Test
# Delete a VM
hyperv_guest:
name: Test
state: absent
# Create VM with 512MB memory
hyperv_guest:
name: Test
memory: 512MB
# Install git from specified repository
win_chocolatey:
name: git
source: https://someserver/api/v2/
'''