Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Synchronize st2.conf with upstream #33

Merged
merged 10 commits into from
Nov 15, 2016
38 changes: 25 additions & 13 deletions attributes/config.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
include_attribute 'stackstorm::user'

# Config defaults options
# Ordered as they appear in original `st2.conf`:
# https://github.com/StackStorm/st2/blob/master/conf/st2.package.conf
default['stackstorm']['config'] = {
api_url: 'http://localhost:9101',
conf_root: '/etc',
debug: false,
api_url: 'http://127.0.0.1:9101',
api_host: '0.0.0.0',
api_port: 9101,
api_mask_secrets: true,
api_allow_origin: '*',

auth_host: '0.0.0.0',
auth_port: 9100,
auth_use_ssl: false,
auth_debug: false,
auth_enable: true,
rmq_host: 'localhost',
rmq_vhost: nil,
rmq_username: 'guest',
rmq_password: 'guest',
rmq_port: 5672,
allow_origin: '*',
auth_standalone_file: '/etc/st2/htpasswd',

syslog_enabled: false,
syslog_host: 'localhost',
syslog_host: '127.0.0.1',
syslog_port: 514,
syslog_facility: 'local7',
syslog_protocol: 'udp',

log_mask_secrets: true,

system_user: node['stackstorm']['user']['user'],
ssh_key_file: "#{node['stackstorm']['user']['home']}/.ssh/id_rsa",
db_host: 'localhost',

rmq_host: '127.0.0.1',
rmq_vhost: nil,
rmq_username: 'guest',
rmq_password: 'guest',
rmq_port: 5672,

db_host: '127.0.0.1',
db_port: 27017,
db_name: 'st2',
db_username: nil,
db_password: nil,
mask_secrets: true
db_password: nil
}
8 changes: 0 additions & 8 deletions recipes/_initial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,3 @@
supports manage_home: true
action :create
end

# Fix localhost in hosts
hostsfile_entry '127.0.0.1' do
hostname 'localhost'
comment 'Appended by st2 cookbook'
action :append
only_if { platform_family?('rhel') }
end
7 changes: 0 additions & 7 deletions spec/recipes/_initial_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,5 @@
}
)
end

it 'should append hostsfile_entry "st2"' do
expect(chef_run).to append_hostsfile_entry('127.0.0.1').with(
hostname: 'localhost',
comment: 'Appended by st2 cookbook'
)
end
end
end
90 changes: 58 additions & 32 deletions spec/recipes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,80 @@
# Host and port to bind the API server.
host = 0.0.0.0
port = 9101
logging = /etc/st2api/console.conf
logging = /etc/st2/logging.api.conf
mask_secrets = true
# allow_origin is required for handling CORS in st2 web UI.
# allow_origin = http://myhost1.example.com:3000,http://myhost2.example.com:3000
allow_origin = *

[stream]
logging = /etc/st2/logging.stream.conf

[sensorcontainer]
logging = /etc/st2reactor/console.conf
logging = /etc/st2/logging.sensorcontainer.conf

[rulesengine]
logging = /etc/st2reactor/console.conf
logging = /etc/st2/logging.rulesengine.conf

[actionrunner]
logging = /etc/st2actions/console.conf
logging = /etc/st2/logging.actionrunner.conf
virtualenv_opts = --always-copy

[resultstracker]
logging = /etc/st2/logging.resultstracker.conf

[notifier]
logging = /etc/st2/logging.notifier.conf

[exporter]
logging = /etc/st2/logging.exporter.conf

[garbagecollector]
logging = /etc/st2/logging.garbagecollector.conf

[auth]
host = 0.0.0.0
port = 9100
use_ssl = false
debug = 'false'
enable = true
logging = /etc/st2api/console.conf
use_ssl = False
debug = False
enable = True
logging = /etc/st2/logging.auth.conf

mode = standalone

# Note: Settings bellow are only used in "standalone" mode
backend = flat_file
backend_kwargs = {"file_path": "/etc/st2/htpasswd"}

# Base URL to the API endpoint excluding the version (e.g. http://myhost.net:9101/)
api_url = http://localhost:9101
api_url = http://127.0.0.1:9101

[system]
base_path = /opt/stackstorm

# [webui]
# webui_base_url = https://mywebhost.domain

[log]
excludes = requests,paramiko
redirect_stderr = False
mask_secrets = true
mask_secrets = True

[system_user]
user = stanley
ssh_key_file = /home/stanley/.ssh/id_rsa

[messaging]
url = amqp://guest:guest@localhost:5672/
url = amqp://guest:guest@127.0.0.1:5672/

[ssh_runner]
remote_dir = /tmp

[action_sensor]
triggers_base_url = http://localhost:9101/v1/triggertypes/

[resultstracker]
logging = /etc/st2actions/console.conf

[notifier]
logging = /etc/st2actions/console.conf
triggers_base_url = http://127.0.0.1:9101/v1/triggertypes/

[database]
host = localhost
host = 127.0.0.1
port = 27017
db_name = st2
)
Expand Down Expand Up @@ -119,32 +133,44 @@
group: 'root',
mode: 0644,
source: 'st2.conf.erb',
# Config options ordered as they appear in original `st2.conf`:
# https://github.com/StackStorm/st2/blob/master/conf/st2.package.conf
variables: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should alphabetize this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using it in a way as it appears in st2.conf for the reasons to verify synchronization easier in the future:
https://github.com/StackStorm/st2/blob/master/conf/st2.dev.conf

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, you should add a comment about that since whoever modifies this list next will just add it to the end since its not alphabetized

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good call!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much better :)

