From 915642e5305197474a0696499c6c543dc47ad1b0 Mon Sep 17 00:00:00 2001 From: Jordi Clariana Date: Wed, 8 Oct 2014 13:27:24 +0200 Subject: [PATCH 1/3] Fix: do not print properies if they are absent. The previous check was wrong because the "provider.send(propery)" returns a string and was always true. --- lib/puppet/provider/network_config/interfaces.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/network_config/interfaces.rb b/lib/puppet/provider/network_config/interfaces.rb index 94fe164d..85fa67c2 100644 --- a/lib/puppet/provider/network_config/interfaces.rb +++ b/lib/puppet/provider/network_config/interfaces.rb @@ -273,7 +273,7 @@ def self.format_file(filename, providers) [:netmask, 'netmask'], [:mtu, 'mtu'], ].each do |(property, section)| - stanza << "#{section} #{provider.send property}" if provider.send(property) + stanza << "#{section} #{provider.send property}" if provider.send(property) and provider.send(propery) != 'absent' end if provider.options From 8db9cd756a5272cc2ea3f9d04e56808004964941 Mon Sep 17 00:00:00 2001 From: Jordi Clariana Date: Wed, 8 Oct 2014 16:48:36 +0200 Subject: [PATCH 2/3] Fix: Typo and convert to string the propery --- lib/puppet/provider/network_config/interfaces.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/network_config/interfaces.rb b/lib/puppet/provider/network_config/interfaces.rb index 85fa67c2..8095e409 100644 --- a/lib/puppet/provider/network_config/interfaces.rb +++ b/lib/puppet/provider/network_config/interfaces.rb @@ -273,7 +273,7 @@ def self.format_file(filename, providers) [:netmask, 'netmask'], [:mtu, 'mtu'], ].each do |(property, section)| - stanza << "#{section} #{provider.send property}" if provider.send(property) and provider.send(propery) != 'absent' + stanza << "#{section} #{provider.send property}" if provider.send(property) and provider.send(property).to_s != 'absent' end if provider.options From 16db25d8da95d24b5612eb4d8ed30d31451c1e36 Mon Sep 17 00:00:00 2001 From: Jordi Clariana Date: Thu, 9 Oct 2014 17:00:44 +0200 Subject: [PATCH 3/3] Compare to :absent is the proper way to do it. provider,options can also be absent, so it has to be checked. --- lib/puppet/provider/network_config/interfaces.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/network_config/interfaces.rb b/lib/puppet/provider/network_config/interfaces.rb index 8095e409..64da85c3 100644 --- a/lib/puppet/provider/network_config/interfaces.rb +++ b/lib/puppet/provider/network_config/interfaces.rb @@ -273,10 +273,10 @@ def self.format_file(filename, providers) [:netmask, 'netmask'], [:mtu, 'mtu'], ].each do |(property, section)| - stanza << "#{section} #{provider.send property}" if provider.send(property) and provider.send(property).to_s != 'absent' + stanza << "#{section} #{provider.send property}" if provider.send(property) and provider.send(property) != :absent end - if provider.options + if provider.options and provider.options != :absent provider.options.each_pair do |key, val| if val.is_a? String stanza << " #{key} #{val}"