You'd be better declaring netplan as a requires:
if $operatingsystem == "Ubuntu" {
if versioncmp($facts['os']['release']['full'], '18') >= 0 {
package { 'netplan':
ensure => present,
}
file { "/etc/netplan/windows-dhcp.yaml":
mode => '0644',
owner => "${rootUID}",
group => "${rootGID}",
content =>
epp("${module_name}/etc/netplan/windows-dhcp.yaml.epp"),
requires => Package['netplan'],
}
}
}
If you only want netplan on specific systems, then you'd want that
delcaration to be done in such a way to only apply to said systems, I leave
that as an exercise for the reader, as the mechanism that is best depends
heavily upon your own setup.
On Wednesday, May 15, 2019 at 2:45:44 PM UTC+1, Helmut Schneider wrote:
>
> Ben Ford wrote:
>
> > To be sure, this pattern doesn't always work and you don't always have
> > control over the full system. What's your use case that you're trying
> > to solve?
>
> if $operatingsystem == "Ubuntu" {
> if versioncmp($facts['os']['release']['full'], '18') >= 0 {
> file { "/etc/netplan/windows-dhcp.yaml":
> mode => '0644',
> owner => "${rootUID}",
> group => "${rootGID}",
> content =>
> epp("${module_name}/etc/netplan/windows-dhcp.yaml.epp"),
> }
> }
> }
>
> I would like to check if netplan is installed before doing so.
>
> onlyif => 'test -d /etc/netplan',
>
> would help. Or
>
> onlyif => 'test -n "`dpkg -l | grep netplan | grep ^ii`"',
>
> but I thought a custom fact would be more efficient.
>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/3c2b9457-e402-4474-a4aa-9d9697578b8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.