diff --git a/README.md b/README.md
index a88822ff..dc3029db 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ Installs and configures [Consul][1] client, server and UI.
- CentOS 5.10, 6.5, 7.0
- RHEL 5.10, 6.5, 7.0
- Ubuntu 10.04, 12.04, 14.04
+- Arch Linux
## Attributes
@@ -135,19 +136,19 @@ Installs and configures [Consul][1] client, server and UI.
['consul']['init_style'] |
String |
- Service init mode for running consul as: init or runit |
+ Service init mode for running consul as: init, runit or systemd |
init |
['consul']['service_user'] |
String |
- For runit service: run consul as this user (init uses 'root') |
+ For runit/systemd service: run consul as this user (init uses 'root') |
consul |
['consul']['service_group'] |
String |
- For runit service: run consul as this group (init uses 'root') |
+ For runit/systemd service: run consul as this group (init uses 'root') |
consul |
diff --git a/attributes/default.rb b/attributes/default.rb
index ab0e116a..89bedd57 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -61,10 +61,10 @@
end
default['consul']['servers'] = []
-default['consul']['init_style'] = 'init' # 'init', 'runit'
+default['consul']['init_style'] = 'init' # 'init', 'runit', 'systemd'
case node['consul']['init_style']
-when 'runit'
+when 'runit' || 'systemd'
default['consul']['service_user'] = 'consul'
default['consul']['service_group'] = 'consul'
else
diff --git a/metadata.rb b/metadata.rb
index bb22475f..fdcd4a7a 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -21,6 +21,8 @@
supports 'ubuntu', '= 12.04'
supports 'ubuntu', '= 14.04'
+supports 'arch'
+
depends 'libarchive'
depends 'chef-provisioning'
depends 'golang', '~> 1.4'
diff --git a/recipes/_service.rb b/recipes/_service.rb
index ce27353e..19969f05 100644
--- a/recipes/_service.rb
+++ b/recipes/_service.rb
@@ -229,4 +229,17 @@
supports status: true, restart: true, reload: true
reload_command "'#{node['runit']['sv_bin']}' hup consul"
end
+when 'systemd'
+ template '/etc/systemd/system/consul.service' do
+ source 'consul-systemd.erb'
+ mode 0755
+ notifies :restart, 'service[consul]', :immediately
+ end
+
+ service 'consul' do
+ supports status: true, restart: true, reload: true
+ action [:enable, :start]
+ subscribes :restart, "file[#{consul_config_filename}]"
+ subscribes :restart, "link[#{Chef::Consul.active_binary(node)}]"
+ end
end
diff --git a/templates/default/consul-systemd.erb b/templates/default/consul-systemd.erb
new file mode 100644
index 00000000..a591784a
--- /dev/null
+++ b/templates/default/consul-systemd.erb
@@ -0,0 +1,17 @@
+[Unit]
+Description=Consul Agent
+Wants=basic.target
+After=basic.target network.target
+
+[Service]
+User=<%= node['consul']['service_user'] %>
+Group=<%= node['consul']['service_group'] %>
+ExecStart=<%= Chef::Consul.active_binary(node) %> agent \
+ -config-dir <%= node['consul']['config_dir'] %>
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+Restart=on-failure
+RestartSec=42s
+
+[Install]
+WantedBy=multi-user.target