Sha256: f41fea0272e5a412421fe70b6f6c97a2e0861d1e8351a30c6d1ec9dba7c93161

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

# ref. http://qiita.com/yunano/items/7ef5fa5670721de55627
directory "/etc/consul.d"

# Set systemd script
define :consul_systemd_script do
  environment_file = params[:name]

  template "/etc/systemd/system/consul.service" do
    variables(
      environment_file: environment_file,
      bin_path:         "#{node[:consul][:bin_dir]}/consul",
      data_dir:         node[:consul][:data_dir],
    )

    notifies :run,     "execute[systemctl daemon-reload]"
    notifies :restart, "service[consul]"
  end

  execute "systemctl daemon-reload" do
    action :nothing
  end
end

# Set init.d script
define :consul_initd_script do
  environment_file = params[:name]

  template "/etc/init.d/consul" do
    mode "755"
    variables(
      environment_file: environment_file,
      bin_path:         "#{node[:consul][:bin_dir]}/consul",
      data_dir:         node[:consul][:data_dir],
    )

    notifies :restart, "service[consul]"
  end
end

case node[:platform]
when "debian"
  environment_file = "/etc/default/consul"

  template environment_file do
    variables(
      gomaxprocs: node[:consul][:gomaxprocs],
      options:    node[:consul][:options],
    )
  end

  if node[:platform_version].to_i >= 8
    consul_systemd_script environment_file

    service "consul" do
      action [:enable, :start]
    end
  end

when "redhat"
  environment_file = "/etc/sysconfig/consul"

  template environment_file do
    variables(
      gomaxprocs: node[:consul][:gomaxprocs],
      options:    node[:consul][:options],
    )
  end

  if node[:platform_version].to_i >= 7
    consul_systemd_script environment_file
  else
    consul_initd_script environment_file
  end

  service "consul" do
    action [:enable, :start]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
itamae-plugin-recipe-consul-0.1.0.beta1 lib/itamae/plugin/recipe/consul/service.rb