Commit 5e04f6cf authored by James T. Lee's avatar James T. Lee
Browse files

PDK: Fix rubocop violations

parent 9a686706
---
fixtures: fixtures:
forge_modules: forge_modules:
stdlib: 'puppetlabs/stdlib' stdlib: 'puppetlabs/stdlib'
......
...@@ -18,6 +18,7 @@ AllCops: ...@@ -18,6 +18,7 @@ AllCops:
- "**/Puppetfile" - "**/Puppetfile"
- "**/Vagrantfile" - "**/Vagrantfile"
- "**/Guardfile" - "**/Guardfile"
- lib/puppet/provider/package/cygwin.rb
Layout/LineLength: Layout/LineLength:
Description: People have wide screens, use them. Description: People have wide screens, use them.
Max: 200 Max: 200
......
# This file can be used to customize the files managed by PDK. ---
# .rubocop.yml:
# See https://github.com/puppetlabs/pdk-templates/blob/main/README.md default_configs:
# for more information. AllCops:
# Exclude:
# See https://github.com/puppetlabs/pdk-templates/blob/main/config_defaults.yml - 'lib/puppet/provider/package/cygwin.rb'
# for the default values.
--- {}
Facter.add('gentoo_news_count') do Facter.add('gentoo_news_count') do
confine :osfamily => 'Gentoo' confine osfamily: 'Gentoo'
setcode do setcode do
Facter::Core::Execution.execute('/usr/bin/eselect news count').to_i Facter::Core::Execution.execute('/usr/bin/eselect news count').to_i
end end
......
Facter.add('is_container') do Facter.add('is_container') do
confine :kernel => 'Linux' confine kernel: 'Linux'
setcode do setcode do
Facter.value(:virtual) == 'lxc' or File.exist? '/run/.containerenv' Facter.value(:virtual) == 'lxc' or File.exist? '/run/.containerenv'
end end
......
Facter.add('machine_id') do Facter.add('machine_id') do
confine :kernel => 'Linux' confine kernel: 'Linux'
setcode do setcode do
if File.exist?('/etc/machine-id') if File.exist?('/etc/machine-id')
File.readlines('/etc/machine-id').map(&:chomp).first File.readlines('/etc/machine-id').map(&:chomp).first
......
Facter.add('podman_version') do Facter.add('podman_version') do
confine :kernel => 'Linux' confine kernel: 'Linux'
setcode do setcode do
if File.exist?('/usr/bin/podman') if File.exist?('/usr/bin/podman')
$1 if Facter::Core::Execution.execute('/usr/bin/podman --version') =~ /podman version (\S+)/ Regexp.last_match(1) if Facter::Core::Execution.execute('/usr/bin/podman --version') =~ %{podman version (\S+)}
end end
end end
end end
Facter.add('profile') do Facter.add('profile') do
confine :osfamily => 'Gentoo' confine osfamily: 'Gentoo'
setcode do setcode do
profile = Facter::Core::Execution.execute('/usr/bin/eselect --brief profile show') profile = Facter::Core::Execution.execute('/usr/bin/eselect --brief profile show')
case profile case profile
when %r{nest:(\S+)/(\S+)/(\S+)} when %r{nest:(\S+)/(\S+)/(\S+)}
{ :cpu => $1, :platform => $2, :role => $3 } { cpu: Regexp.last_match(1), platform: Regexp.last_match(2), role: Regexp.last_match(3) }
when %r{nest:(\S+)/(\S+)} when %r{nest:(\S+)/(\S+)}
{ :cpu => $1, :platform => $1, :role => $2 } { cpu: Regexp.last_match(1), platform: Regexp.last_match(1), role: Regexp.last_match(2) }
end end
end end
end end
Facter.add('profile') do Facter.add('profile') do
confine :osfamily => 'windows' confine osfamily: 'windows'
setcode do setcode do
{ :role => 'workstation' } { role: 'workstation' }
end end
end end
Facter.add('rpool') do Facter.add('rpool') do
confine :kernel => 'Linux' confine kernel: 'Linux'
setcode do setcode do
hostname = Facter.value('hostname') hostname = Facter.value('hostname')
if File.exist?('/sbin/zfs') if File.exist?('/sbin/zfs')
require 'English'
["#{hostname}/crypt", hostname].each do |name| ["#{hostname}/crypt", hostname].each do |name|
Facter::Core::Execution.execute("/sbin/zfs list #{name}") Facter::Core::Execution.execute("/sbin/zfs list #{name}")
break name if $? == 0 break name if $CHILD_STATUS == 0
end end
else else
hostname hostname
......
Facter.add('running_live') do Facter.add('running_live') do
confine :kernel => 'Linux' confine kernel: 'Linux'
setcode do setcode do
Facter.value(:mountpoints)['/']['device'] == 'LiveOS_rootfs' Facter.value(:mountpoints)['/']['device'] == 'LiveOS_rootfs'
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment