Skip to content

Commit

Permalink
atlantis with upstart on ubuntu 14.04
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Abrams <me@benabrams.it>
  • Loading branch information
majormoses committed Aug 29, 2018
1 parent 5667275 commit 13b10a8
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ verifier:
name: inspec

platforms:
- name: ubuntu-1404
named_run_list: debian
driver:
image: dokken/ubuntu-14.04
pid_one_command: /sbin/init
intermediate_instructions: # any tasks before runlist is evaluated and run
- RUN apt-get -y update && apt-get install -y net-tools curl
- ENV container docker
- name: ubuntu-1604
named_run_list: debian
driver:
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rvm:

env:
matrix:
- INSTANCE=server-ubuntu-1404
- INSTANCE=server-ubuntu-1604
- INSTANCE=server-ubuntu-1804

Expand Down
5 changes: 4 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
chef_version '>= 13.0' if respond_to?(:chef_version)
issues_url 'https://github.com/majormoses/atlantis-chef/issues' if respond_to?(:issues_url)
source_url 'https://github.com/majormoses/atlantis-chef' if respond_to?(:source_url)
supports 'ubuntu'
# probably supports others but thats what we are currently testing
supports 'ubuntu', '= 14.04'
supports 'ubuntu', '= 16.04'
supports 'ubuntu', '= 18.04'

version SemVer.find.format '%M.%m.%p'

Expand Down
31 changes: 31 additions & 0 deletions resources/service_upstart.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
property :atlantis_service_template_variables, Hash, default: {
:atlantis_user => 'atlantis',
:atlantis_bin_location => '/usr/local/bin/atlantis',
:atlantis_config_name => 'atlantis.yaml',
:atlantis_home => '/opt/atlantis',
:timeout_stop_sec => 5,
}
property :atlantis_service_template_cookbook, String, default: 'atlantis'
property :atlantis_user, String, default: 'atlantis'

default_action :setup

action :setup do
template 'atlantis.upstart.conf' do
cookbook new_resource.atlantis_service_template_cookbook
path '/etc/init/atlantis.conf'
action :create
variables(vars: new_resource.atlantis_service_template_variables)
end

service 'atlantis' do
action [:enable, :start]
provider Chef::Provider::Service::Upstart
end
end

action :remove do
file '/etc/init/atlantis.conf' do
action :delete
end
end
25 changes: 25 additions & 0 deletions templates/default/atlantis.upstart.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
description "Atlantis"

start on runlevel [2345]
stop on runlevel [06]

respawn
respawn limit 10 10

umask 022

chdir <%= @vars[:atlantis_home] || '/opt/atlantis' %>
env GOMAXPROCS="2"
env PATH="/usr/local/bin:/usr/bin:/bin:/sbin"

kill signal TERM
kill timeout <%= @vars[:timeout_stop_sec] || 5 %>
reload signal HUP

script
# debug
set -x

# start the service
exec start-stop-daemon --start --chuid <%= @vars[:atlantis_user] %> --exec <%= @vars[:atlantis_bin_location] %> -- server --config <%= @vars[:atlantis_home] %>/<%= @vars[:atlantis_config_name] %>
end script
10 changes: 8 additions & 2 deletions test/fixtures/cookbooks/atlantis_test/recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
action :install
end

atlantis_service_systemd 'atlantis' do
action :setup
if node['platform_version'] == '14.04'
atlantis_service_upstart 'atlantis' do
action :setup
end
else
atlantis_service_systemd 'atlantis' do
action :setup
end
end

0 comments on commit 13b10a8

Please sign in to comment.