From 13b10a881c4765abc6c29df3406d9e6c4a5931dc Mon Sep 17 00:00:00 2001 From: Ben Abrams Date: Wed, 29 Aug 2018 10:44:24 -0700 Subject: [PATCH] atlantis with upstart on ubuntu 14.04 Signed-off-by: Ben Abrams --- .kitchen.yml | 8 +++++ .travis.yml | 1 + metadata.rb | 5 ++- resources/service_upstart.rb | 31 +++++++++++++++++++ templates/default/atlantis.upstart.conf.erb | 25 +++++++++++++++ .../cookbooks/atlantis_test/recipes/server.rb | 10 ++++-- 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 resources/service_upstart.rb create mode 100644 templates/default/atlantis.upstart.conf.erb diff --git a/.kitchen.yml b/.kitchen.yml index 7bcc795..31a941b 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -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: diff --git a/.travis.yml b/.travis.yml index b776367..bf9c935 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ rvm: env: matrix: + - INSTANCE=server-ubuntu-1404 - INSTANCE=server-ubuntu-1604 - INSTANCE=server-ubuntu-1804 diff --git a/metadata.rb b/metadata.rb index 4237a57..f05ef6f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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' diff --git a/resources/service_upstart.rb b/resources/service_upstart.rb new file mode 100644 index 0000000..8012c6b --- /dev/null +++ b/resources/service_upstart.rb @@ -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 diff --git a/templates/default/atlantis.upstart.conf.erb b/templates/default/atlantis.upstart.conf.erb new file mode 100644 index 0000000..55461c6 --- /dev/null +++ b/templates/default/atlantis.upstart.conf.erb @@ -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 diff --git a/test/fixtures/cookbooks/atlantis_test/recipes/server.rb b/test/fixtures/cookbooks/atlantis_test/recipes/server.rb index 065c914..78f10ba 100644 --- a/test/fixtures/cookbooks/atlantis_test/recipes/server.rb +++ b/test/fixtures/cookbooks/atlantis_test/recipes/server.rb @@ -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