-
Notifications
You must be signed in to change notification settings - Fork 25
/
default.rb
105 lines (89 loc) · 2.56 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
100
101
102
103
104
105
apt_update if platform_family?('debian')
build_essential 'install compilation tools'
user node['vsts_agent_test']['username'].to_s do
manage_home true
comment 'Vagrant user'
home "/home/#{node['vsts_agent_test']['username']}"
shell '/bin/bash'
not_if "id -u #{node['vsts_agent_test']['username']}"
end
user 'builder' do
manage_home true
comment 'Builder user'
home '/home/builder'
shell '/bin/bash'
end
include_recipe 'vsts_agent::default'
agent1_name = "#{node['hostname']}_01"
agent2_name = "#{node['hostname']}_02"
agent3_name = "#{node['hostname']}_deployment_03"
agents_dir = '/opt/agents'
# 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
log 'Test notification' do
action :nothing
end
# # Agent1
vsts_agent agent1_name do
install_dir "#{agents_dir}/#{agent1_name}"
user node['vsts_agent_test']['username']
group 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']
action :install
notifies :write, 'log[Test notification]', :immediately
end
vsts_agent agent1_name do
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'
group 'builder'
path '/usr/local/bin/:/usr/bin:/opt/bin/:/tmp/'
env('M2_HOME' => '/opt/maven', 'JAVA_HOME' => '/opt/java')
vsts_url node['vsts_agent_test']['vsts_url']
vsts_pool node['vsts_agent_test']['vsts_pool']
vsts_token node['vsts_agent_test']['vsts_token']
work_folder '/tmp/work'
action :install
end
vsts_agent agent2_name do
action :restart
end
# Agent 3 deployment group
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}/#{agent3_name}"
user 'builder'
group 'builder'
path '/usr/local/bin/:/usr/bin:/opt/bin/:/tmp/'
env('M2_HOME' => '/opt/maven', 'JAVA_HOME' => '/opt/java')
vsts_url node['vsts_agent_test']['vsts_url']
vsts_token node['vsts_agent_test']['vsts_token']
work_folder '/tmp/work'
action :install
end
vsts_agent agent3_name do
action :restart
end