Skip to content

Instantly share code, notes, and snippets.

@stephaneerard
Created April 19, 2021 17:28
Show Gist options
  • Select an option

  • Save stephaneerard/03ef18ee31774e54d730d715414d2462 to your computer and use it in GitHub Desktop.

Select an option

Save stephaneerard/03ef18ee31774e54d730d715414d2462 to your computer and use it in GitHub Desktop.
$json = get-content "$PSScriptRoot/../init.json" -raw -Encoding ascii | convertfrom-json
$machinesTypes = $json.vagrant.'machines-types';
foreach($machineType in $machinesTypes) {
frenchex2 vagrant:machine-type:add `
--name "${machineType.Name}" `
--vcpus "${machineType.Vcpus}" `
--cpucap "${machineType.CpuCap}" `
--os-type "${machineType.'os-type'}" `
--os-version "${machineType.'os-version'}" `
--ram-mb "${machineType."ram-mb"}" `
--vram-mb "${machineType."vram-mb"}" `
--no-3d `
--no-gui `
--provider "${machineType.Provider}" `
--enabled `
--box "${machineType.box}"
}
{
"vagrant": {
"machines-types": {
"dev": {
"vcpus": 4,
"cpucap": 100,
"os-type": "Debian_64",
"os-version": "10.9.0",
"ram-mb": 2048,
"vram-mb": 8,
"3d": false,
"gui": false,
"provider": "virtualbox",
"enabled": true,
"box": "debian/contrib-buster64"
}
},
"provisioners": [
]
}
}
@stephaneerard

Copy link
Copy Markdown
Author
param(
    [string] $Path
)

import-module "$PSScriptRoot/../posh_modules/Utils.psm1" -Force

if ([string]::IsNullOrEmpty($Path)) {
    $path = get-location
}

frenchex2 vagrant:init --instance "$Instance" --group "$group"

$json = get-content "$PSScriptRoot/../init.json" -raw -Encoding ascii | convertfrom-json

$machinesTypes = $json.vagrant.'machines-types'.psobject.Properties

foreach($machineType in $machinesTypes) {
    
        frenchex2 vagrant:machine-type:add               `
        --name $machineType.Name                    `
        --vcpus $machineType.Value.Vcpus                 `
        --cpucap $machineType.Value.cpucap               `
        --os-type $machineType.Value.'os-type'          `
        --os-version $machineType.Value.'os-version'        `
        --ram-mb $machineType.Value.'ram-mb'           `
        --vram-mb $machineType.Value.'vram-mb'          `
        --no-3d                                          `
        --no-gui                                         `
        --provider $machineType.Value.provider       `
        --enabled                                        `
        --box $machineType.Value.box
}

this is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment