-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAnsible_Playbook_Run.ps1
More file actions
36 lines (28 loc) · 1.33 KB
/
Ansible_Playbook_Run.ps1
File metadata and controls
36 lines (28 loc) · 1.33 KB
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
param (
[string]$VarsFilePath
)
$testVarsFilePath = {
param ($pathToTest)
if ([string]::IsNullOrWhiteSpace($pathToTest)) {
Write-Host -ForegroundColor Red 'Please specify a valid .yml file generated by Config Builder.'
return $false
}
if (-not (Test-Path -Path $pathToTest)) {
Write-Host -ForegroundColor Red 'Input variables file specified does not exist. Please specify a valid .yml file generated by Config Builder.'
return $false
}
if ($pathToTest -notmatch '.*Yml_SO\d+_.*[.]yml') {
Write-Host -ForegroundColor Red 'Invalid file specified. Please specify a valid .yml file generated by Config Builder.'
return $false
}
Write-Host -ForegroundColor Yellow 'Valid .yml file specified.'
return $true
}
while (! $testVarsFilePath.InvokeReturnAsIs($VarsFilePath)) {
$VarsFilePath = (Read-Host -Prompt 'Specify the path to the variables file generated by Config Builder ').TrimStart('"', "'").TrimEnd('"', "'")
}
$containerId = & docker run -d --rm -it deploy
& docker cp "$( (Resolve-Path -Path $VarsFilePath).Path )" "$( $containerId ):/deploy/vars/globals.yml"
& docker exec -it $containerId ansible-playbook /deploy/cluster_setup.yml
$null = & docker container stop $containerId
Read-Host -Prompt "Press Enter to exit"