'api_url' => 'http://localhost:9101',
'conf_root' => '/etc',
'debug' => false,
'api_url' => 'http://127.0.0.1:9101',
'api_host' => '0.0.0.0',
'api_port' => 9101,
'api_mask_secrets' => true,
'api_allow_origin' => '*',

'auth_host' => '0.0.0.0',
'auth_port' => 9100,
'auth_use_ssl' => false,
'auth_debug' => false,
'auth_enable' => true,
'rmq_host' => 'localhost',
'rmq_vhost' => nil,
'rmq_username' => 'guest',
'rmq_password' => 'guest',
'rmq_port' => 5672,
'allow_origin' => '*',
'auth_standalone_file' => '/etc/st2/htpasswd',

'syslog_enabled' => false,
'syslog_host' => 'localhost',
'syslog_host' => '127.0.0.1',
'syslog_port' => 514,
'syslog_facility' => 'local7',
'syslog_protocol' => 'udp',

'log_mask_secrets' => true,

'system_user' => 'stanley',
'ssh_key_file' => '/home/stanley/.ssh/id_rsa',
'db_host' => 'localhost',

'rmq_host' => '127.0.0.1',
'rmq_vhost' => nil,
'rmq_username' => 'guest',
'rmq_password' => 'guest',
'rmq_port' => 5672,

'db_host' => '127.0.0.1',
'db_port' => 27017,
'db_name' => 'st2',
'db_username' => nil,
'db_password' => nil,
'mask_secrets' => true
'db_password' => nil
}
)
end
Expand Down
51 changes: 32 additions & 19 deletions templates/default/st2.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,46 @@

[api]
# Host and port to bind the API server.
host = 0.0.0.0
port = 9101
logging = <%= @conf_root %>/st2api/console.conf
mask_secrets = <%= @mask_secrets %>
host = <%= @api_host %>
port = <%= @api_port %>
logging = /etc/st2/logging.api.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove config option here as well?

mask_secrets = <%= @api_mask_secrets %>
# allow_origin is required for handling CORS in st2 web UI.
# allow_origin = http://myhost1.example.com:3000,http://myhost2.example.com:3000
allow_origin = <%= @allow_origin %>
allow_origin = <%= @api_allow_origin %>

[stream]
logging = /etc/st2/logging.stream.conf

[sensorcontainer]
logging = <%= @conf_root %>/st2reactor/console.conf
logging = /etc/st2/logging.sensorcontainer.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove config option?

Copy link
Member Author

@arm4b arm4b Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, included explanation in Commit message:

You can't overwrite conf_root from /etc/st2 to anything else, since it's globally hardcoded setting.

So /etc/st2 is hardcoded in packages, you can't change it and it's used in so many places.
Allowing users to edit conf_root brings confusion and broken installation.

Copy link
Member Author

@arm4b arm4b Nov 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's outdated bit that is still here from the legacy installer, before introducing actual .deb/.rpm packages.

I'm going to touch more abandoned things like that in upcoming Cookbook Cleanup.


[rulesengine]
logging = <%= @conf_root %>/st2reactor/console.conf
logging = /etc/st2/logging.rulesengine.conf

[actionrunner]
logging = <%= @conf_root %>/st2actions/console.conf
logging = /etc/st2/logging.actionrunner.conf
virtualenv_opts = --always-copy

[resultstracker]
logging = /etc/st2/logging.resultstracker.conf

[notifier]
logging = /etc/st2/logging.notifier.conf

[exporter]
logging = /etc/st2/logging.exporter.conf

[garbagecollector]
logging = /etc/st2/logging.garbagecollector.conf

[auth]
host = 0.0.0.0
port = 9100
host = <%= @auth_host %>
port = <%= @auth_port %>
use_ssl = <%= @auth_use_ssl %>
debug = <%= @debug ? 'true' : 'false' %>
debug = <%= @auth_debug %>
enable = <%= @auth_enable %>
logging = <%= @conf_root %>/st2api/console.conf
logging = /etc/st2/logging.auth.conf

mode = standalone
# Note: Settings bellow are only used in "standalone" mode
Expand All @@ -39,6 +55,9 @@ api_url = <%= @api_url %>
[system]
base_path = /opt/stackstorm

# [webui]
# webui_base_url = https://mywebhost.domain

<%- if @syslog_enabled -%>
[syslog]
host = <%= @syslog_host %>
Expand All @@ -50,7 +69,7 @@ protocol = <%= @syslog_protocol %>
[log]
excludes = requests,paramiko
redirect_stderr = False
mask_secrets = <%= @mask_secrets %>
mask_secrets = <%= @log_mask_secrets %>

[system_user]
user = <%= @system_user %>
Expand All @@ -65,12 +84,6 @@ remote_dir = /tmp
[action_sensor]
triggers_base_url = <%= @api_url %>/v1/triggertypes/

[resultstracker]
logging = <%= @conf_root %>/st2actions/console.conf

[notifier]
logging = <%= @conf_root %>/st2actions/console.conf

[database]
host = <%= @db_host %>
port = <%= @db_port %>
Expand Down