| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- $modules = @(
- "powershell-yaml"
- )
- $play_folders = @(
- "plays/common"
- )
- foreach ($mod in $modules){
- try {
- Import-Module $mod |Out-Null
- } catch {
- }
- if ((Get-Module $mod) -eq $null){
- "Need to install $mod module..."
- Install-Module -Scope CurrentUser -Force $mod
- Import-Module $mod
- }
- }
- $tplfile = "provision_tpl.yml"
- $provisionfile = "provision.yml"
- if (Test-Path $provisionfile -PathType leaf)
- {
- "Using $provisionfile"
- $currentplays = ConvertFrom-Yaml ([System.IO.File]::ReadAllText($provisionfile))
- } else {
- $currentplays = @()
- }
- $plays = @()
- foreach ($dir in $play_folders){
- $plays += (ls "$dir" |
- foreach-object {$_.name} | sort |
- ForEach-Object {
- "$dir/$_" |out-host
- $content = ConvertFrom-Yaml ([System.IO.File]::ReadAllText("$dir/$_"));
- $content.name = "$dir/$_"
- [PSCustomObject]@{
- enabled = [Boolean]($currentplays|foreach-object {$_.name}) -match "$dir/$_";
- name = "$_";
- dir = "$dir";
- content = $content;
- }
- }
- )
- }
- $enabledplays = $plays | Where-Object {$_.enabled}
- "Active Playbooks:"
- $enabledplays | Select-Object name,dir
- "Available Playbooks:"
- $plays | Select-Object name,dir
- # $label = (ConvertTo-Yaml ($commonplays|Select-Object nam))
- # $label
- $griddata = $plays
- "Griddata"
- $griddata|out-host
- . ./gui/gui.ps1
- $result = $griddata | Out-GridView -PassThru
- $ymltext = ConvertTo-Yaml($commonplays)
- ""
- # [System.IO.File]::WriteAllText($provisionfile, $ymltext)
|