-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsc_configuration.ps1
77 lines (67 loc) · 2.48 KB
/
dsc_configuration.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
66
67
68
69
70
71
72
73
74
75
76
77
Configuration Hubot {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -Name MSFT_xRemoteFile -ModuleName xPSDesiredStateConfiguration
Import-DscResource -ModuleName @{ModuleName="InstallHubot"; RequiredVersion="2.0.59"}
node $AllNodes.Where{$_.Role -eq "Hubot"}.NodeName {
# Set an adapter for hubot to use
Environment hubotadapter {
Name = 'HUBOT_ADAPTER'
Value = $Node.HubotAdapter
Ensure = 'Present'
}
# Set the hubot debug level - either debug or info
Environment hubotdebug {
Name = 'HUBOT_LOG_LEVEL'
Value = 'debug'
Ensure = 'Present'
}
# Set any other environment variables that may be required for the hubot scripts
Environment hubotslacktoken {
Name = 'HUBOT_SLACK_TOKEN'
Value = $Node.SlackAPIKey
Ensure = 'Present'
}
# Install the Prereqs using the same Hubot user
HubotPrerequisites installPreqs {
Ensure = 'Present'
}
# Download the HubotWindows Repo
xRemoteFile hubotRepo {
DestinationPath = "$($env:Temp)\HubotWindows.zip"
Uri = "https://github.com/MattHodge/HubotWindows/releases/download/0.0.2/HubotWindows-0.0.2.zip"
}
# Extract the Hubot Repo
Archive extractHubotRepo {
Path = "$($env:Temp)\HubotWindows.zip"
Destination = $Node.HubotBotPath
Ensure = 'Present'
DependsOn = '[xRemoteFile]hubotRepo'
}
# Install Hubot
HubotInstall installHubot {
BotPath = $Node.HubotBotPath
Ensure = 'Present'
DependsOn = '[Archive]extractHubotRepo','[HubotPrerequisites]installPreqs'
}
# Install Hubot as a service using NSSM
HubotInstallService myhubotservice {
BotPath = $Node.HubotBotPath
ServiceName = "Hubot_$($Node.HubotBotName)"
BotAdapter = $Node.HubotAdapter
Ensure = 'Present'
DependsOn = '[HubotInstall]installHubot','[HubotPrerequisites]installPreqs'
}
}
}
$configData = @{
AllNodes = @(
@{
NodeName = 'localhost';
Role = 'Hubot'
SlackAPIKey = 'xoxb-XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXX'
HubotAdapter = 'slack'
HubotBotName = 'bot'
HubotBotPath = 'C:\SCRIPTS\myhubot'
}
)
}