The branch stable/14 has been updated by bapt:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bf187f6ac5b198d51b3db80c8876fc70ce75b162

commit bf187f6ac5b198d51b3db80c8876fc70ce75b162
Author:     Jesús Daniel Colmenares Oviedo <dt...@freebsd.org>
AuthorDate: 2025-09-11 16:52:30 +0000
Commit:     Baptiste Daroussin <b...@freebsd.org>
CommitDate: 2025-09-17 19:39:24 +0000

    nuageinit: Allow the use of network parameters from network-config
    
    To better comply with the cloud-init specification, we need to
    support the configuration of network-related parameters from
    the network-config file, which is common in most deployments.
    
    Reviewed by:            bapt@
    Approved by:            bapt@
    Differential Revision:  https://reviews.freebsd.org/D52419
    
    (cherry picked from commit 95230b248f6412c2d1c416c1e9795c3192cdf750)
---
 libexec/nuageinit/nuageinit   | 31 ++++++++++++++++++++++++++++++-
 libexec/nuageinit/nuageinit.7 |  7 +++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit
index c94eb822ba0f..5541f6d0f164 100755
--- a/libexec/nuageinit/nuageinit
+++ b/libexec/nuageinit/nuageinit
@@ -583,6 +583,26 @@ local function config2_network(p)
        routing:close()
 end
 
+local function parse_network_config()
+       local nc_file = ni_path .. "/network-config"
+       local nc_file_attr = lfs.attributes(nc_file)
+       if nc_file_attr == nil then
+               return
+       end
+       local f, err = io.open(nc_file)
+       if err then
+               nuage.err("error parsing nocloud network-config: " .. err)
+       end
+       local obj = yaml.load(f:read("*a"))
+       f:close()
+       if not obj then
+               nuage.err("error parsing nocloud network-config")
+       end
+       local netobj = {}
+       netobj["network"] = obj
+       return netobj
+end
+
 if citype == "config-2" then
        local parser = ucl.parser()
        local res, err = parser:parse_file(ni_path .. "/meta_data.json")
@@ -679,7 +699,16 @@ if line == "#cloud-config" then
        end
 
        for i = 1, #calls_table do
-               calls_table[i](obj)
+               if citype == "nocloud" and calls_table[i] == network_config then
+                       netobj = parse_network_config()
+                       if netobj == nil then
+                               network_config(obj)
+                       else
+                               network_config(netobj)
+                       end
+               else
+                       calls_table[i](obj)
+               end
        end
 elseif line:sub(1, 2) == "#!" then
        -- delay for execution at rc.local time --
diff --git a/libexec/nuageinit/nuageinit.7 b/libexec/nuageinit/nuageinit.7
index f02829618f44..8d9aac3d3809 100644
--- a/libexec/nuageinit/nuageinit.7
+++ b/libexec/nuageinit/nuageinit.7
@@ -183,6 +183,13 @@ configuration in
 .Pa /etc/ssh/sshd_config
 .It Ic network
 Network configuration parameters.
+.Pp
+Specifying the following parameters from a file named
+.Pa network-config
+takes precedence over their specification from the
+.Ic network
+parameter of
+.Pa user-data Ns .
 .Bl -tag -width "ethernets"
 .It Ic ethernets
 Mapping representing a generic configuration for existing network interfaces.

Reply via email to