Skip to content

Commit

Permalink
Add service management for wg-quick
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoleon committed May 16, 2023
1 parent 5c65ea4 commit bbb00c3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions manifests/provider/wgquick.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
define wireguard::provider::wgquick (
String[1] $interface = $title,
Enum['present', 'absent'] $ensure = 'present',
Boolean $enable = true,
Wireguard::Peers $peers = [],
Integer[1024, 65000] $dport = Integer(regsubst($title, '^\D+(\d+)$', '\1')),
Optional[Integer[0,4294967295]] $firewall_mark = undef,
Expand Down Expand Up @@ -36,14 +37,24 @@
}
} else {
concat { "/etc/wireguard/${interface}.conf":
ensure => $ensure,
owner => 'root',
mode => '0600',
ensure => $ensure,
owner => 'root',
mode => '0600',
notify => Service["wg-quick@${interface}"],
}
concat::fragment { "${interface}_head":
order => 10,
target => "/etc/wireguard/${interface}.conf",
content => epp("${module_name}/wireguard_head.epp", $params),
}
}
$svc_ensure = $ensure ? {
present => 'running',
absent => 'stopped',
}
service { "wg-quick@${interface}":
ensure => $svc_ensure,
enable => $enable,
}
}

0 comments on commit bbb00c3

Please sign in to comment.