Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CHEF
cookbooks
sys
Commits
921d1d0f
Commit
921d1d0f
authored
Jul 01, 2022
by
Christopher Huhn
Browse files
Cleanup network setup a bit
parent
8c77dbf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
recipes/systemd.rb
View file @
921d1d0f
...
...
@@ -88,22 +88,23 @@ if node['sys']['systemd']['networkd']['make_primary_interface_persistent']
gateway
=
node
[
'network'
][
'default_gateway'
].
to_s
cidr
=
node
[
'network'
][
'interfaces'
][
interface
][
'addresses'
][
ipaddress
][
'prefixlen'
].
to_s
unless
interface
.
empty?
||
ipaddress
.
empty?
||
gateway
.
empty?
||
cidr
.
empty?
# ~FC023
sys_systemd_unit
"
#{
interface
}
.network"
do
directory
'/etc/systemd/network'
config
({
'Match'
=>
{
'Name'
=>
interface
},
'Network'
=>
{
'Address'
=>
"
#{
ipaddress
}
/
#{
cidr
}
"
,
},
'Route'
=>
{
'Gateway'
=>
gateway
}
})
action
:create
notifies
(
:restart
,
'service[systemd-networkd]'
,
:delayed
)
if
systemd_active?
end
sys_systemd_unit
"
#{
interface
}
.network"
do
directory
'/etc/systemd/network'
config
(
'Match'
=>
{
'Name'
=>
interface
},
'Network'
=>
{
'Address'
=>
"
#{
ipaddress
}
/
#{
cidr
}
"
,
},
'Route'
=>
{
'Gateway'
=>
gateway
}
)
action
:create
notifies
(
:restart
,
'service[systemd-networkd]'
,
:delayed
)
if
systemd_active?
# only create the network config if the gathered info is complete:
only_if
{
interface
&&
ipaddress
&&
gateway
&&
cidr
}
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment