X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/3a4d52bd4c0f8e6ae7679145846b7bc7845d8ace..d16a271815bbfa1c2d5f38f106db0c7af7291a52:/cookbooks/openvpn/recipes/default.rb?ds=inline diff --git a/cookbooks/openvpn/recipes/default.rb b/cookbooks/openvpn/recipes/default.rb index 3a0bcccf5..2446fe970 100644 --- a/cookbooks/openvpn/recipes/default.rb +++ b/cookbooks/openvpn/recipes/default.rb @@ -1,14 +1,14 @@ # -# Cookbook Name:: openvpn +# Cookbook:: openvpn # Recipe:: default # -# Copyright 2012, OpenStreetMap Foundation +# Copyright:: 2012, OpenStreetMap Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -20,13 +20,15 @@ package "openvpn" service "openvpn" do - action [ :enable, :start ] + action [:enable, :start] supports :status => true, :restart => true, :reload => true ignore_failure true end node[:openvpn][:tunnels].each do |name, details| - if peer = search(:node, "fqdn:#{details[:peer][:host]}").first + peer = search(:node, "fqdn:#{details[:peer][:host]}").first + + if peer if peer[:openvpn] && !details[:peer][:address] node.default[:openvpn][:tunnels][name][:peer][:address] = peer[:openvpn][:address] end @@ -47,13 +49,13 @@ node[:openvpn][:tunnels].each do |name, details| end if File.exist?("/etc/openvpn/#{name}.key") - node.set[:openvpn][:keys][name] = IO.read("/etc/openvpn/#{name}.key") + node.normal[:openvpn][:keys][name] = IO.read("/etc/openvpn/#{name}.key") end elsif peer && peer[:openvpn] file "/etc/openvpn/#{name}.key" do owner "root" group "root" - mode 0600 + mode 0o600 content peer[:openvpn][:keys][name] end end @@ -63,7 +65,7 @@ node[:openvpn][:tunnels].each do |name, details| source "tunnel.conf.erb" owner "root" group "root" - mode 0644 + mode 0o644 variables :name => name, :address => node[:openvpn][:address], :port => node[:openvpn][:tunnels][name][:port],