-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
ansible-cygwin-installer.ps1
65 lines (53 loc) · 2.33 KB
/
ansible-cygwin-installer.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
61
62
63
64
65
#
# This Powershell script will download and install Cygwin and Ansible.
#
# Run from Powershell
# Set-ExecutionPolicy bypass
# & ansible-cygwin-installer.ps1
#
# Run from cmd with
# powershell -ExecutionPolicy bypass ".\ansible-cygwin-installer.ps1"
#
#
# User variables. These may be changed to suit your environment.
#
$storageDir = $pwd
$cygwinHome = "c:\tools\cygwin"
$cygwinUrlRoot = "http://cygwin.com"
$getPipUrlRoot = "https://bootstrap.pypa.io"
$cygwinMirror = "http://cygwin.mirrors.pair.com"
#
# You shouldn't normally need to change anything below here
#
if ($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64') {
$cygwinSetupExe = "setup-x86_64.exe"
$url = "$cygwinUrlRoot/$cygwinSetupExe"
$file = "$storageDir\$cygwinSetupExe"
} elseif ($ENV:PROCESSOR_ARCHITECTURE -eq 'x86') {
$cygwinSetupExe = "setup-x86.exe"
$url = "$cygwinUrlRoot/$cygwinSetupExe"
$file = "$storageDir\$cygwinSetupExe"
} else {
echo 'Unknown processor architecture'
exit
}
# Fully qualified path to Cygwin setup.exe
$cygwinSetupPath = "$storageDir\$cygwinSetupExe"
# Download Cygwin setup.exe, if it doesn't already exist
if ( ! ( Test-Path -Path $cygwinSetupPath -PathType Leaf ) ) {
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($url,$file)
}
$cygwinSetupArgs = '--no-admin', '-q', '-R', "$cygwinHome", '-s', "$cygwinMirror", '--packages="wget,python,git,vim,make,openssh,openssl,openssh-devel,libsasl2,ca-certificates,python-crypto,python-openssl,python-setuptools,dash,rebase"'
Start-Process -FilePath $cygwinSetupPath -ArgumentList $cygwinSetupArgs -Wait
# Add cygwin bin dir to path
$ENV:PATH="$cygwinHome\bin;$ENV:PATH"
# Install pip
Start-Process -FilePath $cygwinHome\bin\bash.exe -ArgumentList '-c', """wget.exe $getPipUrlRoot/get-pip.py""" -Wait -NoNewWindow
Start-Process -FilePath $cygwinHome\bin\bash.exe -ArgumentList '-c', '"python2.7.exe get-pip.py"' -Wait -NoNewWindow
# Fix fork() errors on some systems
Start-Process -FilePath $cygwinHome\bin\dash.exe -ArgumentList '-c', '"/usr/bin/rebaseall -v"' -Wait -NoNewWindow
# Install Ansible via pip
Start-Process -FilePath $cygwinHome\bin\bash.exe -ArgumentList '-c', '"pip2.7 install ansible"' -Wait -NoNewWindow
# Run Ansible from outside of Cygwin shell
Start-Process -FilePath $cygwinHome\bin\bash.exe -ArgumentList '-c', '"ansible --version"' -Wait -NoNewWindow