rouster 0.7 → 0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/README.md +7 -241
  4. data/Rakefile +18 -55
  5. data/Vagrantfile +8 -26
  6. data/lib/rouster.rb +183 -404
  7. data/lib/rouster/deltas.rb +118 -577
  8. data/lib/rouster/puppet.rb +34 -209
  9. data/lib/rouster/testing.rb +59 -366
  10. data/lib/rouster/tests.rb +19 -70
  11. data/path_helper.rb +7 -5
  12. data/rouster.gemspec +1 -3
  13. data/test/basic.rb +1 -4
  14. data/test/functional/deltas/test_get_groups.rb +2 -74
  15. data/test/functional/deltas/test_get_packages.rb +4 -86
  16. data/test/functional/deltas/test_get_ports.rb +1 -26
  17. data/test/functional/deltas/test_get_services.rb +4 -43
  18. data/test/functional/deltas/test_get_users.rb +2 -35
  19. data/test/functional/puppet/test_facter.rb +1 -41
  20. data/test/functional/puppet/test_get_puppet_star.rb +68 -0
  21. data/test/functional/test_caching.rb +1 -5
  22. data/test/functional/test_dirs.rb +0 -25
  23. data/test/functional/test_get.rb +6 -10
  24. data/test/functional/test_inspect.rb +1 -1
  25. data/test/functional/test_is_file.rb +1 -17
  26. data/test/functional/test_new.rb +22 -233
  27. data/test/functional/test_put.rb +11 -9
  28. data/test/functional/test_restart.rb +4 -1
  29. data/test/functional/test_run.rb +3 -2
  30. data/test/puppet/test_apply.rb +11 -13
  31. data/test/puppet/test_roles.rb +173 -0
  32. data/test/unit/test_new.rb +0 -88
  33. data/test/unit/test_parse_ls_string.rb +0 -67
  34. data/test/unit/testing/test_validate_file.rb +47 -39
  35. data/test/unit/testing/test_validate_package.rb +10 -36
  36. metadata +6 -46
  37. data/.reek +0 -63
  38. data/.travis.yml +0 -11
  39. data/Gemfile +0 -17
  40. data/Gemfile.lock +0 -102
  41. data/LICENSE +0 -9
  42. data/examples/aws.rb +0 -85
  43. data/examples/openstack.rb +0 -61
  44. data/examples/passthrough.rb +0 -71
  45. data/lib/rouster/vagrant.rb +0 -311
  46. data/plugins/aws.rb +0 -347
  47. data/plugins/openstack.rb +0 -136
  48. data/test/functional/deltas/test_get_crontab.rb +0 -161
  49. data/test/functional/deltas/test_get_os.rb +0 -68
  50. data/test/functional/test_is_in_file.rb +0 -40
  51. data/test/functional/test_passthroughs.rb +0 -94
  52. data/test/functional/test_validate_file.rb +0 -131
  53. data/test/unit/puppet/resources/puppet_run_with_failed_exec +0 -59
  54. data/test/unit/puppet/resources/puppet_run_with_successful_exec +0 -61
  55. data/test/unit/puppet/test_get_puppet_star.rb +0 -91
  56. data/test/unit/puppet/test_puppet_parsing.rb +0 -44
  57. data/test/unit/testing/resources/osx-launchd +0 -285
  58. data/test/unit/testing/resources/rhel-systemd +0 -46
  59. data/test/unit/testing/resources/rhel-systemv +0 -41
  60. data/test/unit/testing/resources/rhel-upstart +0 -20
  61. data/test/unit/testing/test_get_services.rb +0 -178
  62. data/test/unit/testing/test_validate_cron.rb +0 -78
  63. data/test/unit/testing/test_validate_port.rb +0 -103
