facter 4.0.26 → 4.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/actions/presuite.rb +1 -12
- data/.github/workflows/acceptance_tests.yml +4 -4
- data/.github/workflows/checks.yaml +9 -3
- data/.github/workflows/coverage.yaml +1 -1
- data/.github/workflows/unit_tests.yaml +2 -2
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +6 -4
- data/CHANGELOG.md +22 -0
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/acceptance/.beaker.yml +15 -0
- data/acceptance/.gitignore +12 -0
- data/acceptance/Gemfile +24 -0
- data/acceptance/Rakefile +2 -0
- data/acceptance/bin/ci-bootstrap-from-artifacts.sh +55 -0
- data/acceptance/config/aio/options.rb +6 -0
- data/acceptance/config/git/options.rb +3 -0
- data/acceptance/config/nodes/aix-53-power.yaml +7 -0
- data/acceptance/config/nodes/aix-61-power.yaml +7 -0
- data/acceptance/config/nodes/aix-71-power.yaml +7 -0
- data/acceptance/config/nodes/huaweios-6-powerpc.yaml +7 -0
- data/acceptance/config/nodes/solaris-10-sparc.yaml +9 -0
- data/acceptance/config/nodes/solaris-11-sparc.yaml +9 -0
- data/acceptance/lib/facter/acceptance/base_fact_utils.rb +565 -0
- data/acceptance/lib/facter/acceptance/user_fact_utils.rb +132 -0
- data/acceptance/lib/helper.rb +3 -0
- data/acceptance/lib/puppet/acceptance/common_utils.rb +10 -0
- data/acceptance/lib/puppet/acceptance/git_utils.rb +19 -0
- data/acceptance/lib/puppet/acceptance/install_utils.rb +58 -0
- data/acceptance/setup/aio/pre-suite/001_run_with_facter_ng.rb +75 -0
- data/acceptance/tests/custom_facts/cached_custom_fact.rb +82 -0
- data/acceptance/tests/custom_facts/conflicts_with_builtin_fact.rb +106 -0
- data/acceptance/tests/custom_facts/custom_fact_with_10001_weight_overrides_external_fact.rb +30 -0
- data/acceptance/tests/custom_facts/expand_command.rb +30 -0
- data/acceptance/tests/custom_facts/having_multiple_facts_in_one_file.rb +40 -0
- data/acceptance/tests/custom_facts/not_expand_command.rb +30 -0
- data/acceptance/tests/custom_facts/using_win32ole_should_not_hang.rb +33 -0
- data/acceptance/tests/custom_facts/weighted_cached_custom_facts.rb +94 -0
- data/acceptance/tests/custom_facts/windows_not_expand_command.rb +30 -0
- data/acceptance/tests/external_facts/env_var_overrides_external_fact.rb +46 -0
- data/acceptance/tests/external_facts/external_dir_overrides_default_external_fact.rb +34 -0
- data/acceptance/tests/external_facts/external_fact_overrides_custom_fact.rb +29 -0
- data/acceptance/tests/external_facts/external_fact_overrides_custom_fact_with_10000_weight_or_less.rb +30 -0
- data/acceptance/tests/external_facts/external_fact_overrides_custom_fact_with_confine.rb +35 -0
- data/acceptance/tests/external_facts/external_fact_stderr_messages_output_to_stderr.rb +49 -0
- data/acceptance/tests/external_facts/external_facts_only_run_once.rb +43 -0
- data/acceptance/tests/external_facts/fact_directory_precedence.rb +109 -0
- data/acceptance/tests/external_facts/handle_same_filename_in_different_dirs.rb +59 -0
- data/acceptance/tests/external_facts/non_root_users_default_external_fact_directory.rb +142 -0
- data/acceptance/tests/external_facts/root_uses_default_external_fact_dir.rb +34 -0
- data/acceptance/tests/external_facts/structured_executable_facts.rb +139 -0
- data/acceptance/tests/facter_returns_success_on_non_existent_fact.rb +9 -0
- data/acceptance/tests/facts/dmi.rb +51 -0
- data/acceptance/tests/facts/facterversion.rb +11 -0
- data/acceptance/tests/facts/identity.rb +52 -0
- data/acceptance/tests/facts/mountpoints_fact.rb +12 -0
- data/acceptance/tests/facts/networking_facts.rb +93 -0
- data/acceptance/tests/facts/nim_type.rb +12 -0
- data/acceptance/tests/facts/non_root_users_without_errors.rb +32 -0
- data/acceptance/tests/facts/operatingsystem_detection_after_clear_on_ubuntu.rb +26 -0
- data/acceptance/tests/facts/os_processors_and_kernel.rb +20 -0
- data/acceptance/tests/facts/osx_numeric_hostname.rb +23 -0
- data/acceptance/tests/facts/partitions.rb +37 -0
- data/acceptance/tests/facts/productname.rb +15 -0
- data/acceptance/tests/facts/ruby.rb +59 -0
- data/acceptance/tests/facts/ssh_key.rb +59 -0
- data/acceptance/tests/facts/validate_file_system_size_bytes.rb +37 -0
- data/acceptance/tests/facts/verify_tmpfs_file_system.rb +54 -0
- data/acceptance/tests/facts/windows_os.rb +64 -0
- data/acceptance/tests/load_libfacter.rb +66 -0
- data/acceptance/tests/no_errors_on_stderr.rb +10 -0
- data/acceptance/tests/options/color.rb +16 -0
- data/acceptance/tests/options/config.rb +27 -0
- data/acceptance/tests/options/config_file/blocklist.rb +35 -0
- data/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb +40 -0
- data/acceptance/tests/options/config_file/custom_dir_overridden_by_cli_custom_dir.rb +56 -0
- data/acceptance/tests/options/config_file/custom_facts.rb +42 -0
- data/acceptance/tests/options/config_file/custom_facts_list.rb +56 -0
- data/acceptance/tests/options/config_file/debug.rb +34 -0
- data/acceptance/tests/options/config_file/debug_override_config_file.rb +34 -0
- data/acceptance/tests/options/config_file/default_file_location.rb +37 -0
- data/acceptance/tests/options/config_file/external_dir_conflicts_with_cli_no_external_facts.rb +37 -0
- data/acceptance/tests/options/config_file/external_dir_overridden_by_cli_external_dir.rb +40 -0
- data/acceptance/tests/options/config_file/external_facts.rb +37 -0
- data/acceptance/tests/options/config_file/external_facts_list.rb +43 -0
- data/acceptance/tests/options/config_file/load_from_ruby.rb +73 -0
- data/acceptance/tests/options/config_file/log_level.rb +35 -0
- data/acceptance/tests/options/config_file/no_custom_facts_and_custom_dir.rb +43 -0
- data/acceptance/tests/options/config_file/no_custom_facts_and_facterlib.rb +43 -0
- data/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb +49 -0
- data/acceptance/tests/options/config_file/no_external_facts.rb +38 -0
- data/acceptance/tests/options/config_file/no_external_facts_and_external_dir.rb +34 -0
- data/acceptance/tests/options/config_file/no_ruby_disables_custom_facts.rb +52 -0
- data/acceptance/tests/options/config_file/no_ruby_disables_ruby_facts.rb +34 -0
- data/acceptance/tests/options/config_file/trace.rb +48 -0
- data/acceptance/tests/options/config_file/ttls_cached_external_execution_resolver_with_json_output.rb +92 -0
- data/acceptance/tests/options/config_file/ttls_cached_external_execution_resolver_with_text_output.rb +74 -0
- data/acceptance/tests/options/config_file/ttls_cached_external_execution_resolver_with_yaml_output.rb +88 -0
- data/acceptance/tests/options/config_file/ttls_cached_external_json_resolver.rb +79 -0
- data/acceptance/tests/options/config_file/ttls_cached_external_text_resolver.rb +78 -0
- data/acceptance/tests/options/config_file/ttls_cached_external_yaml_resolver.rb +78 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_clear_by_empty_ttls_cache_list.rb +71 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_creates_json_cache_file.rb +48 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_expire_facts_do_not_read_the_old_cached_value.rb +58 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_expire_facts_refresh_the_cached_value.rb +61 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_read_from_the_cached_value.rb +57 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_that_are_corrupt_are_refreshed.rb +53 -0
- data/acceptance/tests/options/config_file/ttls_cached_facts_that_are_empty_return_an_empty_value.rb +53 -0
- data/acceptance/tests/options/config_file/ttls_puppet_facts_creates_json_for_cached_facts.rb +45 -0
- data/acceptance/tests/options/config_file/ttls_puppet_facts_honors_cached_facts.rb +54 -0
- data/acceptance/tests/options/config_file/verbose.rb +34 -0
- data/acceptance/tests/options/custom_facts.rb +34 -0
- data/acceptance/tests/options/custom_facts_facterlib.rb +33 -0
- data/acceptance/tests/options/custom_facts_list.rb +48 -0
- data/acceptance/tests/options/custom_facts_load_path.rb +42 -0
- data/acceptance/tests/options/debug.rb +12 -0
- data/acceptance/tests/options/external_facts.rb +28 -0
- data/acceptance/tests/options/external_facts_list.rb +35 -0
- data/acceptance/tests/options/help.rb +13 -0
- data/acceptance/tests/options/json.rb +43 -0
- data/acceptance/tests/options/list_block_groups.rb +15 -0
- data/acceptance/tests/options/list_block_groups_facter_4.rb +15 -0
- data/acceptance/tests/options/list_cache_groups.rb +65 -0
- data/acceptance/tests/options/log_level.rb +13 -0
- data/acceptance/tests/options/no_block.rb +34 -0
- data/acceptance/tests/options/no_cache_should_not_cache_facts.rb +43 -0
- data/acceptance/tests/options/no_cache_should_not_load_cached_facts.rb +58 -0
- data/acceptance/tests/options/no_cache_should_not_refresh_cached_facts.rb +63 -0
- data/acceptance/tests/options/no_color.rb +16 -0
- data/acceptance/tests/options/no_custom_facts.rb +34 -0
- data/acceptance/tests/options/no_custom_facts_and_custom_dir.rb +19 -0
- data/acceptance/tests/options/no_custom_facts_and_facterlib.rb +34 -0
- data/acceptance/tests/options/no_custom_facts_and_load_path.rb +43 -0
- data/acceptance/tests/options/no_external_facts.rb +28 -0
- data/acceptance/tests/options/no_external_facts_and_external_dir.rb +19 -0
- data/acceptance/tests/options/no_ruby.rb +44 -0
- data/acceptance/tests/options/puppet_facts.rb +37 -0
- data/acceptance/tests/options/show_legacy.rb +18 -0
- data/acceptance/tests/options/strict.rb +11 -0
- data/acceptance/tests/options/trace.rb +36 -0
- data/acceptance/tests/options/verbose.rb +12 -0
- data/acceptance/tests/options/version.rb +12 -0
- data/acceptance/tests/options/yaml.rb +43 -0
- data/acceptance/tests/ticket_1123_facter_with_invalid_locale.rb +23 -0
- data/acceptance/tests/ticket_1238_hostname_fqdn.rb +57 -0
- data/lib/custom_facts/core/execution/base.rb +18 -18
- data/lib/custom_facts/util/collection.rb +2 -7
- data/lib/custom_facts/util/config.rb +1 -1
- data/lib/custom_facts/util/directory_loader.rb +51 -24
- data/lib/custom_facts/util/fact.rb +10 -1
- data/lib/custom_facts/util/resolution.rb +1 -1
- data/lib/facts/aix/aio_agent_version.rb +14 -0
- data/lib/facts/bsd/processors/count.rb +17 -0
- data/lib/facts/bsd/processors/models.rb +23 -0
- data/lib/facts/bsd/processors/speed.rb +17 -0
- data/lib/facts/freebsd/disks.rb +15 -0
- data/lib/facts/freebsd/partitions.rb +15 -0
- data/lib/facts/freebsd/processors/count.rb +17 -0
- data/lib/facts/freebsd/processors/models.rb +23 -0
- data/lib/facts/freebsd/processors/speed.rb +17 -0
- data/lib/facts/linux/aio_agent_version.rb +14 -0
- data/lib/facts/linux/ec2_metadata.rb +47 -0
- data/lib/facts/linux/ec2_userdata.rb +47 -0
- data/lib/facts/linux/is_virtual.rb +2 -5
- data/lib/facts/linux/virtual.rb +1 -5
- data/lib/facts/macosx/aio_agent_version.rb +14 -0
- data/lib/facts/macosx/interfaces.rb +2 -2
- data/lib/facts/macosx/networking/dhcp.rb +17 -0
- data/lib/facts/macosx/networking/interfaces.rb +21 -0
- data/lib/facts/macosx/networking/ip.rb +4 -1
- data/lib/facts/macosx/networking/ip6.rb +21 -0
- data/lib/facts/macosx/networking/mac.rb +4 -1
- data/lib/facts/macosx/networking/mtu.rb +20 -0
- data/lib/facts/macosx/networking/netmask.rb +21 -0
- data/lib/facts/macosx/networking/netmask6.rb +21 -0
- data/lib/facts/macosx/networking/network.rb +21 -0
- data/lib/facts/macosx/networking/network6.rb +21 -0
- data/lib/facts/macosx/networking/primary.rb +17 -0
- data/lib/facts/macosx/networking/scope6.rb +20 -0
- data/lib/facts/solaris/aio_agent_version.rb +14 -0
- data/lib/facts/windows/aio_agent_version.rb +14 -0
- data/lib/facts/windows/ec2_metadata.rb +23 -0
- data/lib/facts/windows/ec2_userdata.rb +23 -0
- data/lib/facts_utils/hypervisors.rb +10 -0
- data/lib/framework/core/cache_manager.rb +42 -18
- data/lib/framework/core/fact/external/external_fact_manager.rb +3 -2
- data/lib/framework/core/fact_loaders/external_fact_loader.rb +3 -2
- data/lib/framework/formatters/legacy_fact_formatter.rb +6 -5
- data/lib/framework/parsers/query_parser.rb +14 -2
- data/lib/models/loaded_fact.rb +3 -1
- data/lib/models/resolved_fact.rb +1 -1
- data/lib/models/searched_fact.rb +1 -0
- data/lib/resolvers/{agent_resolver.rb → aio_agent_version.rb} +4 -3
- data/lib/resolvers/bsd/ffi/ffi_helper.rb +31 -0
- data/lib/resolvers/bsd/processors.rb +47 -0
- data/lib/resolvers/ec2.rb +77 -0
- data/lib/resolvers/freebsd/ffi/ffi_helper.rb +42 -0
- data/lib/resolvers/freebsd/geom_resolver.rb +109 -0
- data/lib/resolvers/freebsd/processors.rb +44 -0
- data/lib/resolvers/macosx/networking.rb +110 -0
- data/lib/resolvers/networking_linux_resolver.rb +8 -30
- data/lib/resolvers/utils/networking.rb +70 -0
- data/lib/resolvers/windows/aio_agent_version.rb +56 -0
- metadata +175 -5
- data/lib/resolvers/macosx/ipaddress_resolver.rb +0 -52
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
test_name 'SSH publick key' do
|
|
2
|
+
confine :except, :platform => 'windows'
|
|
3
|
+
confine :except, :platform => /solaris/
|
|
4
|
+
|
|
5
|
+
agents.each do |agent|
|
|
6
|
+
ssh_host_rsa_key_file = '/etc/ssh/ssh_host_rsa_key.pub'
|
|
7
|
+
ssh_tmp_host_rsa_key_file = '/tmp/ssh_host_rsa_key.pub'
|
|
8
|
+
|
|
9
|
+
# The 'cp' might fail because the source file doesn't exist
|
|
10
|
+
on(
|
|
11
|
+
agent,
|
|
12
|
+
"cp -fv #{ssh_host_rsa_key_file} #{ssh_tmp_host_rsa_key_file}",
|
|
13
|
+
acceptable_exit_codes: [0, 1]
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
key = 'AAAAB3NzaC1yc2EAAAADAQABAAABAQDi8n9KzzF4tPIZsohBuyxFrLnkT5YbahpIjHvQZbQ9OwG3pOxTcQJjtS/gGMKJeRE2uaHaWb700rGlfGzhit7198FmjCeYdYLZvTH0q76mN9Ew1a8aesE46JMAmZijfehxzmlbyyQDamB0wSv3CbcpGccQ3cp/jBnnj54q9EJuEN+YU/uWVHK9IgNOAj9n7l7ZKKiDAFYlhg22sWIwX+8EyoAp+ewItLpO1BJe+NcnLzMoh71Qfb2Gm/yDPbKt/3N6CHp6JeHNbbPCL0hPkcbMdc/1+3ZuzM0yqt/Sq+6lz1tQBOeDp7UqZNT0t2I5bu0NNMphpBIAELpb4f6uuZ25'
|
|
17
|
+
rsa_pub_host_key_without_comment = 'ssh-rsa ' + key
|
|
18
|
+
rsa_pub_host_key_with_comment = rsa_pub_host_key_without_comment + ' root@ciprian.badescu-pf1s74sr\n'
|
|
19
|
+
|
|
20
|
+
teardown do
|
|
21
|
+
# Is it present?
|
|
22
|
+
rc = on(
|
|
23
|
+
agent,
|
|
24
|
+
"[ -e #{ssh_tmp_host_rsa_key_file} ]",
|
|
25
|
+
accept_all_exit_codes: true,
|
|
26
|
+
)
|
|
27
|
+
if rc.exit_code == 0
|
|
28
|
+
# It's present, so restore the original
|
|
29
|
+
on(
|
|
30
|
+
agent,
|
|
31
|
+
"mv -fv #{ssh_tmp_host_rsa_key_file} #{ssh_host_rsa_key_file}",
|
|
32
|
+
accept_all_exit_codes: true,
|
|
33
|
+
)
|
|
34
|
+
else
|
|
35
|
+
# It's missing, which means there wasn't one to backup; just
|
|
36
|
+
# delete the one we laid down
|
|
37
|
+
on(
|
|
38
|
+
agent,
|
|
39
|
+
"rm -fv #{ssh_host_rsa_key_file}",
|
|
40
|
+
accept_all_exit_codes: true,
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
step 'SSH publick key with comment is printed' do
|
|
46
|
+
on(agent, "echo '#{rsa_pub_host_key_with_comment}' > #{ssh_host_rsa_key_file}")
|
|
47
|
+
on(agent, facter('ssh.rsa.key')) do |facter_output|
|
|
48
|
+
assert_equal(key, facter_output.stdout.chomp, 'Expected debug to contain key only')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
step 'SSH publick key without comment is printed' do
|
|
53
|
+
on(agent, "echo '#{rsa_pub_host_key_without_comment}' > #{ssh_host_rsa_key_file}")
|
|
54
|
+
on(agent, facter('ssh.rsa.key')) do |facter_output|
|
|
55
|
+
assert_equal(key, facter_output.stdout.chomp, 'Expected debug to contain key only')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This test verifies that the numbers for file systems sizes are positive from "facter" and "puppet facts"
|
|
2
|
+
# This is a regression test for FACT-1578
|
|
3
|
+
test_name "C100110: verify that file system sizes are positive" do
|
|
4
|
+
tag 'risk:high'
|
|
5
|
+
|
|
6
|
+
confine :except, :platform => 'windows' # Windows does not list mount points as facts like Unix
|
|
7
|
+
|
|
8
|
+
require 'json'
|
|
9
|
+
|
|
10
|
+
agents.each do |agent|
|
|
11
|
+
step("verify that facter returns positive numbers for the mount points byte fields") do
|
|
12
|
+
|
|
13
|
+
on(agent, facter("--json")) do |facter_output|
|
|
14
|
+
facter_results = JSON.parse(facter_output.stdout)
|
|
15
|
+
facter_results['mountpoints'].each_key do |mount_key|
|
|
16
|
+
['available_bytes', 'size_bytes', 'used_bytes'].each do |sub_key|
|
|
17
|
+
assert_operator(facter_results['mountpoints'][mount_key][sub_key], :>=, 0,
|
|
18
|
+
"Expected the #{sub_key} from facter to be positive for #{mount_key}")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
step("verify that puppet facts returns positive numbers for the mount points byte fields") do
|
|
25
|
+
|
|
26
|
+
on(agent, puppet("facts --render-as json")) do |puppet_facts|
|
|
27
|
+
puppet_results = JSON.parse(puppet_facts.stdout)
|
|
28
|
+
puppet_results['values']['mountpoints'].each_key do |mount_key|
|
|
29
|
+
['available_bytes', 'size_bytes', 'used_bytes'].each do |sub_key|
|
|
30
|
+
assert_operator(puppet_results['values']['mountpoints'][mount_key][sub_key], :>=, 0,
|
|
31
|
+
"Expected the #{sub_key} from puppet facts to be positive for #{mount_key}")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# This test is intended to demonstrate that mount resource can mount tmpfs file systems
|
|
2
|
+
# and the mount facter mountpoints should show the mount as tmpfs
|
|
3
|
+
test_name 'C98163: mountpoints fact should show mounts on tmpfs' do
|
|
4
|
+
tag 'risk:high'
|
|
5
|
+
|
|
6
|
+
require 'facter/acceptance/user_fact_utils'
|
|
7
|
+
extend Facter::Acceptance::UserFactUtils
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
confine :except, :platform => 'windows'
|
|
11
|
+
confine :except, :platform => /osx/ # See PUP-4823
|
|
12
|
+
confine :except, :platform => /solaris/ # See PUP-5201
|
|
13
|
+
confine :except, :platform => /aix/ # See PUP-6845
|
|
14
|
+
confine :except, :platform => /^eos-/ # Mount provider not supported on Arista EOS switches
|
|
15
|
+
confine :except, :platform => /^cisco_/ # See PUP-5826
|
|
16
|
+
confine :except, :platform => /^huawei/ # See PUP-6126
|
|
17
|
+
|
|
18
|
+
agents.each do |agent|
|
|
19
|
+
mount_point = '/tmp/mountdir'
|
|
20
|
+
manifest_dir = agent.tmpdir('tmpfs')
|
|
21
|
+
manifest = File.join(manifest_dir, 'mount_manifest.pp')
|
|
22
|
+
manifest_content = <<-FILE
|
|
23
|
+
mount {"#{mount_point}":
|
|
24
|
+
ensure => mounted,
|
|
25
|
+
options => 'noexec',
|
|
26
|
+
fstype => 'tmpfs',
|
|
27
|
+
device => 'tmpfs',
|
|
28
|
+
atboot => true,
|
|
29
|
+
}
|
|
30
|
+
FILE
|
|
31
|
+
on(agent, "mkdir -p #{mount_point}")
|
|
32
|
+
create_remote_file(agent, manifest, manifest_content)
|
|
33
|
+
|
|
34
|
+
teardown do
|
|
35
|
+
on(agent, "umount #{mount_point}")
|
|
36
|
+
on(agent, "rm -rf #{mount_point} #{manifest_dir}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
step "Apply the manifest to mount directory '#{mount_point}'" do
|
|
40
|
+
on(agent, puppet("apply #{manifest}"), :acceptable_exit_codes => [0,2]) do |puppet_apply|
|
|
41
|
+
assert_no_match(/Error/, puppet_apply.stdout, 'Unexpected error on stdout was detected!')
|
|
42
|
+
assert_no_match(/ERROR/, puppet_apply.stderr, 'Unexpected error on stderr was detected!')
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
step 'verify tmpfs mount point seen by facter' do
|
|
47
|
+
on(agent, facter("mountpoints.#{mount_point}")) do |facter_output|
|
|
48
|
+
assert_match(/filesystem\s+=>\s+\"tmpfs\"/, facter_output.stdout, 'filesystem is the wrong type')
|
|
49
|
+
assert_match(/device\s+=>\s+\"tmpfs\"/, facter_output.stdout, 'device is not a tmpfs')
|
|
50
|
+
assert_match(/noexec/, facter_output.stdout, 'expected to see noexec option')
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
test_name "Test facter os reports correct os.windows.system32" do
|
|
2
|
+
|
|
3
|
+
# disable this test until changes in beaker
|
|
4
|
+
# https://tickets.puppetlabs.com/browse/BKR-1627
|
|
5
|
+
# will allow this test to run in timely manner
|
|
6
|
+
confine :to, :platform => /no-platform/
|
|
7
|
+
# confine :to, :platform => /windows/
|
|
8
|
+
# confine :except, :platform => /2008/
|
|
9
|
+
|
|
10
|
+
agents.each do |agent|
|
|
11
|
+
os_type = on(agent, powershell("facter os.windows.installation_type")).stdout.chomp
|
|
12
|
+
domain_firewall_state = on(agent, powershell("'(Get-NetFirewallProfile -Profile Domain).Enabled'")).stdout.chomp
|
|
13
|
+
public_firewall_state = on(agent, powershell("'(Get-NetFirewallProfile -Profile Public).Enabled'")).stdout.chomp
|
|
14
|
+
private_firewall_state = on(agent, powershell("'(Get-NetFirewallProfile -Profile Private).Enabled'")).stdout.chomp
|
|
15
|
+
on(agent, powershell("'Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False'"))
|
|
16
|
+
|
|
17
|
+
teardown do
|
|
18
|
+
if os_type == "Server" && on(agent, powershell("'Import-module servermanager ; (Get-WindowsFeature -name RDS-RD-Server).Installed'")).stdout.chomp == "True"
|
|
19
|
+
on(agent, powershell("'Import-module servermanager ; Remove-WindowsFeature –Name RDS-RD-Server'"))
|
|
20
|
+
agent.reboot
|
|
21
|
+
begin
|
|
22
|
+
agent.down?
|
|
23
|
+
rescue
|
|
24
|
+
#TODO: Handle restart pending
|
|
25
|
+
puts 'Assuming that restart was not caught'
|
|
26
|
+
end
|
|
27
|
+
agent.wait_for_port(3389)
|
|
28
|
+
agent.wait_for_port(22)
|
|
29
|
+
on(agent, powershell("Set-NetFirewallProfile -Profile Domain -Enabled #{domain_firewall_state}"))
|
|
30
|
+
on(agent, powershell("Set-NetFirewallProfile -Profile Public -Enabled #{public_firewall_state}"))
|
|
31
|
+
on(agent, powershell("Set-NetFirewallProfile -Profile Private -Enabled #{private_firewall_state}"))
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
step "Install Windows remote desktop feature" do
|
|
36
|
+
if os_type == "Server"
|
|
37
|
+
on(agent, powershell("facter os.windows.system32")) do |facter_before_output|
|
|
38
|
+
assert_equal("C:\\Windows\\system32", facter_before_output.stdout.chomp, 'Before windows feature installation, should be C:\\Windows\\system32')
|
|
39
|
+
end
|
|
40
|
+
on(agent, powershell("Add-WindowsFeature –Name RDS-RD-Server –IncludeAllSubFeature"))
|
|
41
|
+
on(agent, powershell("'Import-module servermanager ; (Get-WindowsFeature -name RDS-RD-Server).Installed'")) do |installed_feature|
|
|
42
|
+
assert_equal("True", installed_feature.stdout.chomp, 'Result should be true for installed RDS-RD-Server feature')
|
|
43
|
+
end
|
|
44
|
+
agent.reboot
|
|
45
|
+
#assert_equal(true, agent.down?, 'Cound install RDS-RD-Server, failed to bring the host down')
|
|
46
|
+
begin
|
|
47
|
+
agent.down?
|
|
48
|
+
rescue
|
|
49
|
+
#TODO: Handle restart pending
|
|
50
|
+
puts 'Assuming that restart was not caught'
|
|
51
|
+
end
|
|
52
|
+
agent.wait_for_port(3389)
|
|
53
|
+
agent.wait_for_port(22)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
step "Verify facter os reports correct system32 variable" do
|
|
58
|
+
on(agent, powershell("facter os.windows.system32")) do |facter_output|
|
|
59
|
+
assert_equal("C:\\Windows\\system32", facter_output.stdout.chomp, 'Result should be C:\\Windows\\system32')
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Verify that we can load the facter the way that mco does based on the platform
|
|
2
|
+
test_name 'C100161: Ruby can load libfacter without raising an error' do
|
|
3
|
+
tag 'risk:high'
|
|
4
|
+
|
|
5
|
+
require 'puppet/acceptance/common_utils'
|
|
6
|
+
extend Puppet::Acceptance::CommandUtils
|
|
7
|
+
|
|
8
|
+
def puppet_ruby_path_to_puppet_install_dir(puppet_ruby_path)
|
|
9
|
+
# find the "puppet" directory which should be the root of the install
|
|
10
|
+
puppet_dir = puppet_ruby_path
|
|
11
|
+
while File.basename(puppet_dir).downcase != 'puppet'
|
|
12
|
+
new_puppet_dir = File.dirname(puppet_dir)
|
|
13
|
+
if new_puppet_dir == puppet_dir
|
|
14
|
+
break
|
|
15
|
+
else
|
|
16
|
+
puppet_dir = new_puppet_dir
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
puppet_dir
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
agents.each do |agent|
|
|
23
|
+
# create a ruby program that will add a fact through Facter
|
|
24
|
+
fact_content = <<-EOM
|
|
25
|
+
require 'facter'
|
|
26
|
+
Facter.add('facter_loaded') do
|
|
27
|
+
setcode do
|
|
28
|
+
'FACTER_LOADED'
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# print a value so that we know that facter loaded and is working
|
|
33
|
+
puts Facter.value('facter_loaded')
|
|
34
|
+
exit 0
|
|
35
|
+
EOM
|
|
36
|
+
|
|
37
|
+
fact_dir = agent.tmpdir('mco_test')
|
|
38
|
+
fact_program = File.join(fact_dir, 'loading_facter.rb')
|
|
39
|
+
create_remote_file(agent, fact_program, fact_content)
|
|
40
|
+
|
|
41
|
+
teardown do
|
|
42
|
+
on(agent, "rm -rf '#{fact_dir}'")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if agent['platform'] =~ /windows/
|
|
46
|
+
# on Windows we have to figure out where facter.rb is so we can include the path
|
|
47
|
+
# figure out the root of the Puppet installation
|
|
48
|
+
puppet_ruby_path = on(agent, "env PATH=\"#{agent['privatebindir']}:${PATH}\" which ruby").stdout.chomp
|
|
49
|
+
cygwin_puppet_root = puppet_ruby_path_to_puppet_install_dir(puppet_ruby_path)
|
|
50
|
+
puppet_root = on(agent, "cygpath -w '#{cygwin_puppet_root}'").stdout.chomp
|
|
51
|
+
# on Windows mco uses -I to include the path to the facter.rb as its not in the
|
|
52
|
+
# default $LOAD_PATH for Puppets Ruby
|
|
53
|
+
include_facter_lib = "-I '#{puppet_root}/facter/lib'"
|
|
54
|
+
else
|
|
55
|
+
# On Unix systems facter.rb is already in the $LOAD_PATH for Puppets Ruby for mco
|
|
56
|
+
include_facter_lib = ''
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Run Puppet's ruby and load facter.rb
|
|
60
|
+
# if we fail to load the .jar or .so, ruby will raise an error for us to detect
|
|
61
|
+
on(agent, "#{ruby_command(agent)} #{include_facter_lib} #{fact_program}") do |ruby_result|
|
|
62
|
+
assert_equal('FACTER_LOADED', ruby_result.stdout.chomp, 'Expected the output to be only the value the added fact')
|
|
63
|
+
assert_empty(ruby_result.stderr, 'Expected libfacter to load without any output on stderr')
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
test_name 'C14514: Running facter should not output anything to stderr' do
|
|
2
|
+
tag 'risk:high'
|
|
3
|
+
|
|
4
|
+
agents.each do |agent|
|
|
5
|
+
on(agent, facter) do |facter_output|
|
|
6
|
+
assert_match(/hostname\s*=>\s*\S*/, facter_output.stdout, 'Hostname fact is missing')
|
|
7
|
+
assert_empty(facter_output.stderr, 'Facter should not have written to stderr')
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This test is intended to ensure with --debug and --color, facter sends escape sequences to colorize the output
|
|
2
|
+
test_name "C86545: --debug and --color command-line options should print DEBUG messages with color escape sequences" do
|
|
3
|
+
tag 'risk:high'
|
|
4
|
+
|
|
5
|
+
confine :except, :platform => 'windows' # On windows we don't get an escape sequence to detect to color change
|
|
6
|
+
|
|
7
|
+
agents.each do |agent|
|
|
8
|
+
step "Agent #{agent}: retrieve debug info from stderr using --debug and --color option" do
|
|
9
|
+
# set the TERM type to be a color xterm to help ensure we emit the escape sequence to change the color
|
|
10
|
+
on(agent, facter('--debug --color'), :environment => { 'TERM' => 'xterm-256color' }) do |facter_output|
|
|
11
|
+
assert_match(/DEBUG/, facter_output.stderr, "Expected DEBUG information in stderr")
|
|
12
|
+
assert_match(/\e\[0;/, facter_output.stderr, "Expected to see an escape sequence in the output")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# This test is intended to verify that the config file location can be specified
|
|
2
|
+
# via the `--config` flag on the command line.
|
|
3
|
+
test_name "C100014: --config command-line option designates the location of the config file" do
|
|
4
|
+
tag 'risk:high'
|
|
5
|
+
|
|
6
|
+
agents.each do |agent|
|
|
7
|
+
step "Agent #{agent}: create config file" do
|
|
8
|
+
config_dir = agent.tmpdir("config_dir")
|
|
9
|
+
config_file = File.join(config_dir, "facter.conf")
|
|
10
|
+
create_remote_file(agent, config_file, <<-FILE)
|
|
11
|
+
cli : {
|
|
12
|
+
debug : true
|
|
13
|
+
}
|
|
14
|
+
FILE
|
|
15
|
+
|
|
16
|
+
teardown do
|
|
17
|
+
on(agent, "rm -rf '#{config_dir}'", :acceptable_exit_codes => [0, 1])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
step "setting --config should cause the config file to be loaded from the specified location" do
|
|
21
|
+
on(agent, facter("--config '#{config_file}'")) do |facter_output|
|
|
22
|
+
assert_match(/DEBUG/, facter_output.stderr, "Expected debug output on stderr")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# This test verifies that when a fact group is blocked in the config file
|
|
2
|
+
# the corresponding facts do not resolve.
|
|
3
|
+
test_name "C99972: facts can be blocked via a blocklist in the config file" do
|
|
4
|
+
tag 'risk:high'
|
|
5
|
+
|
|
6
|
+
require 'facter/acceptance/user_fact_utils'
|
|
7
|
+
extend Facter::Acceptance::UserFactUtils
|
|
8
|
+
|
|
9
|
+
agents.each do |agent|
|
|
10
|
+
step "Agent #{agent}: create config file" do
|
|
11
|
+
custom_conf_dir = agent.tmpdir("config_dir")
|
|
12
|
+
config_file = File.join(custom_conf_dir, "facter.conf")
|
|
13
|
+
create_remote_file(agent, config_file, <<-FILE)
|
|
14
|
+
cli : { debug : true }
|
|
15
|
+
facts : { blocklist : [ "file system", "EC2" ] }
|
|
16
|
+
FILE
|
|
17
|
+
|
|
18
|
+
teardown do
|
|
19
|
+
on(agent, "rm -rf '#{custom_conf_dir}'", :acceptable_exit_codes => [0, 1])
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
step "blocked facts should not be resolved" do
|
|
23
|
+
on(agent, facter("--config '#{config_file}'")) do |facter_output|
|
|
24
|
+
# every platform attempts to resolve at least EC2 facts
|
|
25
|
+
assert_match(/blocking collection of .+ facts/, facter_output.stderr, "Expected stderr to contain statement about blocking fact collection")
|
|
26
|
+
|
|
27
|
+
# on some platforms, file system facts are never resolved, so this will also be true in those cases
|
|
28
|
+
assert_no_match(/filesystems/, facter_output.stdout, "filesystems fact should have been blocked")
|
|
29
|
+
assert_no_match(/mountpoints/, facter_output.stdout, "mountpoints fact should have been blocked")
|
|
30
|
+
assert_no_match(/partitions/, facter_output.stdout, "partitions fact should have been blocked")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# This test verifies that when a fact group is blocked in the config file the
|
|
2
|
+
# corresponding facts do not resolve when being run from the puppet facts command.
|
|
3
|
+
test_name "C100036: when run from puppet facts, facts can be blocked via a list in the config file" do
|
|
4
|
+
tag 'risk:medium'
|
|
5
|
+
|
|
6
|
+
require 'facter/acceptance/user_fact_utils'
|
|
7
|
+
extend Facter::Acceptance::UserFactUtils
|
|
8
|
+
|
|
9
|
+
agents.each do |agent|
|
|
10
|
+
step "facts should be blocked when Facter is run from Puppet with a configured blocklist" do
|
|
11
|
+
# default facter.conf
|
|
12
|
+
facter_conf_default_dir = get_default_fact_dir(agent['platform'], on(agent, facter('kernelmajversion')).stdout.chomp.to_f)
|
|
13
|
+
facter_conf_default_path = File.join(facter_conf_default_dir, "facter.conf")
|
|
14
|
+
|
|
15
|
+
teardown do
|
|
16
|
+
on(agent, "rm -rf '#{facter_conf_default_dir}'", :acceptable_exit_codes => [0, 1])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
step "Agent #{agent}: create default config file" do
|
|
20
|
+
# create the directories
|
|
21
|
+
on(agent, "mkdir -p '#{facter_conf_default_dir}'")
|
|
22
|
+
create_remote_file(agent, facter_conf_default_path, <<-FILE)
|
|
23
|
+
facts : { blocklist : [ "file system", "EC2" ] }
|
|
24
|
+
FILE
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
step "blocked facts should not be resolved" do
|
|
28
|
+
on(agent, puppet("facts --debug")) do |puppet_facts_output|
|
|
29
|
+
# every platform attempts to resolve at least EC2 facts
|
|
30
|
+
assert_match(/blocking collection of .+ facts/, puppet_facts_output.stdout, "Expected stderr to contain statement about blocking fact collection")
|
|
31
|
+
|
|
32
|
+
# on some platforms, file system facts are never resolved, so this will also be true in those cases
|
|
33
|
+
assert_no_match(/filesystems/, puppet_facts_output.stdout, "filesystems fact should have been blocked")
|
|
34
|
+
assert_no_match(/mountpoints/, puppet_facts_output.stdout, "mountpoints fact should have been blocked")
|
|
35
|
+
assert_no_match(/partitions/, puppet_facts_output.stdout, "partitions fact should have been blocked")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# This test verifies that the custom-dir specified in the configuration file can be overridden by using
|
|
2
|
+
# --custom-dir on the command line
|
|
3
|
+
test_name "C100015: config custom-dir overridden by command line --custom-dir" do
|
|
4
|
+
tag 'risk:medium'
|
|
5
|
+
|
|
6
|
+
require 'json'
|
|
7
|
+
require 'facter/acceptance/user_fact_utils'
|
|
8
|
+
extend Facter::Acceptance::UserFactUtils
|
|
9
|
+
|
|
10
|
+
config_fact_content = <<EOM
|
|
11
|
+
Facter.add('config_fact') do
|
|
12
|
+
setcode do
|
|
13
|
+
"config_value"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
EOM
|
|
17
|
+
|
|
18
|
+
cli_fact_content = <<EOM
|
|
19
|
+
Facter.add('cli_fact') do
|
|
20
|
+
setcode do
|
|
21
|
+
"cli_value"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
EOM
|
|
25
|
+
|
|
26
|
+
agents.each do |agent|
|
|
27
|
+
step "Agent #{agent}: create 2 custom fact directories with facts and a config file pointing at 1 directory" do
|
|
28
|
+
custom_config_dir = agent.tmpdir('custom_dir')
|
|
29
|
+
custom_cli_dir = agent.tmpdir('cli_custom_dir')
|
|
30
|
+
custom_config_fact = File.join(custom_config_dir, 'custom_fact.rb')
|
|
31
|
+
custom_cli_fact = File.join(custom_cli_dir, 'custom_fact.rb')
|
|
32
|
+
create_remote_file(agent, custom_config_fact, config_fact_content)
|
|
33
|
+
create_remote_file(agent, custom_cli_fact, cli_fact_content)
|
|
34
|
+
config_dir = agent.tmpdir("config_dir")
|
|
35
|
+
config_file = File.join(config_dir, "facter.conf")
|
|
36
|
+
config_content = <<EOM
|
|
37
|
+
global : {
|
|
38
|
+
custom-dir : "#{custom_config_dir}",
|
|
39
|
+
}
|
|
40
|
+
EOM
|
|
41
|
+
create_remote_file(agent, config_file, config_content)
|
|
42
|
+
|
|
43
|
+
teardown do
|
|
44
|
+
on(agent, "rm -rf '#{custom_config_dir}' '#{custom_cli_dir}' '#{config_dir}'")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
step "Agent #{agent}: resolve a fact from the command line custom-dir and not the config file" do
|
|
48
|
+
on(agent, facter("--config '#{config_file}' --custom-dir '#{custom_cli_dir}' --json")) do |facter_output|
|
|
49
|
+
results = JSON.parse(facter_output.stdout)
|
|
50
|
+
assert_equal("cli_value", results['cli_fact'], "Incorrect custom fact value for cli_fact")
|
|
51
|
+
assert_nil(results['config_fact'], "Config fact should not resolve and be nil")
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|