|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'spec_helper_acceptance' |
| 4 | + |
| 5 | +describe 'systemd with manage_networkd true' do |
| 6 | + has_package = fact('os.family') == 'RedHat' |
| 7 | + |
| 8 | + # On Enterprise Linux 8 & 9 the package is shipped in EPEL |
| 9 | + before { install_package(default, 'epel-release') if has_package && %w[8 9].include?(fact('os.release.major')) } |
| 10 | + |
| 11 | + context 'configure systemd-networkd' do |
| 12 | + let(:manifest) do |
| 13 | + <<~PUPPET |
| 14 | + class { 'systemd': |
| 15 | + manage_networkd => true, |
| 16 | + } |
| 17 | + PUPPET |
| 18 | + end |
| 19 | + |
| 20 | + it 'works idempotently with no errors' do |
| 21 | + apply_manifest(manifest, catch_failures: true) |
| 22 | + # Package systemd-networkd needs to be installed before fact $facts['internal_services'] is set |
| 23 | + apply_manifest(manifest, catch_failures: true) if has_package |
| 24 | + apply_manifest(manifest, catch_changes: true) |
| 25 | + end |
| 26 | + |
| 27 | + describe service('systemd-networkd') do |
| 28 | + it { is_expected.to be_running } |
| 29 | + it { is_expected.to be_enabled } |
| 30 | + end |
| 31 | + |
| 32 | + it { expect(package('systemd-networkd')).to be_installed } if has_package |
| 33 | + end |
| 34 | + |
| 35 | + context 'configure systemd stopped' do |
| 36 | + let(:manifest) do |
| 37 | + <<~PUPPET |
| 38 | + class { 'systemd': |
| 39 | + manage_networkd => true, |
| 40 | + networkd_ensure => 'stopped', |
| 41 | + } |
| 42 | + PUPPET |
| 43 | + end |
| 44 | + |
| 45 | + it 'works idempotently with no errors' do |
| 46 | + apply_manifest(manifest, catch_failures: true) |
| 47 | + apply_manifest(manifest, catch_changes: true) |
| 48 | + end |
| 49 | + |
| 50 | + describe service('systemd-networkd') do |
| 51 | + it { is_expected.not_to be_running } |
| 52 | + it { is_expected.not_to be_enabled } |
| 53 | + end |
| 54 | + end |
| 55 | +end |
0 commit comments