@@ -1,46 +0,0 @@
1
- UNIT LOAD ACTIVE SUB DESCRIPTION
2
- crond.service loaded active running Command Scheduler
3
- dbus.service loaded active running D-Bus System Message Bus
4
- getty@tty1.service loaded active running Getty on tty1
5
- gssproxy.service loaded active running GSSAPI Proxy Daemon
6
- ● kdump.service loaded failed failed Crash recovery kernel arming
7
- kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current kernel
8
- lldpad.service loaded active running Link Layer Discovery Protocol Agent Daemon.
9
- mdmonitor.service loaded active running Software RAID monitoring and management
10
- network.service loaded active running LSB: Bring up/down networking
11
- nfs-config.service loaded active exited Preprocess NFS configuration
12
- ntpd.service loaded active running Network Time Service
13
- postfix.service loaded active running Postfix Mail Transport Agent
14
- rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
15
- rhel-import-state.service loaded active exited Import network configuration from initramfs
16
- rhel-readonly.service loaded active exited Configure read-only root support
17
- rsyslog.service loaded active running System Logging Service
18
- sshd.service loaded active running OpenSSH server daemon
19
- systemd-fsck-root.service loaded active exited File System Check on Root Device
20
- systemd-fsck@dev-disk-by\x2dlabel-boot.service loaded active exited File System Check on /dev/disk/by-label/boot
21
- systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
22
- systemd-journald.service loaded active running Journal Service
23
- systemd-logind.service loaded active running Login Service
24
- systemd-random-seed.service loaded active exited Load/Save Random Seed
25
- systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
26
- systemd-sysctl.service loaded active exited Apply Kernel Variables
27
- systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
28
- systemd-tmpfiles-setup.service loaded active exited Create Volatile Files and Directories
29
- systemd-udev-trigger.service loaded active exited udev Coldplug all Devices
30
- systemd-udevd.service loaded active running udev Kernel Device Manager
31
- systemd-update-utmp.service loaded active exited Update UTMP about System Boot/Shutdown
32
- systemd-user-sessions.service loaded active exited Permit User Sessions
33
- systemd-vconsole-setup.service loaded active exited Setup Virtual Console
34
- tuned.service loaded active running Dynamic System Tuning Daemon
35
- vboxadd-service.service loaded active running LSB: VirtualBox Additions service
36
- vboxadd-x11.service loaded active exited LSB: VirtualBox Linux Additions kernel modules
37
- vboxadd.service loaded active exited LSB: VirtualBox Linux Additions kernel modules
38
-
39
- LOAD = Reflects whether the unit definition was properly loaded.
40
- ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
41
- SUB = The low-level unit activation state, values depend on unit type.
42
-
43
- 36 loaded units listed. Pass --all to see loaded but inactive units, too.
44
- To show all installed unit files use 'systemctl list-unit-files'.
45
-
46
-
@@ -1,41 +0,0 @@
1
- acpid (pid 945) is running...
2
- atd (pid 1010) is running...
3
- auditd (pid 853) is running...
4
- Stopped
5
- cgred is stopped
6
- crond (pid 999) is running...
7
- ip6tables: Firewall is not running.
8
- iptables: Firewall is not running.
9
- Kdump is not operational
10
- mdmonitor is stopped
11
- netconsole module not loaded
12
- Configured devices:
13
- lo eth0
14
- Currently active devices:
15
- lo eth0
16
- rpc.svcgssd is stopped
17
- rpc.mountd is stopped
18
- nfsd is stopped
19
- rpc.statd (pid 905) is running...
20
- ntpd (pid 1587) is running...
21
- portreserve is stopped
22
- master is stopped
23
- puppet is stopped
24
- rdisc is stopped
25
- redis-server (pid 7295) is running...
26
- restorecond is stopped
27
- rhsmcertd (pid 1023) is running...
28
- rpcbind (pid 887) is running...
29
- rpc.gssd is stopped
30
- rpc.idmapd is stopped
31
- rpc.svcgssd is stopped
32
- rsyslogd (pid 869) is running...
33
- sandbox is stopped
34
- saslauthd is stopped
35
- sendmail (pid 981) is running...
36
- sm-client (pid 990) is running...
37
- snmpd (pid 1569) is running...
38
- snmptrapd is stopped
39
- openssh-daemon (pid 965) is running...
40
- svnserve is stopped
41
- tgtd is stopped
@@ -1,20 +0,0 @@
1
- rc stop/waiting
2
- tty (/dev/tty3) start/running, process 1601
3
- tty (/dev/tty2) start/running, process 1597
4
- tty (/dev/tty1) start/running, process 1595
5
- tty (/dev/tty6) start/running, process 1609
6
- tty (/dev/tty5) start/running, process 1607
7
- tty (/dev/tty4) start/running, process 1603
8
- plymouth-shutdown stop/waiting
9
- control-alt-delete stop/waiting
10
- rcS-emergency stop/waiting
11
- kexec-disable stop/waiting
12
- quit-plymouth stop/waiting
13
- rcS stop/waiting
14
- prefdm stop/waiting
15
- named start/running, process 8959
16
- init-system-dbus stop/waiting
17
- splash-manager stop/waiting
18
- start-ttys stop/waiting
19
- rcS-sulogin stop/waiting
20
- serial stop/waiting
@@ -1,178 +0,0 @@
1
- require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
-
3
- require 'rouster'
4
- require 'rouster/puppet'
5
- require 'rouster/testing'
6
- require 'test/unit'
7
-
8
- class TestUnitGetPackages < Test::Unit::TestCase
9
-
10
- def setup
11
- # expose private methods
12
- Rouster.send(:public, *Rouster.private_instance_methods)
13
- Rouster.send(:public, *Rouster.protected_instance_methods)
14
-
15
- @app = Rouster.new(:name => 'app', :unittest => true, :verbosity => 4)
16
-
17
- end
18
-
19
- def test_rhel_systemv
20
- @app.instance_variable_set(:@ostype, :rhel)
21
- services = {}
22
-
23
- raw = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemv', File.dirname(File.expand_path(__FILE__))))
24
-
25
- assert_nothing_raised do
26
- services = @app.get_services(false, true, :systemv, raw)
27
- end
28
-
29
- expected = {
30
- 'acpid' => 'running', # acpid (pid 945) is running...
31
- 'ip6tables' => 'stopped', # ip6tables: Firewall is not running.
32
- 'Kdump' => 'stopped', # Kdump is not operational
33
- 'mdmonitor' => 'stopped', # mdmonitor is stopped
34
- 'netconsole' => 'stopped', # netconsole module not loaded
35
- 'redis-server' => 'running' # redis-server (pid 11285) is running...
36
- }
37
-
38
- expected.each_pair do |service,state|
39
- assert(services.has_key?(service), "service[#{service}]")
40
- assert_equal(services[service], state, "service[#{service}] state[#{state}]")
41
- end
42
-
43
- end
44
-
45
- def test_rhel_systemd
46
- @app.instance_variable_set(:@ostype, :rhel)
47
- @app.instance_variable_set(:@osversion, '7')
48
- services = {}
49
-
50
- raw = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemd', File.dirname(File.expand_path(__FILE__))))
51
-
52
- assert_nothing_raised do
53
- services = @app.get_services(false, true, :systemd, raw)
54
- end
55
-
56
- expected = {
57
- 'kdump' => 'stopped', # ● kdump.service loaded failed failed Crash recovery kernel arming
58
- 'rhel-dmesg' => 'stopped', # rhel-dmesg.service loaded active exited Dump dmesg to /var/log/dmesg
59
- 'sshd' => 'running', # sshd.service loaded active running OpenSSH server daemon
60
- 'systemd-journal-flush'=> 'stopped', # this is a test for output without leading spaces
61
- }
62
-
63
- expected.each_pair do |service,state|
64
- assert(services.has_key?(service), "service[#{service}]")
65
- assert_equal(services[service], state, "service[#{service}] state[#{state}]")
66
- end
67
-
68
- end
69
-
70
- def test_rhel_upstart
71
- @app.instance_variable_set(:@ostype, :rhel)
72
- services = {}
73
-
74
- raw = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-upstart', File.dirname(File.expand_path(__FILE__))))
75
-
76
- assert_nothing_raised do
77
- services = @app.get_services(false, true, :upstart, raw)
78
- end
79
-
80
- expected = {
81
- 'rc' => 'stopped', # rc stop/waiting
82
- 'named' => 'running', # named start/running, process 8959
83
- 'tty' => 'running', # tty (/dev/tty3) start/running, process 1601
84
- }
85
-
86
- expected.each_pair do |service,state|
87
- assert(services.has_key?(service), "service[#{service}]")
88
- assert_equal(services[service], state, "service[#{service}] state[#{state}]")
89
- end
90
-
91
- end
92
-
93
- def test_rhel_both
94
- @app.instance_variable_set(:@ostype, :rhel)
95
- services = {}
96
-
97
- systemv_contents = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemv', File.dirname(File.expand_path(__FILE__))))
98
- upstart_contents = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-upstart', File.dirname(File.expand_path(__FILE__))))
99
-
100
- # TODO this isn't a great test, because the implementation will never have both outputs in the same control loop
101
- raw = systemv_contents
102
- raw << upstart_contents
103
-
104
- assert_nothing_raised do
105
- services = @app.get_services(false, true, :all, raw)
106
- end
107
-
108
- expected = {
109
- 'acpid' => 'running', # initd
110
- 'cgred' => 'stopped', # initd
111
- 'named' => 'running', # upstart
112
- # 'rc' => 'stopped', # upstart -- this is getting mishandled, see comment on line #74 and test_rhel_both_real for reasons this doesn't matter
113
- }
114
-
115
- expected.each_pair do |service,state|
116
- assert(services.has_key?(service), "service[#{service}]")
117
- assert_equal(services[service], state, "service[#{service}] state[#{state}]}")
118
- end
119
-
120
- end
121
-
122
- def test_rhel_both_real
123
- @app.instance_variable_set(:@ostype, :rhel)
124
- services = {}
125
-
126
- systemv_contents = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-systemv', File.dirname(File.expand_path(__FILE__))))
127
- upstart_contents = File.read(sprintf('%s/../../../test/unit/testing/resources/rhel-upstart', File.dirname(File.expand_path(__FILE__))))
128
-
129
- expected = {
130
- 'acpid' => 'running', # initd
131
- 'cgred' => 'stopped', # initd
132
- 'named' => 'running', # upstart
133
- 'rc' => 'stopped', # upstart
134
- }
135
-
136
- assert_nothing_raised do
137
- systemv = @app.get_services(false, true, :systemv, systemv_contents)
138
- upstart = @app.get_services(false, true, :upstart, upstart_contents)
139
-
140
- services = systemv.merge(upstart) # TODO how do we ensure merge order doesn't mislead us?
141
- end
142
-
143
- expected.each_pair do |service,state|
144
- assert(services.has_key?(service), "service[#{service}]")
145
- assert_equal(services[service], state, "service[#{service}] state[#{state}]}")
146
- end
147
-
148
-
149
- end
150
-
151
- def test_osx_launchd
152
- @app.instance_variable_set(:@ostype, :osx)
153
- services = {}
154
-
155
- raw = File.read(sprintf('%s/../../../test/unit/testing/resources/osx-launchd', File.dirname(File.expand_path(__FILE__))))
156
-
157
- assert_nothing_raised do
158
- services = @app.get_services(false, true, :launchd, raw)
159
- end
160
-
161
- expected = {
162
- 'com.bigfix.BESAgent' => 'running', # 100 - com.bigfix.BESAgent
163
- 'com.trendmicro.mpm.icore.agent' => 'stopped', # - 0 com.trendmicro.mpm.icore.agent
164
- }
165
-
166
- expected.each_pair do |service,state|
167
- assert(services.has_key?(service), "service[#{service}]")
168
- assert_equal(services[service], state, "service[#{service}] state[#{state}]")
169
- end
170
-
171
- end
172
-
173
- def teardown
174
- # noop
175
- end
176
-
177
- end
178
-
@@ -1,78 +0,0 @@
1
- require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
-
3
- require 'rouster'
4
- require 'rouster/puppet'
5
- require 'rouster/testing'
6
- require 'test/unit'
7
-
8
- class TestValidateCron < Test::Unit::TestCase
9
-
10
- def setup
11
- # expose private methods
12
- Rouster.send(:public, *Rouster.private_instance_methods)
13
- Rouster.send(:public, *Rouster.protected_instance_methods)
14
-
15
- fake_facts = { 'is_virtual' => 'true', 'timezone' => 'PDT', 'uptime_days' => 42 }
16
-
17
- fake_crons = {
18
- 'root' => {
19
- 'printf > /var/log/apache/error_log' => {
20
- :minute => 10,
21
- :hour => 2,
22
- :dom => '*',
23
- :mon => '*',
24
- :dow => '*'
25
- }
26
- },
27
- 'a_user' => {
28
- '/home/a_user/test.pl' => {
29
- :minute => '0',
30
- :hour => ['0', '6', '12', '18'],
31
- :dom => '*',
32
- :mon => '*',
33
- :dow => '*'
34
- }
35
- }, 'cronless_user' => {}
36
- }
37
-
38
- @app = Rouster.new(:name => 'app', :unittest => true)
39
- @app.deltas[:crontab] = fake_crons
40
- @app.facts = fake_facts
41
- end
42
-
43
- def test_positive_basic
44
-
45
- assert(@app.validate_cron('root', 'printf > /var/log/apache/error_log', { :minute => 10, :hour => 2, :dom => '*', :mon => '*', :dow => '*'}))
46
- assert(@app.validate_cron('a_user', '/home/a_user/test.pl', { :minute => '0', :hour => ['0', '6', '12', '18'], :dom => '*', :mon => '*', :dow => '*' }))
47
- assert(@app.validate_cron('root', 'chmod 1777 /tmp', { :ensure => 'absent' }))
48
- assert(@app.validate_cron('cronless_user', 'rm -f /tmp/foo', { :ensure => 'absent' }))
49
-
50
- end
51
-
52
- def test_positive_constrained
53
-
54
- assert(@app.validate_cron('root', 'printf > /var/log/apache/error_log', { :minute => 10 , :constrain => 'is_virtual true'} ))
55
-
56
- end
57
-
58
- def test_negative_basic
59
-
60
- assert_equal(false, @app.validate_cron('root', 'printf > /var/log/apache/error_log', { :minute => 1 }))
61
- assert_equal(false, @app.validate_cron('root', 'rm -rf /', { :minute => '*', :hour => '*', :dom => '*', :mon => '*', :dow => '*'}))
62
- assert_equal(false, @app.validate_cron('a_user', '/home/a_user/test.pl', { :ensure => 'absent' }))
63
- assert_equal(false, @app.validate_cron('root', '/home/a_user/test.pl', { :minute => '0', :hour => ['0', '6', '12', '18'], :dom => '*', :mon => '*', :dow => '*' }))
64
-
65
- end
66
-
67
- def test_negative_constrained
68
-
69
- assert(@app.validate_cron('root', 'printf > /var/log/apache/error_log', { :minute => 10, :constrain => 'is_virtual false' } ))
70
- assert(@app.validate_cron('root', 'printf > /var/log/apache/error_log', { :gid => 55, :constrain => 'is_virtual false' } ))
71
-
72
- end
73
-
74
- def teardown
75
- # noop
76
- end
77
-
78
- end
@@ -1,103 +0,0 @@
1
- require sprintf('%s/../../../path_helper', File.dirname(File.expand_path(__FILE__)))
2
-
3
- require 'rouster'
4
- require 'rouster/puppet'
5
- require 'rouster/testing'
6
- require 'test/unit'
7
-
8
- class TestValidatePort < Test::Unit::TestCase
9
-
10
- def setup
11
- # expose private methods
12
- Rouster.send(:public, *Rouster.private_instance_methods)
13
- Rouster.send(:public, *Rouster.protected_instance_methods)
14
-
15
- fake_facts = { 'is_virtual' => 'true', 'timezone' => 'PDT', 'uptime_days' => 42 }
16
-
17
- fake_ports = {
18
- 'tcp' => {
19
- '22' => {
20
- :address => {
21
- '0.0.0.0' => 'LISTEN',
22
- '::' => 'LISTEN'
23
- }
24
- },
25
- '25' => {
26
- :address => {
27
- '127.0.0.1' => 'LISTEN',
28
- '::1' => 'LISTEN'
29
- }
30
- },
31
- },
32
- 'udp' => {
33
- '161' => {
34
- :address => {
35
- '0.0.0.0' => 'you_might_not_get_it'
36
- }
37
- },
38
- }
39
- }
40
-
41
- @app = Rouster.new(:name => 'app', :unittest => true)
42
- @app.deltas[:ports] = fake_ports
43
- @app.facts = fake_facts
44
- end
45
-
46
- def test_positive_basic
47
-
48
- assert(@app.validate_port(22, { :state => 'active', :protocol => 'tcp', :address => '0.0.0.0' } ))
49
- assert(@app.validate_port(22, { :ensure => true } ))
50
- assert(@app.validate_port(22, { :proto => 'tcp' } ))
51
- assert(@app.validate_port(22, { :address => '0.0.0.0' } ))
52
-
53
- assert(@app.validate_port('22', { :ensure => true } ))
54
-
55
- assert(@app.validate_port(161, { :state => 'absent' } ))
56
- assert(@app.validate_port(161, { :protocol => 'udp', :address => '0.0.0.0' } ))
57
- assert(@app.validate_port(161, { :proto => 'udp', :state => 'this_will_always_return_true' } ))
58
-
59
- assert(@app.validate_port(1234, { :exists => false } ))
60
- assert(@app.validate_port(1234, { :exists => 'false' } ))
61
- assert(@app.validate_port(1234, { :ensure => false } ))
62
- assert(@app.validate_port(1234, { :ensure => 'absent' } ))
63
- assert(@app.validate_port(1234, { :state => 'open' } ))
64
-
65
- end
66
-
67
- def test_positive_constrained
68
-
69
- assert(@app.validate_port(22, { :state => 'connected', :constrain => 'is_virtual true' } ))
70
-
71
- end
72
-
73
- def test_negative_basic
74
-
75
- assert_equal(false, @app.validate_port(22, { :ensure => true, :address => '127.0.0.1' } ))
76
-
77
- assert_equal(false, @app.validate_port(22, { :ensure => true, :proto => 'udp' } ))
78
- assert_equal(false, @app.validate_port(22, { :ensure => true, :protocol => 'udp' } ))
79
-
80
- assert_equal(false, @app.validate_port(22, { :ensure => 'absent' } ))
81
- assert_equal(false, @app.validate_port(22, { :ensure => false } ))
82
- assert_equal(false, @app.validate_port(22, { :exists => 'absent' } ))
83
- assert_equal(false, @app.validate_port(22, { :exists => false } ))
84
-
85
- end
86
-
87
- def test_negative_constrained
88
-
89
- assert(@app.validate_port(22, { :ensure => false, :constrain => 'is_virtual false' } ))
90
- assert(@app.validate_port(22, { :ensure => true, :constrain => 'is_virtual false' } ))
91
-
92
- end
93
-
94
- def test_negative_port_dne
95
- assert_equal(false, @app.validate_port(4567, { :ensure => true, :address => '*' }))
96
- assert_equal(false, @app.validate_port(4567, { :ensure => true, :address => '127.0.0.1' }))
97
- end
98
-
99
- def teardown
100
- # noop
101
- end
102
-
103
- end