Skip to content

Instantly share code, notes, and snippets.

@hassanakram
Last active May 17, 2021 17:38
Show Gist options
  • Select an option

  • Save hassanakram/22df5b8f83dc794cc0798ec7c31adcd3 to your computer and use it in GitHub Desktop.

Select an option

Save hassanakram/22df5b8f83dc794cc0798ec7c31adcd3 to your computer and use it in GitHub Desktop.
apt_repository 'ppa:longsleep/golang-backports' do
action :add
end
package "golang-1.16-go" do
action :install
end
remote_file "/usr/local/" do
source "https://github.com/vouch/vouch-proxy/archive/refs/tags/v0.23.1.tar.gz"
end
execute 'extract-vounch-proxy' do
command 'tar xzf /usr/local/v0.23.1.tar.gz -C /usr/local/'
cwd '/usr/local'
end
execute 'vounch-proxy-link' do
command 'ln /usr/lib/go-1.8/bin/go /usr/bin/go'
end
execute 'update-alternatives-install-go' do
command 'update-alternatives --force --install "/usr/bin/go" "go" "/usr/lib/go-1.16/bin/go" 0'
end
execute 'update-alternatives-set-go' do
command 'sudo update-alternatives --force --set go /usr/lib/go-1.16/bin/go'
end
execute 'build-vouch' do
command './do.sh goget'
cwd '/usr/local/vouch-proxy-0.23.1/'
end
execute 'build-vouch' do
command './do.sh build'
cwd '/usr/local/vouch-proxy-0.23.1/'
end
sso_okta_secrets = data_bag_item('passwords', 'appname_sso_okta_secrets')
template 'config.yml' do
path '/usr/local/vouch-proxy-0.23.1/config/config.yml'
mode '0644'
notifies :restart, 'service[vouch-proxy]', :delayed
variables(
okta_client_id: sso_okta_secrets['client_id'],
okta_client_secret: sso_okta_secrets['client_secret']
)
end
systemd_unit 'vouch-proxy.service' do
content <<~EOU
[Unit]
Description=Vouch
After=vouch.service
[Service]
Type=simple
WorkingDirectory=/usr/local/vouch-proxy-0.23.1/
ExecStart=/usr/local/vouch-proxy-0.23.1/vouch-proxy
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target
EOU
action [:create, :enable]
end
template 'app.conf' do
path '/etc/nginx/sites-enabled/app.conf'
end
template 'vouch.conf' do
path '/etc/nginx/sites-enabled/vouch.conf'
end
%w(vouch-proxy nginx).each do |srv|
service srv do
action :restart
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment