From 93a328f66e266632f52fa40cb116496233716271 Mon Sep 17 00:00:00 2001 From: Vitaly Khabarov Date: Mon, 12 Sep 2016 16:10:45 +0300 Subject: [PATCH] Added remote atttibute for multiple addresses on one server --- CHANGELOG.md | 3 +++ knife-openvpn.gemspec | 2 +- lib/chef/knife/openvpn.rb | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c4a5c9..d56f311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,5 @@ +## 0.0.6 (Sep 12, 2016) +* New "remote" attribute for multiple servers in client config + ## 0.0.4 (Sep 24, 2015) * add --force option for user certificate revokation diff --git a/knife-openvpn.gemspec b/knife-openvpn.gemspec index 5a96d72..461ada7 100644 --- a/knife-openvpn.gemspec +++ b/knife-openvpn.gemspec @@ -3,7 +3,7 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__) Gem::Specification.new do |gem| gem.name = 'knife-openvpn' - gem.version = '0.0.5' + gem.version = '0.0.6' gem.summary = 'A knife plugin for Express 42 openvpn cookbook' gem.description = gem.summary gem.authors = ['LLC Express 42'] diff --git a/lib/chef/knife/openvpn.rb b/lib/chef/knife/openvpn.rb index e0d493c..8b8897a 100644 --- a/lib/chef/knife/openvpn.rb +++ b/lib/chef/knife/openvpn.rb @@ -417,8 +417,14 @@ def generate_client_config(server_name, user_name) config_content << "dev #{config['dev']}" << newline config_content << "proto #{config['proto']}" << newline search_result.each do |result| - config_content << "remote #{result['openvpn'][server_name]['remote_host']} " - config_content << config['port'].to_s << newline + if result['openvpn'][server_name]['remote'].nil? + config_content << "remote #{result['openvpn'][server_name]['remote_host']} " + config_content << config['port'].to_s << newline + else + result['openvpn'][server_name]['remote'].each do |remote| + config_content << "remote #{remote}" << newline + end + end end config_content << "verb #{config['verb']}" << newline config_content << 'comp-lzo' << newline