gregsowell / ansible-windows Goto Github PK
View Code? Open in Web Editor NEWWindows related automations
Windows related automations
Good stuff,
I built on it a little, my issue is that this part fails everytime:
Everything else works but this part, which of course I need.
I get the following error:
{
"module_stdout": "",
"module_stderr": "/bin/sh: line 1: powershell: command not found\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 127,
"_ansible_no_log": null,
"changed": false
}
- name: Connect to windows host and expand the drive
ansible.windows.win_powershell:
script: |
# Variable specifying the drive you want to extend
$drive_letter = "C"
# Script to get the partition sizes and then resize the volume
$size = (Get-PartitionSupportedSize -DriveLetter $drive_letter)
Resize-Partition -DriveLetter $drive_letter -Size $size.SizeMax
---
- name: vm disk expansion
hosts: localhost
become: false
gather_facts: false
tasks:
- name: Get all disks from existing VM
vmware_guest_disk_info:
validate_certs: False
datacenter: '{{ data_center }}'
name: '{{ vm_name }}'
register: existing_disk
- name: Get Backing datastore for desired disk id
set_fact:
disk_zero_datastore: "{{ item.value.backing_datastore }}"
with_dict: "{{ existing_disk.guest_disk_info }}"
when: item.key == '0'
- debug:
msg: "{{ disk_zero_datastore }}"
when: disk_zero_datastore is defined
- name: Get scsi controller type
set_fact:
scsi_type: "{{ item.value.controller_type }}"
with_dict: "{{ existing_disk.guest_disk_info }}"
when: item.key == '0'
- debug:
msg: '{{ scsi_type }}'
when: scsi_type is defined
- name: Get Unit Number
set_fact:
unit_number: "{{ item.value.unit_number }}"
with_dict: "{{ existing_disk.guest_disk_info }}"
when: item.key == '0'
- debug:
msg: '{{ unit_number }}'
when: unit_number is defined
- name: Get Disk + 30%
set_fact:
disc_size: "{{ item.value.capacity_in_kb|int *13/10| round(2, 'floor')|int }}"
with_dict: "{{ existing_disk.guest_disk_info }}"
when: item.key == '0'
- debug:
msg: '{{ disc_size }}'
when: disc_size is defined
- name: Connect to VMWare and shutdown guest
community.vmware.vmware_guest:
validate_certs: no
datacenter: "{{ data_center }}"
name: "{{ vm_name }}"
state: shutdownguest
delegate_to: localhost
failed_when: vm_shutdown.instance.hw_power_status != 'poweredOff' and vm_shutdown.changed == false
register: vm_shutdown
- name: Wait 15 seconds
ansible.builtin.pause:
seconds: 15
- name: Connect to VMWare and resize disk on VM
community.vmware.vmware_guest_disk:
validate_certs: no
datacenter: "{{ data_center }}"
name: "{{ vm_name }}"
disk:
- size_kb: "{{ disc_size|int }}"
state: present
unit_number: "{{ unit_number }}"
scsi_controller: 0
scsi_type: "{{ scsi_type }}"
delegate_to: localhost
register: disk_facts
- name: Connect to VMWare and boot up guest
community.vmware.vmware_guest:
validate_certs: no
name: "{{ vm_name }}"
state: poweredon
delegate_to: localhost
# register: disk_facts
- name: Wait 300 seconds, but only start checking after 15 seconds
wait_for_connection:
delay: 15
timeout: 300
- name: Extend disk to 100%
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.