serverspec-cem-acpt 2.42.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +7 -0
  2. data/.github/stale.yml +18 -0
  3. data/.gitignore +28 -0
  4. data/.gitmodules +3 -0
  5. data/.travis.yml +25 -0
  6. data/Gemfile +9 -0
  7. data/Guardfile +4 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +36 -0
  10. data/Rakefile +31 -0
  11. data/WINDOWS_SUPPORT.md +131 -0
  12. data/appveyor.yml +70 -0
  13. data/bin/serverspec-init +7 -0
  14. data/lib/serverspec/commands/base.rb +7 -0
  15. data/lib/serverspec/helper/type.rb +25 -0
  16. data/lib/serverspec/helper.rb +8 -0
  17. data/lib/serverspec/matcher/be_enabled.rb +24 -0
  18. data/lib/serverspec/matcher/be_enforcing.rb +10 -0
  19. data/lib/serverspec/matcher/be_executable.rb +13 -0
  20. data/lib/serverspec/matcher/be_installed.rb +24 -0
  21. data/lib/serverspec/matcher/be_listening.rb +20 -0
  22. data/lib/serverspec/matcher/be_monitored_by.rb +17 -0
  23. data/lib/serverspec/matcher/be_mounted.rb +15 -0
  24. data/lib/serverspec/matcher/be_permissive.rb +10 -0
  25. data/lib/serverspec/matcher/be_reachable.rb +17 -0
  26. data/lib/serverspec/matcher/be_readable.rb +13 -0
  27. data/lib/serverspec/matcher/be_resolvable.rb +9 -0
  28. data/lib/serverspec/matcher/be_running.rb +19 -0
  29. data/lib/serverspec/matcher/be_writable.rb +13 -0
  30. data/lib/serverspec/matcher/belong_to_group.rb +5 -0
  31. data/lib/serverspec/matcher/belong_to_primary_group.rb +5 -0
  32. data/lib/serverspec/matcher/contain.rb +28 -0
  33. data/lib/serverspec/matcher/have_entry.rb +14 -0
  34. data/lib/serverspec/matcher/have_rule.rb +25 -0
  35. data/lib/serverspec/matcher/have_site_application.rb +18 -0
  36. data/lib/serverspec/matcher/have_site_bindings.rb +22 -0
  37. data/lib/serverspec/matcher/have_virtual_dir.rb +14 -0
  38. data/lib/serverspec/matcher.rb +40 -0
  39. data/lib/serverspec/power_assert.rb +14 -0
  40. data/lib/serverspec/setup.rb +351 -0
  41. data/lib/serverspec/subject.rb +12 -0
  42. data/lib/serverspec/type/base.rb +31 -0
  43. data/lib/serverspec/type/bond.rb +11 -0
  44. data/lib/serverspec/type/bridge.rb +11 -0
  45. data/lib/serverspec/type/cgroup.rb +17 -0
  46. data/lib/serverspec/type/command.rb +31 -0
  47. data/lib/serverspec/type/cron.rb +15 -0
  48. data/lib/serverspec/type/default_gateway.rb +15 -0
  49. data/lib/serverspec/type/docker_base.rb +27 -0
  50. data/lib/serverspec/type/docker_container.rb +27 -0
  51. data/lib/serverspec/type/docker_image.rb +4 -0
  52. data/lib/serverspec/type/file.rb +161 -0
  53. data/lib/serverspec/type/fstab.rb +11 -0
  54. data/lib/serverspec/type/group.rb +15 -0
  55. data/lib/serverspec/type/hadoop_config.rb +27 -0
  56. data/lib/serverspec/type/host.rb +21 -0
  57. data/lib/serverspec/type/iis_app_pool.rb +43 -0
  58. data/lib/serverspec/type/iis_website.rb +40 -0
  59. data/lib/serverspec/type/interface.rb +47 -0
  60. data/lib/serverspec/type/ip6tables.rb +13 -0
  61. data/lib/serverspec/type/ipfilter.rb +11 -0
  62. data/lib/serverspec/type/ipnat.rb +11 -0
  63. data/lib/serverspec/type/iptables.rb +11 -0
  64. data/lib/serverspec/type/json_file.rb +9 -0
  65. data/lib/serverspec/type/kernel_module.rb +7 -0
  66. data/lib/serverspec/type/kvm.rb +19 -0
  67. data/lib/serverspec/type/linux_audit_system.rb +45 -0
  68. data/lib/serverspec/type/linux_kernel_parameter.rb +10 -0
  69. data/lib/serverspec/type/lxc.rb +15 -0
  70. data/lib/serverspec/type/mail_alias.rb +7 -0
  71. data/lib/serverspec/type/mysql_config.rb +10 -0
  72. data/lib/serverspec/type/package.rb +66 -0
  73. data/lib/serverspec/type/php_config.rb +12 -0
  74. data/lib/serverspec/type/php_extension.rb +11 -0
  75. data/lib/serverspec/type/port.rb +40 -0
  76. data/lib/serverspec/type/ppa.rb +11 -0
  77. data/lib/serverspec/type/process.rb +31 -0
  78. data/lib/serverspec/type/routing_table.rb +11 -0
  79. data/lib/serverspec/type/selinux.rb +19 -0
  80. data/lib/serverspec/type/selinux_module.rb +15 -0
  81. data/lib/serverspec/type/service.rb +57 -0
  82. data/lib/serverspec/type/user.rb +47 -0
  83. data/lib/serverspec/type/windows_feature.rb +7 -0
  84. data/lib/serverspec/type/windows_firewall.rb +28 -0
  85. data/lib/serverspec/type/windows_hot_fix.rb +7 -0
  86. data/lib/serverspec/type/windows_registry_key.rb +19 -0
  87. data/lib/serverspec/type/windows_scheduled_task.rb +7 -0
  88. data/lib/serverspec/type/x509_certificate.rb +92 -0
  89. data/lib/serverspec/type/x509_private_key.rb +20 -0
  90. data/lib/serverspec/type/yumrepo.rb +11 -0
  91. data/lib/serverspec/type/zfs.rb +29 -0
  92. data/lib/serverspec/version.rb +3 -0
  93. data/lib/serverspec.rb +61 -0
  94. data/serverspec.gemspec +27 -0
  95. data/spec/helper/type_spec.rb +6 -0
  96. data/spec/spec_helper.rb +28 -0
  97. data/spec/type/aix/file_spec.rb +27 -0
  98. data/spec/type/aix/group_spec.rb +7 -0
  99. data/spec/type/aix/package_spec.rb +7 -0
  100. data/spec/type/aix/port_spec.rb +20 -0
  101. data/spec/type/aix/service_spec.rb +12 -0
  102. data/spec/type/aix/user_spec.rb +16 -0
  103. data/spec/type/arch/file_spec.rb +15 -0
  104. data/spec/type/arch/package_spec.rb +19 -0
  105. data/spec/type/arch/service_spec.rb +9 -0
  106. data/spec/type/base/command_spec.rb +106 -0
  107. data/spec/type/base/cron_spec.rb +11 -0
  108. data/spec/type/base/default_gateway_spec.rb +11 -0
  109. data/spec/type/base/file_spec.rb +418 -0
  110. data/spec/type/base/group_spec.rb +16 -0
  111. data/spec/type/base/host_spec.rb +47 -0
  112. data/spec/type/base/json_file_spec.rb +27 -0
  113. data/spec/type/base/mail_alias_spec.rb +7 -0
  114. data/spec/type/base/mysql_config_spec.rb +13 -0
  115. data/spec/type/base/package_spec.rb +51 -0
  116. data/spec/type/base/php_config_spec.rb +37 -0
  117. data/spec/type/base/php_extension_spec.rb +13 -0
  118. data/spec/type/base/port_spec.rb +34 -0
  119. data/spec/type/base/process_spec.rb +35 -0
  120. data/spec/type/base/routing_table_spec.rb +63 -0
  121. data/spec/type/base/service_spec.rb +54 -0
  122. data/spec/type/base/user_spec.rb +49 -0
  123. data/spec/type/darwin/file_spec.rb +41 -0
  124. data/spec/type/darwin/package_spec.rb +19 -0
  125. data/spec/type/darwin/port_spec.rb +27 -0
  126. data/spec/type/darwin/service_spec.rb +16 -0
  127. data/spec/type/debian/package_spec.rb +23 -0
  128. data/spec/type/debian/service_spec.rb +11 -0
  129. data/spec/type/fedora/service_spec.rb +15 -0
  130. data/spec/type/fedora15/service_spec.rb +15 -0
  131. data/spec/type/fedora20/service_spec.rb +15 -0
  132. data/spec/type/freebsd/file_spec.rb +29 -0
  133. data/spec/type/freebsd/package_spec.rb +19 -0
  134. data/spec/type/freebsd/port_spec.rb +27 -0
  135. data/spec/type/freebsd/service_spec.rb +8 -0
  136. data/spec/type/freebsd10/package_spec.rb +19 -0
  137. data/spec/type/gentoo/package_spec.rb +7 -0
  138. data/spec/type/gentoo/service_spec.rb +12 -0
  139. data/spec/type/linux/bond_spec.rb +12 -0
  140. data/spec/type/linux/bridge_spec.rb +12 -0
  141. data/spec/type/linux/cgroup_spec.rb +13 -0
  142. data/spec/type/linux/docker_container_pre_1_8_spec.rb +124 -0
  143. data/spec/type/linux/docker_container_spec.rb +131 -0
  144. data/spec/type/linux/docker_image_spec.rb +94 -0
  145. data/spec/type/linux/file_spec.rb +27 -0
  146. data/spec/type/linux/fstab_spec.rb +31 -0
  147. data/spec/type/linux/interface_spec.rb +50 -0
  148. data/spec/type/linux/ip6tables_spec.rb +19 -0
  149. data/spec/type/linux/iptables_spec.rb +11 -0
  150. data/spec/type/linux/kernel_module_spec.rb +7 -0
  151. data/spec/type/linux/kvm_guest_spec.rb +15 -0
  152. data/spec/type/linux/linux_audit_system_spec.rb +139 -0
  153. data/spec/type/linux/linux_kernel_parameter_spec.rb +33 -0
  154. data/spec/type/linux/lxc_container_spec.rb +12 -0
  155. data/spec/type/linux/selinux_module_spec.rb +15 -0
  156. data/spec/type/linux/selinux_spec.rb +23 -0
  157. data/spec/type/linux/x509_certificate_spec.rb +100 -0
  158. data/spec/type/linux/x509_private_key_spec.rb +31 -0
  159. data/spec/type/linux/zfs_spec.rb +15 -0
  160. data/spec/type/nixos/package_spec.rb +15 -0
  161. data/spec/type/nixos/service_spec.rb +9 -0
  162. data/spec/type/openbsd/file_spec.rb +134 -0
  163. data/spec/type/openbsd/interface_spec.rb +31 -0
  164. data/spec/type/openbsd/mail_alias_spec.rb +7 -0
  165. data/spec/type/openbsd/package_spec.rb +11 -0
  166. data/spec/type/openbsd/port_spec.rb +7 -0
  167. data/spec/type/openbsd/service_spec.rb +13 -0
  168. data/spec/type/openbsd/user_spec.rb +12 -0
  169. data/spec/type/opensuse/service_spec.rb +16 -0
  170. data/spec/type/plamo/package_spec.rb +8 -0
  171. data/spec/type/plamo/service_spec.rb +8 -0
  172. data/spec/type/redhat/file_spec.rb +19 -0
  173. data/spec/type/redhat/package_spec.rb +23 -0
  174. data/spec/type/redhat/service_spec.rb +11 -0
  175. data/spec/type/redhat/yumrepo_spec.rb +11 -0
  176. data/spec/type/redhat5/iptables_spec.rb +11 -0
  177. data/spec/type/redhat7/service_spec.rb +9 -0
  178. data/spec/type/smartos/package_spec.rb +19 -0
  179. data/spec/type/smartos/service_spec.rb +16 -0
  180. data/spec/type/solaris/cron_spec.rb +11 -0
  181. data/spec/type/solaris/file_spec.rb +15 -0
  182. data/spec/type/solaris/group_spec.rb +7 -0
  183. data/spec/type/solaris/host_spec.rb +19 -0
  184. data/spec/type/solaris/ipfilter_spec.rb +7 -0
  185. data/spec/type/solaris/ipnat_spec.rb +7 -0
  186. data/spec/type/solaris/package_spec.rb +7 -0
  187. data/spec/type/solaris/port_spec.rb +34 -0
  188. data/spec/type/solaris/service_spec.rb +16 -0
  189. data/spec/type/solaris/user_spec.rb +16 -0
  190. data/spec/type/solaris/zfs_spec.rb +15 -0
  191. data/spec/type/solaris10/file_spec.rb +313 -0
  192. data/spec/type/solaris10/group_spec.rb +8 -0
  193. data/spec/type/solaris10/host_spec.rb +16 -0
  194. data/spec/type/solaris10/package_spec.rb +8 -0
  195. data/spec/type/solaris10/user_spec.rb +8 -0
  196. data/spec/type/suse/package_spec.rb +23 -0
  197. data/spec/type/suse/service_spec.rb +11 -0
  198. data/spec/type/ubuntu/ppa_spec.rb +11 -0
  199. data/spec/type/ubuntu/service_spec.rb +7 -0
  200. data/spec/type/windows/command_spec.rb +64 -0
  201. data/spec/type/windows/feature_spec.rb +17 -0
  202. data/spec/type/windows/file_spec.rb +127 -0
  203. data/spec/type/windows/group_spec.rb +23 -0
  204. data/spec/type/windows/host_spec.rb +32 -0
  205. data/spec/type/windows/hot_fix_spec.rb +22 -0
  206. data/spec/type/windows/iis_app_pool_spec.rb +17 -0
  207. data/spec/type/windows/iis_webisite_spec.rb +16 -0
  208. data/spec/type/windows/package_spec.rb +10 -0
  209. data/spec/type/windows/port_spec.rb +25 -0
  210. data/spec/type/windows/registry_key_spec.rb +58 -0
  211. data/spec/type/windows/scheduled_task_spec.rb +9 -0
  212. data/spec/type/windows/service_spec.rb +30 -0
  213. data/spec/type/windows/user_spec.rb +33 -0
  214. data/wercker.yml +13 -0
  215. metadata +446 -0
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'freebsd'
4
+
5
+ describe port(80) do
6
+ it { should be_listening }
7
+ end
8
+
9
+ describe port(80) do
10
+ it { should be_listening.with('tcp') }
11
+ end
12
+
13
+ describe port(80) do
14
+ it do
15
+ expect {
16
+ should be_listening.with('not implemented')
17
+ }.to raise_error(ArgumentError, %r/\A`be_listening` matcher doesn\'t support/)
18
+ end
19
+ end
20
+
21
+ describe port(80) do
22
+ it { should be_listening.on('127.0.0.1') }
23
+ end
24
+
25
+ describe port(53) do
26
+ it { should be_listening.with('udp') }
27
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'freebsd'
4
+
5
+ describe service('sshd') do
6
+ it { should be_enabled }
7
+ end
8
+
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'freebsd', :release => 10
4
+
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ end
8
+
9
+ describe package('httpd') do
10
+ it { should be_installed.with_version('2.2.15-28.el6') }
11
+ end
12
+
13
+ describe package('httpd') do
14
+ let(:stdout) { "2.2.15\n" }
15
+ its(:version) { should eq '2.2.15' }
16
+ its(:version) { should > '2.2.14' }
17
+ its(:version) { should < '2.2.16' }
18
+ its(:version) { should > '2.2.9' }
19
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'gentoo'
4
+
5
+ describe package('httpd') do
6
+ it { should be_installed }
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'gentoo'
4
+
5
+ describe service('sshd') do
6
+ it { should be_enabled }
7
+ end
8
+
9
+ describe service('sshd') do
10
+ it { should be_running }
11
+ end
12
+
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe bond('bond0') do
6
+ it { should exist }
7
+ end
8
+
9
+ describe bond('bond0') do
10
+ let(:stdout) { 'eth0' }
11
+ it { should have_interface 'eth0' }
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe bridge('br0') do
6
+ it { should exist }
7
+ end
8
+
9
+ describe bridge('br0') do
10
+ let(:stdout) { 'eth0' }
11
+ it { should have_interface 'eth0' }
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe cgroup('group1') do
6
+ let(:stdout) { "1\r\n" }
7
+ its('cpuset.cpus') { should eq 1 }
8
+ end
9
+
10
+ describe cgroup('group1') do
11
+ let(:stdout) { "1\r\n" }
12
+ its('cpuset.cpus') { should_not eq 0 }
13
+ end
@@ -0,0 +1,124 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require 'json'
4
+
5
+ property[:os] = nil
6
+ set :os, {:family => 'linux'}
7
+
8
+ describe docker_container('c1') do
9
+ it { should exist }
10
+ end
11
+
12
+ describe docker_container('c1 pre 1.8') do
13
+ let(:stdout) { inspect_container }
14
+ it { should be_running }
15
+ it { should have_volume('/tmp', '/data') }
16
+ it { should_not have_volume('/tmp', '/data-bad') }
17
+ its(:inspection) { should include 'Driver' => 'aufs' }
18
+ its(['Config.Cmd']) { should include '/bin/sh' }
19
+ its(['HostConfig.PortBindings.80.[0].HostPort']) { should eq '8080' }
20
+ end
21
+
22
+ describe docker_container('restarting pre 1.8') do
23
+ let(:stdout) do
24
+ attrs = JSON.parse(inspect_container)
25
+ attrs.first['State']['Restarting'] = true
26
+ attrs.to_json
27
+ end
28
+
29
+ it { should_not be_running }
30
+ end
31
+
32
+ def inspect_container
33
+ <<'EOS'
34
+ [{
35
+ "Args": [],
36
+ "Config": {
37
+ "AttachStderr": false,
38
+ "AttachStdin": false,
39
+ "AttachStdout": false,
40
+ "Cmd": [
41
+ "/bin/sh"
42
+ ],
43
+ "CpuShares": 0,
44
+ "Cpuset": "",
45
+ "Domainname": "",
46
+ "Entrypoint": null,
47
+ "Env": [
48
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
49
+ ],
50
+ "ExposedPorts": null,
51
+ "Hostname": "65cd2e2d7963",
52
+ "Image": "busybox",
53
+ "Memory": 0,
54
+ "MemorySwap": 0,
55
+ "NetworkDisabled": false,
56
+ "OnBuild": null,
57
+ "OpenStdin": true,
58
+ "PortSpecs": null,
59
+ "StdinOnce": false,
60
+ "Tty": true,
61
+ "User": "",
62
+ "Volumes": null,
63
+ "WorkingDir": ""
64
+ },
65
+ "Created": "2014-09-26T15:08:37.527931773Z",
66
+ "Driver": "aufs",
67
+ "ExecDriver": "native-0.2",
68
+ "HostConfig": {
69
+ "Binds": [
70
+ "/data:/tmp"
71
+ ],
72
+ "ContainerIDFile": "",
73
+ "Dns": null,
74
+ "DnsSearch": null,
75
+ "Links": null,
76
+ "LxcConf": [],
77
+ "NetworkMode": "bridge",
78
+ "PortBindings": {
79
+ "80": [
80
+ {
81
+ "HostIp": "",
82
+ "HostPort": "8080"
83
+ }
84
+ ]
85
+ },
86
+ "Privileged": false,
87
+ "PublishAllPorts": false,
88
+ "VolumesFrom": null
89
+ },
90
+ "HostnamePath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hostname",
91
+ "HostsPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hosts",
92
+ "Id": "65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545",
93
+ "Image": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287",
94
+ "MountLabel": "",
95
+ "Name": "/c1",
96
+ "NetworkSettings": {
97
+ "Bridge": "docker0",
98
+ "Gateway": "172.17.42.1",
99
+ "IPAddress": "172.17.0.24",
100
+ "IPPrefixLen": 16,
101
+ "PortMapping": null,
102
+ "Ports": {}
103
+ },
104
+ "Path": "/bin/sh",
105
+ "ProcessLabel": "",
106
+ "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/resolv.conf",
107
+ "State": {
108
+ "ExitCode": 0,
109
+ "FinishedAt": "0001-01-01T00:00:00Z",
110
+ "Paused": false,
111
+ "Pid": 4123,
112
+ "Running": true,
113
+ "StartedAt": "2014-09-26T15:08:37.737780273Z"
114
+ },
115
+ "Volumes": {
116
+ "/tmp": "/data"
117
+ },
118
+ "VolumesRW": {
119
+ "/tmp": true
120
+ }
121
+ }
122
+ ]
123
+ EOS
124
+ end
@@ -0,0 +1,131 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require 'multi_json'
4
+
5
+ property[:os] = nil
6
+ set :os, {:family => 'linux'}
7
+
8
+ describe docker_container('c1') do
9
+ it { should exist }
10
+ end
11
+
12
+ describe docker_container('c1') do
13
+ let(:stdout) { inspect_container }
14
+ it { should be_running }
15
+ it { should have_volume('/tmp', '/data') }
16
+ it { should_not have_volume('/tmp', '/data-bad') }
17
+ its(:inspection) { should include 'Driver' => 'aufs' }
18
+ its(['Config.Cmd']) { should include '/bin/sh' }
19
+ its(['HostConfig.PortBindings.80.[0].HostPort']) { should eq '8080' }
20
+ its(['HostConfig.PortBindings.80.[1].HostPort']) { should eq '8081' }
21
+ end
22
+
23
+ describe docker_container('restarting') do
24
+ let(:stdout) do
25
+ attrs = MultiJson.load(inspect_container)
26
+ attrs.first['State']['Restarting'] = true
27
+ attrs.to_json
28
+ end
29
+
30
+ it { should_not be_running }
31
+ end
32
+
33
+ def inspect_container
34
+ <<'EOS'
35
+ [{
36
+ "Args": [],
37
+ "Config": {
38
+ "AttachStderr": false,
39
+ "AttachStdin": false,
40
+ "AttachStdout": false,
41
+ "Cmd": [
42
+ "/bin/sh"
43
+ ],
44
+ "CpuShares": 0,
45
+ "Cpuset": "",
46
+ "Domainname": "",
47
+ "Entrypoint": null,
48
+ "Env": [
49
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
50
+ ],
51
+ "ExposedPorts": null,
52
+ "Hostname": "65cd2e2d7963",
53
+ "Image": "busybox",
54
+ "Memory": 0,
55
+ "MemorySwap": 0,
56
+ "NetworkDisabled": false,
57
+ "OnBuild": null,
58
+ "OpenStdin": true,
59
+ "PortSpecs": null,
60
+ "StdinOnce": false,
61
+ "Tty": true,
62
+ "User": "",
63
+ "Volumes": null,
64
+ "WorkingDir": ""
65
+ },
66
+ "Created": "2014-09-26T15:08:37.527931773Z",
67
+ "Driver": "aufs",
68
+ "ExecDriver": "native-0.2",
69
+ "HostConfig": {
70
+ "Binds": [
71
+ "/data:/tmp"
72
+ ],
73
+ "ContainerIDFile": "",
74
+ "Dns": null,
75
+ "DnsSearch": null,
76
+ "Links": null,
77
+ "LxcConf": [],
78
+ "NetworkMode": "bridge",
79
+ "PortBindings": {
80
+ "80": [
81
+ {
82
+ "HostIp": "",
83
+ "HostPort": "8080"
84
+ },
85
+ {
86
+ "HostIp": "",
87
+ "HostPort": "8081"
88
+ }
89
+ ]
90
+ },
91
+ "Privileged": false,
92
+ "PublishAllPorts": false,
93
+ "VolumesFrom": null
94
+ },
95
+ "HostnamePath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hostname",
96
+ "HostsPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hosts",
97
+ "Id": "65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545",
98
+ "Image": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287",
99
+ "MountLabel": "",
100
+ "Name": "/c1",
101
+ "NetworkSettings": {
102
+ "Bridge": "docker0",
103
+ "Gateway": "172.17.42.1",
104
+ "IPAddress": "172.17.0.24",
105
+ "IPPrefixLen": 16,
106
+ "PortMapping": null,
107
+ "Ports": {}
108
+ },
109
+ "Path": "/bin/sh",
110
+ "ProcessLabel": "",
111
+ "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/resolv.conf",
112
+ "State": {
113
+ "ExitCode": 0,
114
+ "FinishedAt": "0001-01-01T00:00:00Z",
115
+ "Paused": false,
116
+ "Pid": 4123,
117
+ "Running": true,
118
+ "StartedAt": "2014-09-26T15:08:37.737780273Z"
119
+ },
120
+ "Mounts": [
121
+ {
122
+ "Source": "/data",
123
+ "Destination": "/tmp",
124
+ "Mode": "",
125
+ "RW": true
126
+ }
127
+ ]
128
+ }
129
+ ]
130
+ EOS
131
+ end
@@ -0,0 +1,94 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ property[:os] = nil
5
+ set :os, {:family => 'linux'}
6
+
7
+ describe docker_image('busybox:latest') do
8
+ it { should exist }
9
+ end
10
+
11
+ describe docker_image('busybox:latest') do
12
+ let(:stdout) { inspect_image }
13
+ its(:inspection) { should include 'Architecture' => 'amd64' }
14
+ its(['Architecture']) { should eq 'amd64' }
15
+ its(['Config.Cmd']) { should include '/bin/sh' }
16
+ end
17
+
18
+ def inspect_image
19
+ <<'EOS'
20
+ [{
21
+ "Architecture": "amd64",
22
+ "Author": "Jérôme Petazzoni \u003cjerome@docker.com\u003e",
23
+ "Comment": "",
24
+ "Config": {
25
+ "AttachStderr": false,
26
+ "AttachStdin": false,
27
+ "AttachStdout": false,
28
+ "Cmd": [
29
+ "/bin/sh"
30
+ ],
31
+ "CpuShares": 0,
32
+ "Cpuset": "",
33
+ "Domainname": "",
34
+ "Entrypoint": null,
35
+ "Env": [
36
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
37
+ ],
38
+ "ExposedPorts": null,
39
+ "Hostname": "88f18f678e5d",
40
+ "Image": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644",
41
+ "Memory": 0,
42
+ "MemorySwap": 0,
43
+ "NetworkDisabled": false,
44
+ "OnBuild": [],
45
+ "OpenStdin": false,
46
+ "PortSpecs": null,
47
+ "StdinOnce": false,
48
+ "Tty": false,
49
+ "User": "",
50
+ "Volumes": null,
51
+ "WorkingDir": ""
52
+ },
53
+ "Container": "8e73b239682fe73338323d9af83d3c5aa5bb7d22a3fe84cbfcf5f47e756d6636",
54
+ "ContainerConfig": {
55
+ "AttachStderr": false,
56
+ "AttachStdin": false,
57
+ "AttachStdout": false,
58
+ "Cmd": [
59
+ "/bin/sh",
60
+ "-c",
61
+ "#(nop) CMD [/bin/sh]"
62
+ ],
63
+ "CpuShares": 0,
64
+ "Cpuset": "",
65
+ "Domainname": "",
66
+ "Entrypoint": null,
67
+ "Env": [
68
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
69
+ ],
70
+ "ExposedPorts": null,
71
+ "Hostname": "88f18f678e5d",
72
+ "Image": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644",
73
+ "Memory": 0,
74
+ "MemorySwap": 0,
75
+ "NetworkDisabled": false,
76
+ "OnBuild": [],
77
+ "OpenStdin": false,
78
+ "PortSpecs": null,
79
+ "StdinOnce": false,
80
+ "Tty": false,
81
+ "User": "",
82
+ "Volumes": null,
83
+ "WorkingDir": ""
84
+ },
85
+ "Created": "2014-10-01T20:46:08.914288461Z",
86
+ "DockerVersion": "1.2.0",
87
+ "Id": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287",
88
+ "Os": "linux",
89
+ "Parent": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644",
90
+ "Size": 0
91
+ }
92
+ ]
93
+ EOS
94
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, {:family => 'linux'}
5
+
6
+ describe file('/tmp') do
7
+ it { should be_readable.by_user('mail') }
8
+ end
9
+
10
+ describe file('/tmp') do
11
+ it { should be_writable.by_user('mail') }
12
+ end
13
+
14
+ describe file('/tmp') do
15
+ it { should be_executable.by_user('mail') }
16
+ end
17
+
18
+ describe file('/tmp') do
19
+ it { should be_immutable }
20
+ end
21
+
22
+ describe file('/tmp') do
23
+ let(:exit_status) { 0 }
24
+ let(:stdout) { 'unconfined_u:unconfined_r:unconfined_t:s0' }
25
+ its(:selinux_label) { should eq 'unconfined_u:unconfined_r:unconfined_t:s0' }
26
+ end
27
+
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe fstab do
6
+ let(:stdout) { "/dev/sda1 /mnt ext4 ro,errors=remount-ro,barrier=0 0 2\r\n" }
7
+ it { should have_entry( :mount_point => '/mnt' ) }
8
+ end
9
+
10
+ describe fstab do
11
+ let(:exit_status) { 1 }
12
+ it { should_not have_entry( :mount_point => '/mnt' ) }
13
+ end
14
+
15
+ describe fstab do
16
+ let(:stdout) { "/dev/sda1 /mnt ext4 ro,errors=remount-ro,barrier=0 0 2\r\n" }
17
+ it do
18
+ should have_entry(
19
+ :device => '/dev/sda1',
20
+ :mount_point => '/mnt',
21
+ :type => 'ext4',
22
+ :options => {
23
+ :ro => true,
24
+ :errors => 'remount-ro',
25
+ :barrier => 0
26
+ },
27
+ :dump => 0,
28
+ :pass => 2
29
+ )
30
+ end
31
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe interface('eth0') do
6
+ let(:stdout) { '1000' }
7
+ its(:speed) { should eq 1000 }
8
+ end
9
+
10
+ describe interface('eth0') do
11
+ let(:stdout) { '1500' }
12
+ its(:mtu) { should eq 1500 }
13
+ end
14
+
15
+ describe interface('eth0') do
16
+ it { should have_ipv4_address('192.168.10.10') }
17
+ end
18
+
19
+ describe interface('eth0') do
20
+ it { should have_ipv4_address('192.168.10.10/24') }
21
+ end
22
+
23
+ describe interface('eth0') do
24
+ it { should have_ipv6_address('2001:0db8:bd05:01d2:288a:1fc0:0001:10ee') }
25
+ end
26
+
27
+ describe interface('eth1') do
28
+ let(:stdout) { "1.2.3.4/1\r\n" }
29
+ its(:ipv4_address) { should match(/^[\d.]+\/\d+$/) }
30
+ end
31
+
32
+ describe interface('eth1') do
33
+ let(:stdout) { "2001:db8::1234/1\r\n" }
34
+ its(:ipv6_address) { should match(/^[a-f\d:]+\/\d+$/i) }
35
+ end
36
+
37
+ describe interface('eth0') do
38
+ let(:stdout) { 'up' }
39
+ it { should be_up }
40
+ end
41
+
42
+ describe interface('invalid-interface') do
43
+ let(:stdout) { '1000' }
44
+ its(:speed) { should_not eq 100 }
45
+ end
46
+
47
+ describe interface('invalid-interface') do
48
+ let(:stdout) { '9001' }
49
+ its(:mtu) { should_not eq 1500 }
50
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe ip6tables do
6
+ it { should have_rule '-P INPUT ACCEPT' }
7
+ end
8
+
9
+ describe ip6tables do
10
+ it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
11
+ end
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe iptables do
6
+ it { should have_rule '-P INPUT ACCEPT' }
7
+ end
8
+
9
+ describe iptables do
10
+ it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe kernel_module('lp') do
6
+ it { should be_loaded }
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ set :os, :family => 'linux'
4
+
5
+ describe kvm('ct01') do
6
+ it { should exist }
7
+ end
8
+
9
+ describe kvm('ct01') do
10
+ it { should be_running }
11
+ end
12
+
13
+ describe kvm('ct01') do
14
+ it { should be_enabled }
15
+ end