File tree 18 files changed +27
-27
lines changed
18 files changed +27
-27
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ defaults: # Used for any hierarchy level that omits these keys.
6
6
data_hash : yaml_data # Use the built-in YAML backend.
7
7
8
8
hierarchy :
9
- - name : " osfamily /major release"
9
+ - name : " os.family /major release"
10
10
paths :
11
11
# Used to distinguish between Debian and Ubuntu
12
12
- " os/%{facts.os.name}/%{facts.os.release.major}.yaml"
13
13
- " os/%{facts.os.family}/%{facts.os.release.major}.yaml"
14
14
# Used for Solaris
15
15
- " os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
16
- - name : " osfamily "
16
+ - name : " os.family "
17
17
paths :
18
18
- " os/%{facts.os.name}.yaml"
19
19
- " os/%{facts.os.family}.yaml"
Original file line number Diff line number Diff line change 2
2
3
3
# apt_reboot_required.rb
4
4
Facter . add ( :apt_reboot_required ) do
5
- confine osfamily : 'Debian'
5
+ confine 'os.family' : 'Debian'
6
6
setcode do
7
7
File . file? ( '/var/run/reboot-required' )
8
8
end
Original file line number Diff line number Diff line change 2
2
3
3
# This fact lists the .list filenames that are used by apt.
4
4
Facter . add ( :apt_sources ) do
5
- confine osfamily : 'Debian'
5
+ confine 'os.family' : 'Debian'
6
6
setcode do
7
7
sources = [ 'sources.list' ]
8
8
Dir . glob ( '/etc/apt/sources.list.d/*.{list,sources}' ) . each do |file |
Original file line number Diff line number Diff line change 6
6
# This is generated upon a successful apt-get update run natively in ubuntu.
7
7
# the Puppetlabs-apt module deploys this same functionality for other debian-ish OSes
8
8
Facter . add ( 'apt_update_last_success' ) do
9
- confine osfamily : 'Debian'
9
+ confine 'os.family' : 'Debian'
10
10
setcode do
11
11
if File . exist? ( '/var/lib/apt/periodic/update-success-stamp' )
12
12
# get epoch time
Original file line number Diff line number Diff line change @@ -31,15 +31,15 @@ def get_updates(upgrade_option)
31
31
end
32
32
33
33
Facter . add ( 'apt_has_updates' ) do
34
- confine osfamily : 'Debian'
34
+ confine 'os.family' : 'Debian'
35
35
setcode do
36
36
apt_package_updates = get_updates ( 'upgrade' )
37
37
apt_package_updates != [ [ ] , [ ] ] if !apt_package_updates . nil? && apt_package_updates . length == 2
38
38
end
39
39
end
40
40
41
41
Facter . add ( 'apt_has_dist_updates' ) do
42
- confine osfamily : 'Debian'
42
+ confine 'os.family' : 'Debian'
43
43
setcode do
44
44
apt_dist_updates = get_updates ( 'dist-upgrade' )
45
45
apt_dist_updates != [ [ ] , [ ] ] if !apt_dist_updates . nil? && apt_dist_updates . length == 2
Original file line number Diff line number Diff line change 11
11
Puppet ::Type . type ( :apt_key ) . provide ( :apt_key ) do
12
12
desc 'apt-key provider for apt_key resource'
13
13
14
- confine osfamily : :debian
15
- defaultfor osfamily : :debian
14
+ confine 'os.family' : :debian
15
+ defaultfor 'os.family' : :debian
16
16
commands apt_key : 'apt-key'
17
17
commands gpg : '/usr/bin/gpg'
18
18
Original file line number Diff line number Diff line change 9
9
10
10
describe 'on non-Debian distro' do
11
11
before ( :each ) do
12
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . once . and_return ( 'Redhat' )
12
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . once . and_return ( 'Redhat' )
13
13
end
14
14
15
15
it { is_expected . to be_nil }
16
16
end
17
17
18
18
describe 'on Debian based distro missing apt-get' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . once . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . once . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( false )
23
23
end
27
27
28
28
describe 'on Debian based distro' do
29
29
before ( :each ) do
30
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . once . and_return ( 'Debian' )
30
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . once . and_return ( 'Debian' )
31
31
allow ( File ) . to receive ( :executable? ) # Stub all other calls
32
32
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
33
33
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has security updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 9
9
10
10
describe 'on non-Debian distro' do
11
11
before ( :each ) do
12
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . once . and_return ( 'Redhat' )
12
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . once . and_return ( 'Redhat' )
13
13
end
14
14
15
15
it { is_expected . to be_nil }
16
16
end
17
17
18
18
describe 'on Debian based distro missing apt-get' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . once . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . once . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( false )
23
23
end
27
27
28
28
describe 'on Debian based distro' do
29
29
before ( :each ) do
30
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
30
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
31
31
allow ( File ) . to receive ( :executable? ) # Stub all other calls
32
32
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
33
33
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 9
9
10
10
describe 'if a reboot is required' do
11
11
before ( :each ) do
12
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
12
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
13
13
allow ( File ) . to receive ( :file? ) . and_return ( true )
14
14
allow ( File ) . to receive ( :file? ) . once . with ( '/var/run/reboot-required' ) . and_return ( true )
15
15
end
19
19
20
20
describe 'if a reboot is not required' do
21
21
before ( :each ) do
22
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
22
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
23
23
allow ( File ) . to receive ( :file? ) . and_return ( true )
24
24
allow ( File ) . to receive ( :file? ) . once . with ( '/var/run/reboot-required' ) . and_return ( false )
25
25
end
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has security updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
Original file line number Diff line number Diff line change 9
9
10
10
describe 'on Debian based distro which has not yet created the update-success-stamp file' do
11
11
it 'has a value of -1' do
12
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
12
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
13
13
allow ( File ) . to receive ( :exist? ) . with ( '/var/lib/apt/periodic/update-success-stamp' ) . and_return ( false )
14
14
expect ( subject ) . to eq ( -1 )
15
15
end
16
16
end
17
17
18
18
describe 'on Debian based distro which has created the update-success-stamp' do
19
19
it 'has the value of the mtime of the file' do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :exist? ) . and_return ( true )
22
22
allow ( File ) . to receive ( :mtime ) . and_return ( 1_407_660_561 )
23
23
expect ( subject ) . to eq ( 1_407_660_561 )
Original file line number Diff line number Diff line change 17
17
18
18
describe 'when apt has updates' do
19
19
before ( :each ) do
20
- allow ( Facter . fact ( :osfamily ) ) . to receive ( :value ) . and_return ( 'Debian' )
20
+ allow ( Facter . fact ( :'os.family' ) ) . to receive ( :value ) . and_return ( 'Debian' )
21
21
allow ( File ) . to receive ( :executable? ) # Stub all other calls
22
22
allow ( Facter ::Core ::Execution ) . to receive ( :execute ) # Catch all other calls
23
23
allow ( File ) . to receive ( :executable? ) . with ( '/usr/bin/apt-get' ) . and_return ( true )
You can’t perform that action at this time.
0 commit comments