simp-cli 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +27 -0
- data/README.md +48 -0
- data/Rakefile +142 -0
- data/bin/simp +5 -0
- data/lib/simp/cli.rb +88 -0
- data/lib/simp/cli/commands/bootstrap.rb +275 -0
- data/lib/simp/cli/commands/check.rb +163 -0
- data/lib/simp/cli/commands/cleancerts.rb +114 -0
- data/lib/simp/cli/commands/config.rb +235 -0
- data/lib/simp/cli/commands/doc.rb +14 -0
- data/lib/simp/cli/commands/passgen.rb +128 -0
- data/lib/simp/cli/commands/puppeteval.rb +82 -0
- data/lib/simp/cli/commands/runpuppet.rb +95 -0
- data/lib/simp/cli/config/item.rb +456 -0
- data/lib/simp/cli/config/item/add_ldap_to_hiera.rb +43 -0
- data/lib/simp/cli/config/item/answers_yaml_file_writer.rb +58 -0
- data/lib/simp/cli/config/item/certificates.rb +39 -0
- data/lib/simp/cli/config/item/client_nets.rb +65 -0
- data/lib/simp/cli/config/item/common_runlevel_default.rb +32 -0
- data/lib/simp/cli/config/item/dns_search.rb +48 -0
- data/lib/simp/cli/config/item/dns_servers.rb +57 -0
- data/lib/simp/cli/config/item/failover_log_servers.rb +27 -0
- data/lib/simp/cli/config/item/gateway.rb +32 -0
- data/lib/simp/cli/config/item/grub_password.rb +51 -0
- data/lib/simp/cli/config/item/hostname.rb +24 -0
- data/lib/simp/cli/config/item/hostname_conf.rb +48 -0
- data/lib/simp/cli/config/item/ipaddress.rb +46 -0
- data/lib/simp/cli/config/item/is_master_yum_server.rb +23 -0
- data/lib/simp/cli/config/item/ldap_base_dn.rb +38 -0
- data/lib/simp/cli/config/item/ldap_bind_dn.rb +34 -0
- data/lib/simp/cli/config/item/ldap_bind_hash.rb +28 -0
- data/lib/simp/cli/config/item/ldap_bind_pw.rb +24 -0
- data/lib/simp/cli/config/item/ldap_master.rb +33 -0
- data/lib/simp/cli/config/item/ldap_root_dn.rb +42 -0
- data/lib/simp/cli/config/item/ldap_root_hash.rb +35 -0
- data/lib/simp/cli/config/item/ldap_sync_dn.rb +24 -0
- data/lib/simp/cli/config/item/ldap_sync_hash.rb +28 -0
- data/lib/simp/cli/config/item/ldap_sync_pw.rb +26 -0
- data/lib/simp/cli/config/item/ldap_uri.rb +43 -0
- data/lib/simp/cli/config/item/log_servers.rb +27 -0
- data/lib/simp/cli/config/item/netmask.rb +39 -0
- data/lib/simp/cli/config/item/network_conf.rb +63 -0
- data/lib/simp/cli/config/item/network_dhcp.rb +27 -0
- data/lib/simp/cli/config/item/network_interface.rb +41 -0
- data/lib/simp/cli/config/item/network_setup_nic.rb +28 -0
- data/lib/simp/cli/config/item/ntp_servers.rb +69 -0
- data/lib/simp/cli/config/item/puppet_autosign.rb +66 -0
- data/lib/simp/cli/config/item/puppet_ca.rb +31 -0
- data/lib/simp/cli/config/item/puppet_ca_port.rb +28 -0
- data/lib/simp/cli/config/item/puppet_conf.rb +98 -0
- data/lib/simp/cli/config/item/puppet_fileserver.rb +104 -0
- data/lib/simp/cli/config/item/puppet_hosts_entry.rb +44 -0
- data/lib/simp/cli/config/item/puppet_server.rb +30 -0
- data/lib/simp/cli/config/item/puppet_server_ip.rb +25 -0
- data/lib/simp/cli/config/item/puppetdb_port.rb +25 -0
- data/lib/simp/cli/config/item/puppetdb_server.rb +26 -0
- data/lib/simp/cli/config/item/remove_ldap_from_hiera.rb +47 -0
- data/lib/simp/cli/config/item/rename_fqdn_yaml.rb +40 -0
- data/lib/simp/cli/config/item/rsync_base.rb +37 -0
- data/lib/simp/cli/config/item/rsync_server.rb +44 -0
- data/lib/simp/cli/config/item/rsync_timeout.rb +26 -0
- data/lib/simp/cli/config/item/set_grub_password.rb +19 -0
- data/lib/simp/cli/config/item/simp_yum_servers.rb +30 -0
- data/lib/simp/cli/config/item/use_auditd.rb +19 -0
- data/lib/simp/cli/config/item/use_fips.rb +46 -0
- data/lib/simp/cli/config/item/use_iptables.rb +22 -0
- data/lib/simp/cli/config/item/use_ldap.rb +19 -0
- data/lib/simp/cli/config/item/use_selinux.rb +32 -0
- data/lib/simp/cli/config/item/yum_repositories.rb +75 -0
- data/lib/simp/cli/config/item_list_factory.rb +236 -0
- data/lib/simp/cli/config/questionnaire.rb +86 -0
- data/lib/simp/cli/config/utils.rb +128 -0
- data/lib/simp/cli/lib/utils.rb +114 -0
- data/lib/simp/simp.rb +77 -0
- data/spec/lib/simp/cli/commands/config_spec.rb +42 -0
- data/spec/lib/simp/cli/config/item/add_ldap_to_hiera_spec.rb +58 -0
- data/spec/lib/simp/cli/config/item/answers_yaml_file_writer_spec.rb +86 -0
- data/spec/lib/simp/cli/config/item/certificates_spec.rb +50 -0
- data/spec/lib/simp/cli/config/item/client_nets_spec.rb +66 -0
- data/spec/lib/simp/cli/config/item/common_runlevel_default_spec.rb +27 -0
- data/spec/lib/simp/cli/config/item/dns_search_spec.rb +74 -0
- data/spec/lib/simp/cli/config/item/dns_servers_spec.rb +76 -0
- data/spec/lib/simp/cli/config/item/failover_log_servers_spec.rb +49 -0
- data/spec/lib/simp/cli/config/item/files/FakeCA/cacertkey +1 -0
- data/spec/lib/simp/cli/config/item/files/FakeCA/gencerts_nopass.sh +10 -0
- data/spec/lib/simp/cli/config/item/files/autosign.conf.new +11 -0
- data/spec/lib/simp/cli/config/item/files/autosign.conf.used +15 -0
- data/spec/lib/simp/cli/config/item/files/fileserver.conf +41 -0
- data/spec/lib/simp/cli/config/item/files/hosts +2 -0
- data/spec/lib/simp/cli/config/item/files/hosts.old_puppet_entry +3 -0
- data/spec/lib/simp/cli/config/item/files/puppet.conf +25 -0
- data/spec/lib/simp/cli/config/item/files/puppet.your.domain.yaml +21 -0
- data/spec/lib/simp/cli/config/item/files/resolv.conf__multiple +10 -0
- data/spec/lib/simp/cli/config/item/files/resolv.conf__single +4 -0
- data/spec/lib/simp/cli/config/item/files/rsyncd.conf +225 -0
- data/spec/lib/simp/cli/config/item/gateway_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/grub_password_spec.rb +24 -0
- data/spec/lib/simp/cli/config/item/hostname_conf_spec.rb +27 -0
- data/spec/lib/simp/cli/config/item/hostname_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/ipaddress_spec.rb +40 -0
- data/spec/lib/simp/cli/config/item/is_master_yum_server_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/ldap_base_dn_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_bind_dn_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_bind_hash_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_bind_pw_spec.rb +21 -0
- data/spec/lib/simp/cli/config/item/ldap_master_spec.rb +37 -0
- data/spec/lib/simp/cli/config/item/ldap_root_dn_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_root_hash_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_sync_dn_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/ldap_sync_hash_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/ldap_sync_pw_spec.rb +21 -0
- data/spec/lib/simp/cli/config/item/ldap_uri_spec.rb +32 -0
- data/spec/lib/simp/cli/config/item/log_servers_spec.rb +49 -0
- data/spec/lib/simp/cli/config/item/netmask_spec.rb +28 -0
- data/spec/lib/simp/cli/config/item/network_conf_spec.rb +63 -0
- data/spec/lib/simp/cli/config/item/network_dhcp_spec.rb +11 -0
- data/spec/lib/simp/cli/config/item/network_interface_spec.rb +26 -0
- data/spec/lib/simp/cli/config/item/network_setup_nic_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/ntp_servers_spec.rb +43 -0
- data/spec/lib/simp/cli/config/item/puppet_autosign_spec.rb +55 -0
- data/spec/lib/simp/cli/config/item/puppet_ca_port_spec.rb +23 -0
- data/spec/lib/simp/cli/config/item/puppet_ca_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/puppet_conf_spec.rb +110 -0
- data/spec/lib/simp/cli/config/item/puppet_fileserver_spec.rb +53 -0
- data/spec/lib/simp/cli/config/item/puppet_hosts_entry_spec.rb +85 -0
- data/spec/lib/simp/cli/config/item/puppet_server_ip_spec.rb +24 -0
- data/spec/lib/simp/cli/config/item/puppet_server_spec.rb +22 -0
- data/spec/lib/simp/cli/config/item/puppetdb_port_spec.rb +25 -0
- data/spec/lib/simp/cli/config/item/puppetdb_server_spec.rb +25 -0
- data/spec/lib/simp/cli/config/item/remove_ldap_from_hiera_spec.rb +58 -0
- data/spec/lib/simp/cli/config/item/rename_fqdn_yaml_spec.rb +63 -0
- data/spec/lib/simp/cli/config/item/rsync_base_spec.rb +28 -0
- data/spec/lib/simp/cli/config/item/rsync_server_spec.rb +41 -0
- data/spec/lib/simp/cli/config/item/rsync_timeout_spec.rb +21 -0
- data/spec/lib/simp/cli/config/item/set_grub_password_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/simp_yum_servers_spec.rb +41 -0
- data/spec/lib/simp/cli/config/item/spec_helper.rb +22 -0
- data/spec/lib/simp/cli/config/item/use_auditd_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_fips_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_iptables_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_ldap_spec.rb +29 -0
- data/spec/lib/simp/cli/config/item/use_selinux_spec.rb +24 -0
- data/spec/lib/simp/cli/config/item/yum_repositories_spec.rb +94 -0
- data/spec/lib/simp/cli/config/item_spec.rb +106 -0
- data/spec/lib/simp/cli/config/spec_helper.rb +1 -0
- data/spec/lib/simp/cli/config/utils_spec.rb +131 -0
- data/spec/lib/simp/cli/spec_helper.rb +1 -0
- data/spec/spec_helper.rb +91 -0
- metadata +391 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'simp/cli/config/item/network_conf'
|
2
|
+
|
3
|
+
require 'simp/cli/config/item/network_interface'
|
4
|
+
require 'simp/cli/config/item/dns_search'
|
5
|
+
require 'simp/cli/config/item/dns_servers'
|
6
|
+
require 'simp/cli/config/item/gateway'
|
7
|
+
require 'simp/cli/config/item/hostname'
|
8
|
+
require 'simp/cli/config/item/ipaddress'
|
9
|
+
require 'simp/cli/config/item/netmask'
|
10
|
+
require 'simp/cli/config/item/network_dhcp'
|
11
|
+
|
12
|
+
require_relative( 'spec_helper' )
|
13
|
+
|
14
|
+
describe Simp::Cli::Config::Item::NetworkConf do
|
15
|
+
before :each do
|
16
|
+
@ci = Simp::Cli::Config::Item::NetworkConf.new
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# TODO: how to test this?
|
21
|
+
describe "#apply" do
|
22
|
+
it "will puppet apply a static network interface" do
|
23
|
+
@ci.config_items = init_config_items( {'dhcp' => 'static'} )
|
24
|
+
skip "FIXME: how shall we test NetworkConf#apply()?"
|
25
|
+
@ci.apply
|
26
|
+
end
|
27
|
+
|
28
|
+
it "will puppet apply a dhcp network interface" do
|
29
|
+
@ci.config_items = init_config_items( {'dhcp' => 'dhcp'} )
|
30
|
+
skip "FIXME: how shall we test NetworkConf#apply()?"
|
31
|
+
@ci.apply
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# helper method to create a number of previous answers
|
37
|
+
def init_config_items( extra_answers={} )
|
38
|
+
answers = {}
|
39
|
+
things = {
|
40
|
+
'NetworkInterface' => 'br1',
|
41
|
+
'DHCP' => 'static',
|
42
|
+
'Hostname' => 'scli.tasty.bacon',
|
43
|
+
'IPAddress' => '10.0.71.50',
|
44
|
+
'Netmask' => '255.255.255.0',
|
45
|
+
'Gateway' => '10.0.71.1',
|
46
|
+
'DNSServers' => ['10.0.71.7', '8.8.8.8'],
|
47
|
+
'DNSSearch' => 'tasty.bacon',
|
48
|
+
}
|
49
|
+
things.each do |name,value|
|
50
|
+
item = Simp::Cli::Config::Item.const_get(name).new
|
51
|
+
if extra_answers.keys.include? item.key
|
52
|
+
item.value = extra_answers.fetch( item.key )
|
53
|
+
else
|
54
|
+
item.value = value
|
55
|
+
end
|
56
|
+
answers[ item.key ] = item
|
57
|
+
end
|
58
|
+
answers
|
59
|
+
end
|
60
|
+
|
61
|
+
it_behaves_like "an Item that doesn't output YAML"
|
62
|
+
#it_behaves_like "a child of Simp::Cli::Config::Item"
|
63
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'simp/cli/config/item/network_dhcp'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::DHCP do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::DHCP.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
11
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'simp/cli/config/item/network_interface'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::NetworkInterface do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::NetworkInterface.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#initialize" do
|
11
|
+
subject{ @ci }
|
12
|
+
its(:key){ is_expected.to eq( 'network::interface') }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#validate" do
|
16
|
+
subject{ @ci }
|
17
|
+
it "doesn't validate nonsensical interfaces" do
|
18
|
+
expect( @ci.validate( 'lo' ) ).to eq false
|
19
|
+
expect( @ci.validate( '' ) ).to eq false
|
20
|
+
# assuming no one has a "nerbaderp" interface...
|
21
|
+
expect( @ci.validate( 'nerbaderp' ) ).to eq false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simp/cli/config/item/network_setup_nic'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::SetupNIC do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::SetupNIC.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates yes/no" do
|
12
|
+
expect( @ci.validate 'yes' ).to eq true
|
13
|
+
expect( @ci.validate 'y' ).to eq true
|
14
|
+
expect( @ci.validate 'Y' ).to eq true
|
15
|
+
expect( @ci.validate 'no' ).to eq true
|
16
|
+
expect( @ci.validate 'n' ).to eq true
|
17
|
+
expect( @ci.validate 'NO' ).to eq true
|
18
|
+
expect( @ci.validate true ).to eq true
|
19
|
+
expect( @ci.validate false ).to eq true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "doesn't validate other things" do
|
23
|
+
expect( @ci.validate 'ydd' ).to eq false
|
24
|
+
expect( @ci.validate 'gsdg' ).to eq false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'simp/cli/config/item/ntp_servers'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::NTPServers do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::NTPServers.new
|
8
|
+
@ci.silent = true
|
9
|
+
end
|
10
|
+
|
11
|
+
# describe "#recommended_value" do
|
12
|
+
# TODO: how to test this when os_value returns a valid value?
|
13
|
+
# it "recommends nil when gateway is unavailable" do
|
14
|
+
# expect( @ci.recommended_value ).to be_nil
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
|
18
|
+
describe "#validate" do
|
19
|
+
it "validates array with good hosts" do
|
20
|
+
expect( @ci.validate ['pool.ntp.org'] ).to eq true
|
21
|
+
expect( @ci.validate ['192.168.1.1'] ).to eq true
|
22
|
+
expect( @ci.validate ['192.168.1.1', 'pool.ntp.org'] ).to eq true
|
23
|
+
# NTP servers are optional, so nil is okay
|
24
|
+
expect( @ci.validate nil ).to eq true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "doesn't validate array with bad hosts" do
|
28
|
+
expect( @ci.validate 0 ).to eq false
|
29
|
+
expect( @ci.validate false ).to eq false
|
30
|
+
expect( @ci.validate [nil] ).to eq false
|
31
|
+
expect( @ci.validate ['pool.ntp.org.'] ).to eq false
|
32
|
+
expect( @ci.validate ['192.168.1.1.'] ).to eq false
|
33
|
+
expect( @ci.validate ['1.2.3.4/24'] ).to eq false
|
34
|
+
end
|
35
|
+
|
36
|
+
it "accepts an empty list" do
|
37
|
+
expect( @ci.validate [] ).to eq true
|
38
|
+
expect( @ci.validate "" ).to eq true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'simp/cli/config/item/puppet_autosign'
|
2
|
+
require 'simp/cli/config/item/hostname'
|
3
|
+
require 'rspec/its'
|
4
|
+
require_relative( 'spec_helper' )
|
5
|
+
|
6
|
+
describe Simp::Cli::Config::Item::PuppetAutosign do
|
7
|
+
before :each do
|
8
|
+
@file_dir = File.expand_path( 'files', File.dirname( __FILE__ ) )
|
9
|
+
tmp_dir = File.expand_path( 'tmp', File.dirname( __FILE__ ) )
|
10
|
+
@tmp_dir = Dir.mktmpdir(File.basename(__FILE__), tmp_dir )
|
11
|
+
@ci = Simp::Cli::Config::Item::PuppetAutosign.new
|
12
|
+
@ci.silent = true
|
13
|
+
|
14
|
+
# add hostname to ConfigItems
|
15
|
+
item = Simp::Cli::Config::Item::Hostname.new
|
16
|
+
item.value = 'puppet.domain.tld'
|
17
|
+
@ci.config_items[item.key] = item
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#apply" do
|
21
|
+
it 'persists an existing autosign.conf' do
|
22
|
+
# copy file from files to tmp
|
23
|
+
FileUtils.cp File.join( @file_dir, 'autosign.conf.used'), @tmp_dir
|
24
|
+
@ci.file = File.join( @tmp_dir, 'autosign.conf.used' )
|
25
|
+
@ci.apply
|
26
|
+
lines = File.readlines( @ci.file ).join( "\n" )
|
27
|
+
expect( lines ).to match(%r{^puppet.fake.domain\n\s*server1.fake.domain\n\s*server2.fake.domain$})
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'handles a newly-bootstrapped autosign.conf' do
|
31
|
+
# copy file from files to tmp
|
32
|
+
FileUtils.cp File.join( @file_dir, 'autosign.conf.new'), @tmp_dir
|
33
|
+
@ci.file = File.join( @tmp_dir, 'autosign.conf.new' )
|
34
|
+
@ci.apply
|
35
|
+
lines = File.readlines( @ci.file ).join( "\n" )
|
36
|
+
expect( lines ).to match(%r{^puppet.domain.tld$})
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'handles an empty autosign.conf' do
|
40
|
+
FileUtils.touch File.join( @tmp_dir, 'autosign.conf.empty' )
|
41
|
+
@ci.file = File.join( @tmp_dir, 'autosign.conf.empty' )
|
42
|
+
@ci.apply
|
43
|
+
lines = File.readlines( @ci.file ).join( "\n" )
|
44
|
+
expect( lines ).to match(%r{^puppet.domain.tld$})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
after :each do
|
49
|
+
FileUtils.remove_entry_secure @tmp_dir
|
50
|
+
end
|
51
|
+
|
52
|
+
it_behaves_like "an Item that doesn't output YAML"
|
53
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'simp/cli/config/item/puppet_ca_port'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::PuppetCAPort do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::PuppetCAPort.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates acceptable ca ports" do
|
12
|
+
expect( @ci.validate '8140' ).to eq true
|
13
|
+
expect( @ci.validate '8141' ).to eq true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "doesn't validate bad ca ports" do
|
17
|
+
expect( @ci.validate 'puppet' ).to eq false
|
18
|
+
expect( @ci.validate '70000' ).to eq false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'simp/cli/config/item/puppet_ca'
|
2
|
+
require 'rspec/its'
|
3
|
+
require_relative( 'spec_helper' )
|
4
|
+
|
5
|
+
describe Simp::Cli::Config::Item::PuppetCA do
|
6
|
+
before :each do
|
7
|
+
@ci = Simp::Cli::Config::Item::PuppetCA.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#validate" do
|
11
|
+
it "validates fqdns" do
|
12
|
+
expect( @ci.validate 'puppet' ).to eq true
|
13
|
+
expect( @ci.validate 'puppet.change.me' ).to eq true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "doesn't validate bad fqdns" do
|
17
|
+
expect( @ci.validate 'puppet-' ).to eq false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
22
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'simp/cli/config/item/puppet_conf'
|
2
|
+
require 'simp/cli/config/item/puppet_ca'
|
3
|
+
require 'simp/cli/config/item/puppet_ca_port'
|
4
|
+
require 'simp/cli/config/item/puppet_server'
|
5
|
+
|
6
|
+
require_relative( 'spec_helper' )
|
7
|
+
|
8
|
+
describe Simp::Cli::Config::Item::PuppetConf do
|
9
|
+
before :context do
|
10
|
+
@ci = Simp::Cli::Config::Item::PuppetConf.new
|
11
|
+
@puppet_server = 'puppet.nerd'
|
12
|
+
@puppet_ca = 'puppetca.nerd'
|
13
|
+
@puppet_ca_port = '9999'
|
14
|
+
@use_fips = true
|
15
|
+
|
16
|
+
previous_items = {}
|
17
|
+
s = Simp::Cli::Config::Item::PuppetServer.new
|
18
|
+
s.value = @puppet_server
|
19
|
+
previous_items[ s.key ] = s
|
20
|
+
s = Simp::Cli::Config::Item::PuppetCA.new
|
21
|
+
s.value = @puppet_ca
|
22
|
+
previous_items[ s.key ] = s
|
23
|
+
s = Simp::Cli::Config::Item::PuppetCAPort.new
|
24
|
+
s.value = @puppet_ca_port
|
25
|
+
previous_items[ s.key ] = s
|
26
|
+
s = Simp::Cli::Config::Item::UseFips.new
|
27
|
+
s.value = @use_fips
|
28
|
+
previous_items[ s.key ] = s
|
29
|
+
|
30
|
+
@ci.config_items = previous_items
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#apply" do
|
34
|
+
before :context do
|
35
|
+
@files_dir = File.expand_path( 'files', File.dirname( __FILE__ ) )
|
36
|
+
@tmp_dir = File.expand_path( 'tmp', File.dirname( __FILE__ ) )
|
37
|
+
@tmp_file = File.join( @tmp_dir, 'test__puppet.conf' )
|
38
|
+
@puppet_conf = File.join( @files_dir,'puppet.conf')
|
39
|
+
FileUtils.mkdir_p @tmp_dir
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when @skip_apply == true" do
|
43
|
+
before :context do
|
44
|
+
FileUtils.copy_file @puppet_conf, @tmp_file
|
45
|
+
@ci.file = @tmp_file
|
46
|
+
@ci.skip_apply = true
|
47
|
+
@ci.silent = true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "does not alter puppet.conf" do
|
51
|
+
@ci.apply
|
52
|
+
expect( IO.read(@tmp_file) ).to eq IO.read(@puppet_conf)
|
53
|
+
end
|
54
|
+
|
55
|
+
after :context do
|
56
|
+
FileUtils.rm @tmp_file
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "edits the puppet.conf file" do
|
61
|
+
before :context do
|
62
|
+
FileUtils.copy_file @puppet_conf, @tmp_file
|
63
|
+
@ci.file = @tmp_file
|
64
|
+
@ci.skip_apply = false
|
65
|
+
@ci.silent = true
|
66
|
+
@ci.apply
|
67
|
+
@lines = File.readlines( @tmp_file ).join( "\n" )
|
68
|
+
end
|
69
|
+
|
70
|
+
it "configures server" do
|
71
|
+
expect( @lines ).to match(%r{^\s*server\s*=\s#{@puppet_server}} )
|
72
|
+
end
|
73
|
+
|
74
|
+
it "configures ca_server" do
|
75
|
+
expect( @lines ).to match(%r{^\s*ca_server\s*=\s#{@puppetca_server}} )
|
76
|
+
end
|
77
|
+
|
78
|
+
it "configures ca_port" do
|
79
|
+
expect( @lines ).to match(%r{^\s*ca_port\s*=\s#{@puppetca_port}} )
|
80
|
+
end
|
81
|
+
|
82
|
+
it "configures environmentpath" do
|
83
|
+
expect( @lines ).to match(%r{^\s*environmentpath\s*=\s/etc/puppet/environments} )
|
84
|
+
end
|
85
|
+
|
86
|
+
it "configures stringify_facts" do
|
87
|
+
expect( @lines ).to match(%r{^\s*stringify_facts\s*=\sfalse} )
|
88
|
+
end
|
89
|
+
|
90
|
+
it "configures digest_algorithm" do
|
91
|
+
expect( @lines ).to match(%r{^\s*digest_algorithm\s*=\ssha256} )
|
92
|
+
end
|
93
|
+
|
94
|
+
it "configures trusted_node_data" do
|
95
|
+
expect( @lines ).to match(%r{^\s*trusted_node_data\s*=\strue} )
|
96
|
+
end
|
97
|
+
|
98
|
+
it "configures keylength" do
|
99
|
+
expect( @lines ).to match(%r{^\s*keylength\s*=\s2048} )
|
100
|
+
end
|
101
|
+
|
102
|
+
after :context do
|
103
|
+
FileUtils.rm @tmp_file
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it_behaves_like "an Item that doesn't output YAML"
|
109
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
110
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'simp/cli/config/item/puppet_fileserver'
|
2
|
+
|
3
|
+
require 'simp/cli/config/item/hostname'
|
4
|
+
|
5
|
+
require_relative( 'spec_helper' )
|
6
|
+
|
7
|
+
describe Simp::Cli::Config::Item::PuppetFileServer do
|
8
|
+
before :all do
|
9
|
+
@ci = Simp::Cli::Config::Item::PuppetFileServer.new
|
10
|
+
@files_dir = File.expand_path( 'files', File.dirname( __FILE__ ) )
|
11
|
+
@tmp_dir = File.expand_path( 'tmp', File.dirname( __FILE__ ) )
|
12
|
+
@tmp_file = File.join( @tmp_dir, 'test__fileserver.conf' )
|
13
|
+
@fileserver_conf = File.join( @files_dir,'fileserver.conf')
|
14
|
+
@ci.silent = true
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#apply" do
|
18
|
+
context "edits the fileserver.conf file" do
|
19
|
+
before :context do
|
20
|
+
@ci.file = @tmp_file
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with a valid hostname (fqdn)" do
|
24
|
+
before :context do
|
25
|
+
FileUtils.mkdir_p @tmp_dir
|
26
|
+
FileUtils.copy_file @fileserver_conf, @tmp_file
|
27
|
+
|
28
|
+
item = Simp::Cli::Config::Item::Hostname.new
|
29
|
+
item.value = "scli.tasty.bacon"
|
30
|
+
@ci.config_items = { 'hostname' => item }
|
31
|
+
|
32
|
+
@result = @ci.apply
|
33
|
+
end
|
34
|
+
|
35
|
+
it "configures server with correct domain" do
|
36
|
+
lines = File.readlines( @tmp_file ).join( "\n" )
|
37
|
+
expect( lines ).to match(%r{^\s*allow\s+\*.tasty.bacon} )
|
38
|
+
end
|
39
|
+
|
40
|
+
it "reports success" do
|
41
|
+
expect( @result ).to eq true
|
42
|
+
end
|
43
|
+
|
44
|
+
after :context do
|
45
|
+
FileUtils.rm @tmp_file
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it_behaves_like "an Item that doesn't output YAML"
|
52
|
+
it_behaves_like "a child of Simp::Cli::Config::Item"
|
53
|
+
end
|