This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
603 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
{ | ||
"EC2": [ | ||
"ec2_metadata", | ||
"ec2_userdata" | ||
], | ||
"GCE": [ | ||
"gce" | ||
], | ||
"augeas": [ | ||
"augeas", | ||
"augeasversion" | ||
], | ||
"desktop management interface": [ | ||
"dmi", | ||
"bios_vendor", | ||
"bios_version", | ||
"bios_release_date", | ||
"boardassettag", | ||
"boardmanufacturer", | ||
"boardproductname", | ||
"boardserialnumber", | ||
"chassisassettag", | ||
"manufacturer", | ||
"productname", | ||
"serialnumber", | ||
"uuid", | ||
"chassistype" | ||
], | ||
"file system": [ | ||
"mountpoints", | ||
"filesystems", | ||
"partitions" | ||
], | ||
"hypervisors": [ | ||
"hypervisors" | ||
], | ||
"id": [ | ||
"id", | ||
"gid", | ||
"identity" | ||
], | ||
"kernel": [ | ||
"kernel", | ||
"kernelversion", | ||
"kernelrelease", | ||
"kernelmajversion" | ||
], | ||
"load_average": [ | ||
"load_averages" | ||
], | ||
"memory": [ | ||
"memory", | ||
"memoryfree", | ||
"memoryfree_mb", | ||
"memorysize", | ||
"memorysize_mb", | ||
"swapfree", | ||
"swapfree_mb", | ||
"swapsize", | ||
"swapsize_mb", | ||
"swapencrypted" | ||
], | ||
"networking": [ | ||
"networking", | ||
"hostname", | ||
"ipaddress", | ||
"ipaddress6", | ||
"netmask", | ||
"netmask6", | ||
"network", | ||
"network6", | ||
"macaddress", | ||
"interfaces", | ||
"domain", | ||
"fqdn", | ||
"dhcp_servers" | ||
], | ||
"operating system": [ | ||
"os", | ||
"operatingsystem", | ||
"osfamily", | ||
"operatingsystemrelease", | ||
"operatingsystemmajrelease", | ||
"hardwaremodel", | ||
"architecture", | ||
"lsbdistid", | ||
"lsbdistrelease", | ||
"lsbdistcodename", | ||
"lsbdistdescription", | ||
"lsbmajdistrelease", | ||
"lsbminordistrelease", | ||
"lsbrelease", | ||
"macosx_buildversion", | ||
"macosx_productname", | ||
"macosx_productversion", | ||
"macosx_productversion_major", | ||
"macosx_productversion_minor", | ||
"windows_edition_id", | ||
"windows_installation_type", | ||
"windows_product_name", | ||
"windows_release_id", | ||
"system32", | ||
"selinux", | ||
"selinux_enforced", | ||
"selinux_policyversion", | ||
"selinux_current_mode", | ||
"selinux_config_mode", | ||
"selinux_config_policy" | ||
], | ||
"path": [ | ||
"path" | ||
], | ||
"processor": [ | ||
"processors", | ||
"processorcount", | ||
"physicalprocessorcount", | ||
"hardwareisa" | ||
], | ||
"ssh": [ | ||
"ssh", | ||
"sshdsakey", | ||
"sshrsakey", | ||
"sshecdsakey", | ||
"sshed25519key", | ||
"sshfp_dsa", | ||
"sshfp_rsa", | ||
"sshfp_ecdsa", | ||
"sshfp_ed25519" | ||
], | ||
"system profiler": [ | ||
"system_profiler", | ||
"sp_boot_mode", | ||
"sp_boot_rom_version", | ||
"sp_boot_volume", | ||
"sp_cpu_type", | ||
"sp_current_processor_speed", | ||
"sp_kernel_version", | ||
"sp_l2_cache_core", | ||
"sp_l3_cache", | ||
"sp_local_host_name", | ||
"sp_machine_model", | ||
"sp_machine_name", | ||
"sp_number_processors", | ||
"sp_os_version", | ||
"sp_packages", | ||
"sp_physical_memory", | ||
"sp_platform_uuid", | ||
"sp_secure_vm", | ||
"sp_serial_number", | ||
"sp_smc_version_system", | ||
"sp_uptime", | ||
"sp_user_name" | ||
], | ||
"timezone": [ | ||
"timezone" | ||
], | ||
"uptime": [ | ||
"system_uptime", | ||
"uptime", | ||
"uptime_days", | ||
"uptime_hours", | ||
"uptime_seconds" | ||
], | ||
"virtualization": [ | ||
"virtual", | ||
"is_virtual", | ||
"cloud" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facter | ||
class CacheList | ||
include Singleton | ||
|
||
attr_reader :cache_groups, :groups_ttls | ||
|
||
def initialize(block_list_path = nil) | ||
@block_groups_file_path = block_list_path || File.join(ROOT_DIR, 'fact_groups.conf') | ||
load_cache_groups | ||
end | ||
|
||
# Get the group name a fact is part of | ||
def get_fact_group(fact_name) | ||
@cache_groups.detect { |k, v| break k if Array(v).find { |f| fact_name =~ /^#{f}.*/ } } | ||
end | ||
|
||
# Get config ttls for a given group | ||
def get_group_ttls(group_name) | ||
return unless (ttls = @groups_ttls.find { |g| g[group_name] }) | ||
|
||
ttls_to_seconds(ttls[group_name]) | ||
end | ||
|
||
private | ||
|
||
def load_cache_groups | ||
groups = Facter::GroupList.instance.groups | ||
options = Options.instance | ||
@groups_ttls = ConfigReader.new(options[:config]).ttls || {} | ||
@cache_groups = groups.select { |g| @groups_ttls.find { |t| t[g] } } | ||
end | ||
|
||
def ttls_to_seconds(ttls) | ||
duration, unit = ttls.split(' ', 2) | ||
time = duration.to_i | ||
case unit | ||
when 'seconds' | ||
return time | ||
when 'minutes' | ||
return time * 60 | ||
when 'hours' | ||
return time * 60 * 60 | ||
when 'days' | ||
return time * 60 * 60 * 24 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Facter | ||
class GroupList | ||
include Singleton | ||
|
||
attr_reader :groups | ||
|
||
def initialize(group_list_path = nil) | ||
@groups_file_path = group_list_path || File.join(ROOT_DIR, 'fact_groups.conf') | ||
@groups ||= File.readable?(@groups_file_path) ? Hocon.load(@groups_file_path) : {} | ||
end | ||
end | ||
end |
Oops, something went wrong.