1.0.0 π
This commit is contained in:
Π ΠΎΠ΄ΠΈΡΠ΅Π»Ρ
1ca1a40363
ΠΠΎΠΌΠΌΠΈΡ
26d27f9df0
|
@ -6,7 +6,7 @@ driver:
|
|||
provisioner:
|
||||
name: chef_zero
|
||||
always_update_cookbooks: true
|
||||
multiple_converge: 3
|
||||
multiple_converge: 2
|
||||
enforce_idempotency: true
|
||||
require_chef_omnibus: true
|
||||
|
||||
|
@ -28,7 +28,10 @@ suites:
|
|||
- test/smoke/default
|
||||
attributes:
|
||||
vsts_agent:
|
||||
agent_pool: "OXO Hub Eng Mac Pool"
|
||||
agent_pool: OXO Hub Eng Mac Pool
|
||||
account: office
|
||||
data_bag: vsts
|
||||
data_bag_item: office_build_agent
|
||||
homebrew:
|
||||
auto-update: false
|
||||
owner: vagrant
|
||||
|
|
32
README.md
32
README.md
|
@ -28,7 +28,7 @@ default['vsts_agent']['version']
|
|||
|
||||
The name of the agent pool you wish to add the agent to.
|
||||
|
||||
**Default value:** `'ApexInfra macOS'`
|
||||
**Default value:** `American Hanko's Agents`
|
||||
|
||||
```ruby
|
||||
default['vsts_agent']['agent_pool']
|
||||
|
@ -36,10 +36,9 @@ default['vsts_agent']['agent_pool']
|
|||
|
||||
### VSTS Account Name
|
||||
|
||||
The name of your VSTS account. You **must** set this attribute if you are not a
|
||||
member of the "Office" account.
|
||||
The name of your VSTS account.
|
||||
|
||||
**Default value:** `'office'`
|
||||
**Default value:** `americanhanko`
|
||||
|
||||
```ruby
|
||||
default['vsts_agent']['account']
|
||||
|
@ -59,7 +58,7 @@ default['vsts_agent']['admin_user']
|
|||
|
||||
The location where containing all of the VSTS builds, sources, etc.
|
||||
|
||||
**Default value:** `'/Users/node['vsts_agent']['admin_user']/vsts-agent'`
|
||||
**Default value:** `'/Users/#{node['vsts_agent']['admin_user']}/vsts-agent'`
|
||||
|
||||
```ruby
|
||||
default['vsts_agent']['agent_home']
|
||||
|
@ -80,8 +79,23 @@ default['vsts_agent']['additional_environment']
|
|||
Required Data Bag Item
|
||||
----------------------
|
||||
|
||||
For now, you'll need to create a data bag called 'vsts' with a bag item called
|
||||
'build_agent' that contains two keys used to configure the agent:
|
||||
For now, you'll need to create a data bag. Name your bag and corresponding item
|
||||
whatever you like and make sure to set the corresponding attributes:
|
||||
|
||||
- `personal_access_token`
|
||||
- `account_url`
|
||||
```ruby
|
||||
default['vsts_agent']['data_bag']
|
||||
default['vsts_agent']['data_bag_item']
|
||||
```
|
||||
|
||||
Additionally, it must contain a `personal_access_token` key with
|
||||
the token itself as the value. The token must have rights to read and modify
|
||||
VSTS build agents. The permissions are selected at the time of the PAT creation.
|
||||
|
||||
Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": "vsts_build_agent",
|
||||
"personal_access_token": "iu8tfaxxrhce7yeu434yo9zfjtxif3jygzk24wegi855er2moobs",
|
||||
}
|
||||
```
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
default['vsts_agent']['version'] = '2.129.0'
|
||||
default['vsts_agent']['agent_name'] = node['hostname']
|
||||
default['vsts_agent']['account'] = 'office'
|
||||
default['vsts_agent']['agent_pool'] = 'OXO Hub Eng Mac Pool'
|
||||
default['vsts_agent']['additional_environment'] = {}
|
||||
|
||||
default['vsts_agent']['admin_user'] = 'vagrant'
|
||||
default['vsts_agent']['data_bag'] = 'vsts'
|
||||
default['vsts_agent']['data_bag_item'] = 'build_agent'
|
||||
|
||||
default['vsts_agent']['agent_name'] = node['hostname']
|
||||
default['vsts_agent']['account'] = 'americanhanko'
|
||||
default['vsts_agent']['agent_pool'] = "American Hanko's Agents"
|
||||
default['vsts_agent']['version'] = '2.129.0'
|
||||
default['vsts_agent']['additional_environment'] = {}
|
||||
|
|
|
@ -4,7 +4,7 @@ maintainer_email 'eric.hanko1@gmail.com'
|
|||
license 'MIT'
|
||||
description 'A dedicated cookbook for configuring a VSTS build/release agent on macOS.'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version '0.2.0'
|
||||
version '1.0.0'
|
||||
chef_version '~> 13.0' if respond_to?(:chef_version)
|
||||
|
||||
depends 'homebrew'
|
||||
|
|
|
@ -9,6 +9,10 @@ action_class do
|
|||
node['vsts_agent']['admin_user']
|
||||
end
|
||||
|
||||
def staff_group
|
||||
'staff'
|
||||
end
|
||||
|
||||
def agent_home
|
||||
::File.join('/Users', admin_user, 'vsts-agent')
|
||||
end
|
||||
|
@ -29,6 +33,10 @@ action_class do
|
|||
node['vsts_agent']['account']
|
||||
end
|
||||
|
||||
def account_url
|
||||
'https://' + account_name + '.visualstudio.com'
|
||||
end
|
||||
|
||||
def vsts_environment
|
||||
default_environment.merge(additional_environment)
|
||||
end
|
||||
|
@ -38,7 +46,7 @@ action_class do
|
|||
end
|
||||
|
||||
def default_environment
|
||||
{ VSTS_AGENT_INPUT_URL: agent_data[:account_url],
|
||||
{ VSTS_AGENT_INPUT_URL: account_url,
|
||||
VSTS_AGENT_INPUT_AUTH: 'PAT',
|
||||
VSTS_AGENT_INPUT_TOKEN: agent_data[:personal_access_token],
|
||||
VSTS_AGENT_INPUT_POOL: node['vsts_agent']['agent_pool'],
|
||||
|
@ -51,7 +59,7 @@ action_class do
|
|||
end
|
||||
|
||||
def agent_data
|
||||
data_bag_item('vsts', 'build_agent')
|
||||
data_bag_item node['vsts_agent']['data_bag'], node['vsts_agent']['data_bag_item']
|
||||
end
|
||||
|
||||
def launchd_plist
|
||||
|
@ -82,52 +90,56 @@ action :install do
|
|||
directory '/usr/local/lib/' do
|
||||
recursive true
|
||||
owner admin_user
|
||||
group 'admin'
|
||||
group staff_group
|
||||
end
|
||||
|
||||
link '/usr/local/lib/libcrypto.1.0.0.dylib' do
|
||||
to '/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib'
|
||||
owner admin_user
|
||||
group staff_group
|
||||
end
|
||||
|
||||
link '/usr/local/lib/libssl.1.0.0.dylib' do
|
||||
to '/usr/local/opt/openssl/lib/libssl.1.0.0.dylib'
|
||||
owner admin_user
|
||||
group staff_group
|
||||
end
|
||||
|
||||
directory agent_home do
|
||||
owner admin_user
|
||||
group 'staff'
|
||||
group staff_group
|
||||
end
|
||||
|
||||
directory "#{admin_library}/LaunchAgents" do
|
||||
recursive true
|
||||
owner admin_user
|
||||
group 'staff'
|
||||
group staff_group
|
||||
end
|
||||
|
||||
directory "#{admin_home}/Downloads/vsts-agent" do
|
||||
recursive true
|
||||
owner admin_user
|
||||
group 'staff'
|
||||
group staff_group
|
||||
end
|
||||
|
||||
remote_file target_path do
|
||||
source release_download_url
|
||||
owner admin_user
|
||||
group 'admin'
|
||||
group staff_group
|
||||
show_progress true
|
||||
end
|
||||
|
||||
tar_extract target_path do
|
||||
target_dir agent_home
|
||||
group 'admin'
|
||||
group staff_group
|
||||
user admin_user
|
||||
action :extract_local
|
||||
only_if { agent_needs_update? }
|
||||
end
|
||||
|
||||
directory "#{admin_home}/Downloads/vsts-agent" do
|
||||
user admin_user
|
||||
group staff_group
|
||||
action :nothing
|
||||
recursive true
|
||||
subscribes :delete, 'tar_extract[vsts agent source]', :delayed
|
||||
|
@ -160,29 +172,25 @@ action :install_service do
|
|||
directory "#{admin_library}/Logs" do
|
||||
recursive true
|
||||
owner admin_user
|
||||
group 'admin'
|
||||
mode 0o775
|
||||
group staff_group
|
||||
end
|
||||
|
||||
directory "#{admin_library}/Logs/vsts.agent.#{account_name}.#{agent_name}" do
|
||||
recursive true
|
||||
owner admin_user
|
||||
group 'admin'
|
||||
mode 0o775
|
||||
group staff_group
|
||||
end
|
||||
|
||||
file "#{agent_home}/runsvc.sh" do
|
||||
owner admin_user
|
||||
group 'admin'
|
||||
mode 0o775
|
||||
group staff_group
|
||||
content ::File.open("#{agent_home}/bin/runsvc.sh").read
|
||||
action :create
|
||||
end
|
||||
|
||||
file "#{agent_home}/.service" do
|
||||
owner admin_user
|
||||
group 'admin'
|
||||
mode 0o775
|
||||
group staff_group
|
||||
content launchd_plist
|
||||
action :create
|
||||
end
|
||||
|
@ -204,6 +212,14 @@ action :install_service do
|
|||
end
|
||||
end
|
||||
|
||||
action :start_service do
|
||||
execute 'start service with launchctl' do
|
||||
user admin_user
|
||||
command [launchctl_command, 'load', '-w', launchd_plist]
|
||||
not_if { service_started? }
|
||||
end
|
||||
end
|
||||
|
||||
action :uninstall_service do
|
||||
file "#{agent_home}/runsvc.sh" do
|
||||
action :delete
|
||||
|
@ -218,14 +234,6 @@ action :uninstall_service do
|
|||
end
|
||||
end
|
||||
|
||||
action :start_service do
|
||||
execute 'start service with launchctl' do
|
||||
user admin_user
|
||||
command [launchctl_command, 'load', '-w', launchd_plist]
|
||||
not_if { service_started? }
|
||||
end
|
||||
end
|
||||
|
||||
action :stop_service do
|
||||
execute 'stop service with launchctl' do
|
||||
user admin_user
|
||||
|
|
ΠΠ°Π³ΡΡΠ·ΠΊΠ°β¦
Π‘ΡΡΠ»ΠΊΠ° Π² Π½ΠΎΠ²ΠΎΠΉ Π·Π°Π΄Π°ΡΠ΅