Change default location of puppet-network interfaces file on Debian

In order to compare the difference between sysinv database and currently
configured interfaces the destination directory will be changed to
/var/run/network-scripts.puppet/

This new location will be used by apply_network_config script to
update modified configuration from the database and save the result
in /etc/network/interfaces.d/ to be used during boot

Story: 2009101
Task: 44570

Signed-off-by: Andre Fernando Zanella Kantek <AndreFernandoZanella.Kantek@windriver.com>
Change-Id: I0b54688ee4ce658a23ef6257481a44d96f29f441
This commit is contained in:
Andre Fernando Zanella Kantek 2022-02-22 09:45:04 -03:00 committed by Andre Kantek
parent 4ba94078f5
commit df184de40a
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,50 @@
From cb0e726128a9565aa2f5ea97c8c9fafe944dd173 Mon Sep 17 00:00:00 2001
From: Andre Fernando Zanella Kantek
<AndreFernandoZanella.Kantek@windriver.com>
Date: Tue, 22 Feb 2022 09:09:08 -0300
Subject: [PATCH] save result file to /var/run/network-scripts.puppet/ to allow
manipulation before is saved in /etc/network/
Signed-off-by: Andre Fernando Zanella Kantek <AndreFernandoZanella.Kantek@windriver.com>
---
lib/puppet/provider/network_config/interfaces.rb | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/puppet/provider/network_config/interfaces.rb b/lib/puppet/provider/network_config/interfaces.rb
index 73b3286..d72ab45 100644
--- a/lib/puppet/provider/network_config/interfaces.rb
+++ b/lib/puppet/provider/network_config/interfaces.rb
@@ -19,12 +19,19 @@ Puppet::Type.type(:network_config).provide(:interfaces) do
has_feature :provider_options
has_feature :hotpluggable
+ # WRS: Generate temporary copy. It will get compared to file
+ # /etc/network/interfaces afterward. Only config that have changed
+ # will get replaced. Don't let puppet directly manage it, else it will
+ # trigger un-wanted networking actions (like up/down).
+ SCRIPT_DIRECTORY = '/var/run/network-scripts.puppet/'
+ SCRIPT_FILE = SCRIPT_DIRECTORY + 'interfaces'
+
def select_file
- '/etc/network/interfaces'
+ SCRIPT_FILE
end
def self.target_files
- ['/etc/network/interfaces']
+ [SCRIPT_FILE]
end
class MalformedInterfacesError < Puppet::Error
@@ -242,6 +249,8 @@ Puppet::Type.type(:network_config).provide(:interfaces) do
# Generate an array of sections
def self.format_file(_filename, providers)
+ Dir.mkdir(SCRIPT_DIRECTORY) unless File.exists?(SCRIPT_DIRECTORY)
+
contents = []
contents << header
--
2.17.1

View File

@ -0,0 +1 @@
0001-save-result-file-to-var-run-network-to-allow-manipul.patch