Skip to content

Commit cdf2084

Browse files
authored
Merge pull request #110 from chef-partners/rhass/timeout-debug
Fix Starter Kit Download issues add improvements for debugging.
2 parents 237076d + 4d6a136 commit cdf2084

File tree

8 files changed

+49
-22
lines changed

8 files changed

+49
-22
lines changed

arm-templates/automate/automate_setup.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@
3232
config.puts(%Q{api_fqdn "#{@fqdn}"})
3333
end
3434

35+
environment = {
36+
'HOME' => '/root'
37+
}
38+
3539
# Configure the hostname
36-
hostname = Mixlib::ShellOut.new("chef-marketplace-ctl hostname #{@fqdn}")
40+
hostname = Mixlib::ShellOut.new("chef-marketplace-ctl hostname #{@fqdn}", env: environment)
3741
hostname.run_command
3842

3943
# Configure Automate
40-
configure = Mixlib::ShellOut.new("chef-marketplace-ctl setup --preconfigure")
44+
configure = Mixlib::ShellOut.new("chef-marketplace-ctl setup --preconfigure", env: environment)
4145
configure.run_command

cloudformation/marketplace_byol.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ Resources:
253253
- |+
254254
255255
- - '#!/bin/bash -ex'
256+
- export HOME=/root
256257
- !If
257258
- HasLicenseUrl
258259
- !Sub >-

files/chef-marketplace-cookbooks/chef-marketplace/attributes/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
m["platform"] = "aws"
1717
m["user"] = "ec2-user"
1818
m["api_ssl_port"] = 443
19+
m["update_channel"] = :stable
1920
m["reporting"]["cron"]["enabled"] = true
2021
m["reporting"]["cron"]["expression"] = "0 0 * * *"
2122
m["reporting"]["cron"]["year"] = "date +%Y"

files/chef-marketplace-cookbooks/chef-marketplace/recipes/_upgrade_automate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Chef Automate
1515
chef_ingredient 'delivery' do
1616
action :upgrade
17-
17+
channel node['chef-marketplace']['update_channel'].to_sym
1818
notifies :run, 'bash[delivery-ctl reconfigure]', :immediately
1919
notifies :run, 'bash[yum-clean-all]', :immediately
2020
notifies :run, 'bash[apt-get-clean]', :immediately
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
upstream biscotti {
2-
server 127.0.0.1:<%= node['chef-marketplace']['biscotti']['port'] %>;
2+
# Disable fail_timeout and max_fails accounting for Unicorn.
3+
# https://git.io/vAzf0
4+
server 127.0.0.1:<%= node['chef-marketplace']['biscotti']['port'] %> max_fails=0 fail_timeout=0;
35
}

files/chef-marketplace-ctl-commands/setup.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
options.preconfigure = false
88
options.license_url = nil
99
options.license_base64 = nil
10+
options.debug = false
1011

1112
OptionParser.new do |opts|
1213
opts.banner = "Usage: chef-marketplace-ctl setup [options]"
@@ -60,6 +61,10 @@
6061
options.license_base64 = license
6162
end
6263

64+
opts.on("--debug", "Enable debug logging output.") do
65+
options.debug = true
66+
end
67+
6368
opts.on("-h", "--help", "Show this message") do
6469
puts opts
6570
exit

files/chef-marketplace-ctl-commands/upgrade.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require "json"
22

3+
RELEASE_CHANNELS = %w(unstable current stable)
4+
35
add_command_under_category "upgrade", "Maintenance", "Upgrade or install Chef software", 2 do
46
config = {
57
"chef-marketplace" => {
@@ -64,6 +66,10 @@
6466
config["chef-marketplace"]["upgrade_packages"] << "automate"
6567
end
6668

69+
opts.on("-r RELEASE_CHANNEL", "--channel RELEASE_CHANNEL", RELEASE_CHANNELS, "Release channel to use for downloading packages to install") do |channel|
70+
config["chef-marketplace"]["update_channel"] = channel.to_sym
71+
end
72+
6773
opts.on("-h", "--help", "Show this message") do
6874
puts opts
6975
exit(0)

files/chef-marketplace-gem/lib/marketplace/setup.rb

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,34 +77,41 @@ def setup_automate
7777
# * determine correct email
7878
# * create user with existing delivery.{pem,pub}
7979
create_user = [
80-
"chef-server-ctl user-create",
81-
"delivery", # options.username.to_s.shellescape,
82-
"Automate", # options.first_name.to_s.shellescape,
83-
"User", # options.last_name.to_s.shellescape,
84-
"[email protected]", # options.email.to_s.shellescape,
85-
passwords["chef_user"].shellescape, # options.password.to_s.shellescape
86-
"-f /etc/delivery/delivery.pem",
87-
].join(" ")
80+
"chef-server-ctl",
81+
"user-create",
82+
"delivery", # options.username,
83+
"Automate", # options.first_name,
84+
"User", # options.last_name,
85+
"[email protected]", # options.email,
86+
passwords["chef_user"], # options.password
87+
"-f", "/etc/delivery/delivery.pem",
88+
].shelljoin
8889
retry_command(create_user, retries: 1)
8990

9091
# create chef server org
9192
create_org = [
92-
"chef-server-ctl org-create",
93-
"delivery", # options.organization.to_s.shellescape,
94-
"delivery", # options.organization.to_s.shellescape,
95-
"-a",
96-
"delivery" # options.username.to_s.shellescape
97-
].join(" ")
93+
"chef-server-ctl",
94+
"org-create",
95+
"delivery", # options.organization,
96+
"delivery", # options.organization,
97+
"-a", "delivery" # options.username
98+
].shelljoin
9899
retry_command(create_org, retries: 1)
99100

101+
# Try to wait for automate to come up before attempting to create the
102+
# automate enterprise. This has the added bonus of being able to log
103+
# the state of all the services while we wait.
104+
retry_command("delivery-ctl status", retries: 60, seconds: 2) # Wait up to two minutes.
105+
100106
# create automate enterprise
101107
create_ent = [
102-
"delivery-ctl create-enterprise",
108+
"delivery-ctl",
109+
"create-enterprise",
103110
"default", # enterprise name
104111
"--ssh-pub-key-file=/etc/delivery/builder.pub", # builder public key
105-
"--password=#{passwords['admin_user'].shellescape}", # admin password
106-
"--builder-password=#{passwords['builder_user'].shellescape}" # builder password
107-
].join(" ")
112+
"--password=#{passwords['admin_user']}", # admin password
113+
"--builder-password=#{passwords['builder_user']}" # builder password
114+
].shelljoin
108115
retry_command(create_ent, retries: 3, seconds: 10)
109116
end
110117

@@ -367,6 +374,7 @@ def retry_command(cmd, retries: 5, seconds: 2, env: {})
367374
retries.times do
368375
command = Mixlib::ShellOut.new(cmd)
369376
command.environment = env unless env.empty?
377+
command.live_stream = STDOUT if options.debug
370378
command.run_command
371379
return unless command.error?
372380
ui.say("#{cmd} failed, retrying...")

0 commit comments

Comments
 (0)