-
Notifications
You must be signed in to change notification settings - Fork 25
/
default.rb
99 lines (82 loc) · 2.41 KB
/
default.rb
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#### Begin prepare system ####
user 'builder' do
comment 'Builder user'
home '/home/builder'
shell '/bin/bash'
password 'Pas$w0r_d'
end
grant_logon_as_service node['vsts_agent_test']['username']
grant_logon_as_service 'builder'
include_recipe 'seven_zip::default'
#### End prepare system ####
include_recipe 'vsts_agent::default'
agent1_name = "win_#{node['hostname']}_01"
agent2_name = "win_#{node['hostname']}_02"
agent3_name = "win_#{node['hostname']}_deployment_03"
agents_dir = 'C:\\agents'
log 'Test notification' do
action :nothing
end
# cleanup
vsts_agent agent1_name do
vsts_token node['vsts_agent_test']['vsts_token']
action :remove
end
vsts_agent agent2_name do
vsts_token node['vsts_agent_test']['vsts_token']
action :remove
end
vsts_agent agent3_name do
vsts_token node['vsts_agent_test']['vsts_token']
action :remove
end
# Agent1
vsts_agent agent1_name do
install_dir "#{agents_dir}\\#{agent1_name}"
user node['vsts_agent_test']['username']
vsts_url node['vsts_agent_test']['vsts_url']
vsts_pool node['vsts_agent_test']['vsts_pool']
vsts_token node['vsts_agent_test']['vsts_token']
windowslogonaccount node['vsts_agent_test']['username']
windowslogonpassword node['vsts_agent_test']['username']
notifies :write, 'log[Test notification]', :immediately
action :install
end
vsts_agent agent1_name do
vsts_token node['vsts_agent_test']['vsts_token']
action :restart
end
vsts_agent agent1_name do
vsts_token node['vsts_agent_test']['vsts_token']
action :remove
end
# Agent2
vsts_agent agent2_name do
install_dir "#{agents_dir}\\#{agent2_name}"
user 'builder'
vsts_url node['vsts_agent_test']['vsts_url']
vsts_pool node['vsts_agent_test']['vsts_pool']
vsts_token node['vsts_agent_test']['vsts_token']
windowslogonaccount 'NT AUTHORITY\\NetworkService'
action :install
end
vsts_agent agent2_name do
action :restart
end
# Agent3
vsts_agent agent3_name do
deploymentGroup true
deploymentGroupName node['vsts_agent_test']['deployment_group_name']
projectName node['vsts_agent_test']['deployment_group_project']
deploymentGroupTags 'web, db'
install_dir "#{agents_dir}\\#{agent2_name}"
user 'builder'
vsts_url node['vsts_agent_test']['vsts_url']
vsts_pool node['vsts_agent_test']['vsts_pool']
vsts_token node['vsts_agent_test']['vsts_token']
windowslogonaccount 'NT AUTHORITY\\NetworkService'
action :install
end
vsts_agent agent3_name do
action :restart
end