remove keep awake recipe and tests

This commit is contained in:
Jacob Zaval 2021-02-25 15:44:09 -08:00
Родитель 0b07d65bb8
Коммит 59567af3d4
6 изменённых файлов: 1 добавлений и 209 удалений

Просмотреть файл

@ -35,24 +35,6 @@ Each of these attributes defaults to vagrant since our resources are developed
with the Vagrant paradigm. In other words, the user and password declared here
should be an admin user with passwordless super-user rights.
## Recipes
#### ***All macos-cookbook recipes are deprecated and will be removed in a future release.***
### Keep Awake
Prevent macOS from falling asleep, disable the screensaver, reboot upon power failure,
enable wake on LAN, enable remote login (SSH) and adjust several other settings
to always keep macOS on and available.
**Usage:** `include_recipe 'macos::keep_awake'`
| Attributes used | Default value |
|-----------------------------------------|-------------------------|
| `node['macos']['remote_login_enabled']` | `true` |
| `node['macos']['network_time_server']` | `'time.windows.com'` |
| `node['macos']['time_zone']` | `'America/Los_Angeles'` |
## Resources
- [`automatic_software_updates`](https://github.com/Microsoft/macos-cookbook/blob/master/documentation/resource_automatic_software_updates.md)

Просмотреть файл

@ -1,7 +1,2 @@
default['macos']['admin_user'] = 'vagrant'
default['macos']['admin_password'] = 'vagrant'
default['macos']['remote_login_enabled'] = true
default['macos']['network_time_server'] = 'time.windows.com'
default['macos']['time_zone'] = 'America/Los_Angeles'

Просмотреть файл

@ -67,17 +67,6 @@ suites:
controls:
- updates-disabled
- name: power-management
provisioner:
enforce_idempotency: true
run_list:
- recipe[macos::keep_awake]
verifier:
controls:
- screensaver-disabled
- remote-administration
- no-sleep
- name: spotlight
provisioner:
enforce_idempotency: true

Просмотреть файл

@ -4,7 +4,7 @@ maintainer_email 'chef@microsoft.com'
license 'MIT'
description 'Resources for configuring and provisioning macOS'
chef_version '>= 14.0'
version '3.4.3'
version '4.0.0'
source_url 'https://github.com/Microsoft/macos-cookbook'
issues_url 'https://github.com/Microsoft/macos-cookbook/issues'

Просмотреть файл

@ -1,74 +0,0 @@
Chef.deprecated(:generic, 'macos::keep_awake is deprecated and will be removed in a future release')
form_factor = MacOS::System::FormFactor.new(node['hardware'])
environment = MacOS::System::Environment.new(node['virtualization']['systems'])
screensaver = MacOS::System::ScreenSaver.new(node['macos']['admin_user'])
system_preference 'disable computer sleep' do
preference :computersleep
setting 'Never'
end
system_preference 'disable display sleep' do
preference :displaysleep
setting 'Never'
end
system_preference 'disable hard disk sleep' do
preference :harddisksleep
setting 'Never'
end
system_preference 'restart if the computer becomes unresponsive' do
preference :restartfreeze
setting 'On'
end
system_preference 'wake the computer when accessed using a network connection' do
preference :wakeonnetworkaccess
setting 'On'
not_if { environment.vm? }
end
system_preference 'restart after a power failure' do
preference :restartpowerfailure
setting 'On'
not_if { environment.vm? || form_factor.portable? }
end
system_preference 'pressing power button does not sleep computer' do
preference :allowpowerbuttontosleepcomputer
setting 'Off'
only_if { form_factor.desktop? }
end
system_preference 'allow remote apple events' do
preference :remoteappleevents
setting 'On'
end
system_preference 'set the network time server' do
preference :networktimeserver
setting node['macos']['network_time_server']
end
system_preference 'set the time zone' do
preference :timezone
setting node['macos']['time_zone']
end
system_preference 'enable remote login' do
preference :remotelogin
if node['macos']['remote_login_enabled']
setting 'On'
else
setting 'Off'
end
end
defaults 'com.apple.screensaver' do
option '-currentHost write'
settings 'idleTime' => 0
not_if { screensaver.disabled? }
user node['macos']['admin_user']
end

Просмотреть файл

@ -1,100 +0,0 @@
require 'spec_helper'
include MacOS::System
shared_context 'running on bare metal Mac Mini' do
before(:each) do
chef_run.node.automatic['virtualization']['systems'] = { 'vbox' => 'host', 'Parallels' => 'host' }
chef_run.node.automatic['hardware']['machine_model'] = 'Macmini7,1'
end
shared_examples 'including metal-specific power preferences' do
it 'sets wake on lan' do
chef_run.converge(described_recipe)
expect(chef_run).to set_system_preference('wake the computer when accessed using a network connection')
end
it 'disables power button sleep' do
chef_run.converge(described_recipe)
expect(chef_run).to set_system_preference('pressing power button does not sleep computer')
end
it 'sets restart after a power failure' do
chef_run.converge(described_recipe)
expect(chef_run).to set_system_preference('restart after a power failure')
end
it 'converges successfully on bare metal' do
expect { chef_run }.to_not raise_error
end
end
end
shared_context 'when running on bare metal MacBook Pro' do
before(:each) do
chef_run.node.automatic['virtualization']['systems'] = { 'vbox' => 'host', 'Parallels' => 'host' }
chef_run.node.automatic['hardware']['machine_model'] = 'MacBookPro14,3'
end
shared_examples 'including metal-specific power preferences for portables' do
it 'sets wake on lan' do
chef_run.converge(described_recipe)
expect(chef_run).to set_system_preference('wake the computer when accessed using a network connection')
end
it 'does not set restart after a power failure' do
chef_run.converge(described_recipe)
expect(chef_run).to_not set_system_preference('restart after a power failure')
end
it 'converges successfully on bare metal' do
expect { chef_run }.to_not raise_error
end
end
end
shared_context 'running in a Parallels virtual machine' do
before(:each) do
chef_run.node.automatic['virtualization']['systems'] = { 'Parallels' => 'guest' }
chef_run.node.automatic['hardware']['machine_model'] = 'Parallels13,1'
end
shared_examples 'ignoring metal-specific power preferences' do
it 'does not set wake on lan' do
chef_run.converge(described_recipe)
expect(chef_run).to_not set_system_preference('wake the computer when accessed using a network connection')
end
it 'skips disabling power button sleep' do
chef_run.converge(described_recipe)
expect(chef_run).to_not set_system_preference('pressing power button does not sleep computer')
end
it 'does not set restart after a power failure' do
chef_run.converge(described_recipe)
expect(chef_run).to_not set_system_preference('restart after a power failure')
end
it 'converges successfully in a vm' do
expect { chef_run }.to_not raise_error
end
end
end
describe 'macos::keep_awake' do
let(:chef_run) { ChefSpec::SoloRunner.new }
describe 'keep_awake in a Parallels VM' do
include_context 'running in a Parallels virtual machine'
it_behaves_like 'ignoring metal-specific power preferences'
end
describe 'keep_awake on bare metal' do
include_context 'running on bare metal Mac Mini'
it_behaves_like 'including metal-specific power preferences'
end
describe 'keep_awake on portable bare metal' do
include_context 'when running on bare metal MacBook Pro'
it_behaves_like 'including metal-specific power preferences for portables'
end
end