|
261 | 261 | end |
262 | 262 | end |
263 | 263 | end |
| 264 | + |
| 265 | + context 'with no value' do |
| 266 | + let(:manifest) do |
| 267 | + "sysctl { 'vm.swappiness': }" |
| 268 | + end |
| 269 | + |
| 270 | + it 'works with no errors' do |
| 271 | + apply_manifest_on(host, manifest, catch_failures: true) |
| 272 | + end |
| 273 | + |
| 274 | + it 'is idempotent' do |
| 275 | + apply_manifest_on(host, manifest, catch_changes: true) |
| 276 | + end |
| 277 | + end |
| 278 | + |
| 279 | + context 'when setting multiple values' do |
| 280 | + let(:manifest) do |
| 281 | + <<-EOS |
| 282 | + sysctl { 'vm.swappiness': value => '60' } |
| 283 | + sysctl { 'net.ipv4.ip_forward': value => '0' } |
| 284 | + EOS |
| 285 | + end |
| 286 | + |
| 287 | + it 'works with no errors' do |
| 288 | + apply_manifest_on(host, manifest, catch_failures: true) |
| 289 | + end |
| 290 | + |
| 291 | + it 'is idempotent' do |
| 292 | + apply_manifest_on(host, manifest, catch_changes: true) |
| 293 | + end |
| 294 | + end |
| 295 | + |
| 296 | + context 'when removing multiple values' do |
| 297 | + let(:manifest_one) do |
| 298 | + <<-EOS |
| 299 | + sysctl { 'vm.swappiness': value => '60' } |
| 300 | + sysctl { 'net.ipv4.ip_forward': value => '0' } |
| 301 | + EOS |
| 302 | + end |
| 303 | + let(:manifest_two) do |
| 304 | + <<-EOS |
| 305 | + sysctl { 'vm.swappiness': ensure => 'absent' } |
| 306 | + sysctl { 'net.ipv4.ip_forward': ensure => 'absent' } |
| 307 | + EOS |
| 308 | + end |
| 309 | + |
| 310 | + it 'is idempotent' do |
| 311 | + apply_manifest_on(host, manifest_one, catch_failures: true) |
| 312 | + apply_manifest_on(host, manifest_two, catch_failures: true) |
| 313 | + apply_manifest_on(host, manifest_two, catch_changes: true) |
| 314 | + end |
| 315 | + end |
| 316 | + |
| 317 | + context 'when managing multiple files' do |
| 318 | + let(:manifest) do |
| 319 | + <<-EOS |
| 320 | + sysctl{'net.ipv6.conf.all.disable_ipv6': ensure => present, value => 1, target => '/etc/sysctl.d/99-disable-ipv6.conf' } |
| 321 | + sysctl{'net.ipv4.tcp_syncookies': ensure => present, value => 2, target => '/etc/sysctl.d/99-ddos-abwehr.conf'} |
| 322 | + EOS |
| 323 | + end |
| 324 | + |
| 325 | + it 'works with no errors' do |
| 326 | + apply_manifest_on(host, manifest, catch_failures: true) |
| 327 | + end |
| 328 | + |
| 329 | + it 'is idempotent' do |
| 330 | + apply_manifest_on(host, manifest, catch_changes: true) |
| 331 | + end |
| 332 | + |
| 333 | + describe 'removing one of two settings' do |
| 334 | + let(:manifest_one) do |
| 335 | + <<-EOS |
| 336 | + sysctl{'net.ipv6.conf.all.disable_ipv6': ensure => present, value => 1, target => '/etc/sysctl.d/99-disable-ipv6.conf' } |
| 337 | + sysctl{'net.ipv4.tcp_syncookies': ensure => present, value => 2, target => '/etc/sysctl.d/99-ddos-abwehr.conf'} |
| 338 | + EOS |
| 339 | + end |
| 340 | + let(:manifest_two) do |
| 341 | + <<-EOS |
| 342 | + sysctl{'net.ipv6.conf.all.disable_ipv6': ensure => present, value => 1, target => '/etc/sysctl.d/99-disable-ipv6.conf' } |
| 343 | + sysctl{'net.ipv4.tcp_syncookies': ensure => absent, target => '/etc/sysctl.d/99-ddos-abwehr.conf'} |
| 344 | + EOS |
| 345 | + end |
| 346 | + |
| 347 | + it 'is idempotent' do |
| 348 | + apply_manifest_on(host, manifest_one, catch_failures: true) |
| 349 | + apply_manifest_on(host, manifest_two, catch_failures: true) |
| 350 | + apply_manifest_on(host, manifest_two, catch_changes: true) |
| 351 | + end |
| 352 | + end |
| 353 | + end |
264 | 354 | end |
265 | 355 | end |
266 | 356 | end |
|
0 commit comments