-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
62 lines (41 loc) · 1.89 KB
/
install.ps1
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
Set-ExecutionPolicy Bypass -Scope Process -Force
$baseUrl = "https://raw.githubusercontent.com/shakahl/ansible-runner-docker/master"
$installDir = "$($env:appdata)\ansible-runner"
$scriptFile = "$installDir\ansible-runner.cmd"
$configDir = "$($env:userprofile)\.ansible"
Write-Output "Config dir: $configDir"
Write-Output "Install dir: $installDir"
Write-Output "Install file: $scriptFile"
Write-Output "Ensuring install directory exists: $installDir"
If(!(test-path $installDir))
{
New-Item -ItemType Directory -Force -Path $installDir
}
Write-Output "Ensuring configuration directory exists: $configDir"
If(!(test-path $configDir))
{
New-Item -ItemType Directory -Force -Path $configDir
}
If(!(test-path "$configDir\ansible.cfg"))
{
Write-Output "Creating: $configDir\ansible.cfg"
Invoke-Expression -Command "(New-Object System.Net.WebClient).DownloadFile('$baseUrl/docker/etc/ansible/ansible.cfg', '$configDir\ansible.cfg')"
}
If(!(test-path "$configDir\hosts"))
{
Write-Output "Creating: $configDir\hosts"
Invoke-Expression -Command "(New-Object System.Net.WebClient).DownloadFile('$baseUrl/docker/etc/ansible/hosts', '$configDir\hosts')"
}
# Download the script
Invoke-Expression -Command "(New-Object System.Net.WebClient).DownloadFile('$baseUrl/ansible-runner.cmd', '$scriptFile')"
# PowerShell 3+?
#iwr https://raw.githubusercontent.com/shakahl/ansible-runner-docker/master/install.ps1 -UseBasicParsing | iex
Write-Output 'Ensuring commands are on the path'
if ($($env:Path).ToLower().Contains($($installDir).ToLower()) -eq $false) {
[Environment]::SetEnvironmentVariable
( "Path", $env:Path + ";$installDir", [System.EnvironmentVariableTarget]::User )
}
(Get-Command 'docker' | Select-Object -ExpandProperty Definition | Tee-Object -Variable dockerCmd)
$dockerCmd -replace ' ', '` '
# Pulling docker image
Invoke-Expression -Command "'$dockerCmd pull shakahl/ansible-runner-docker'"