Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def config_dir
def configure
return unless node['cpe_adobe_flash']['configure']

configs = node['cpe_adobe_flash']['configs'].reject { |_k, v| v.nil? }
configs = node['cpe_adobe_flash']['configs'].compact
# Until adobe removes this problematic naming convention,
# we still have to use it.
{
Expand All @@ -47,14 +47,14 @@ def configure
not_if { configs.empty? }
owner 'root'
group 'admin'
mode 0755
mode '0755'
action :create
end
template ::File.join(config_dir, 'mms.cfg') do # ~ FB016
source 'cpe_adobe_flash.erb'
owner 'root'
group 'admin'
mode 0644
mode '0644'
action configs.empty? ? :delete : :create
notifies :restart, 'launchd[com.adobe.fpsaud]'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
def configure
return unless node['cpe_adobe_flash']['configure']

configs = node['cpe_adobe_flash']['configs'].reject { |_k, v| v.nil? }
configs = node['cpe_adobe_flash']['configs'].compact
node.default['cpe_adobe_flash']['_applied_configs'] = configs

template ::File.join(config_dir, 'mms.cfg') do # ~FB031
Expand Down
4 changes: 2 additions & 2 deletions itchef/cookbooks/cpe_bluetooth/resources/cpe_bluetooth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
default_action :config

action :config do
prefs = node['cpe_bluetooth'].reject { |_k, v| v.nil? }
prefs = node['cpe_bluetooth'].compact
if prefs.empty?
Chef::Log.info("#{cookbook_name}: No prefs found.")
return
end

prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition

profile = {
'PayloadIdentifier' => "#{prefix}.bluetooth",
Expand Down
27 changes: 15 additions & 12 deletions itchef/cookbooks/cpe_chrome/resources/cpe_chrome_posix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
manage_chrome_extensions
end

action_class do
action_class do # rubocop:disable Metrics/BlockLength
def install_repos
return unless node.linux?
return unless node['cpe_chrome']['manage_repo']
Expand Down Expand Up @@ -69,7 +69,7 @@ def manage_chrome
!node.installed?('com.google.Chrome')
if node['cpe_chrome']['mp']['UseMasterPreferencesFile']
mprefs =
node['cpe_chrome']['mp']['FileContents'].reject { |_k, v| v.nil? }
node['cpe_chrome']['mp']['FileContents'].compact
else
mprefs = {}
end
Expand Down Expand Up @@ -142,7 +142,7 @@ def manage_chrome_linux(mprefs, prefs)

def manage_chrome_macos(mprefs, prefs)
prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition
chrome_profile = {
'PayloadIdentifier' => "#{prefix}.browsers.chrome",
'PayloadRemovalDisallowed' => true,
Expand Down Expand Up @@ -170,7 +170,7 @@ def manage_chrome_macos(mprefs, prefs)
# Check for Chrome Canary
if node.installed?('com.google.Chrome.canary')
prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition
canary_profile = {
'PayloadIdentifier' => "#{prefix}.browsers.chromecanary",
'PayloadRemovalDisallowed' => true,
Expand Down Expand Up @@ -224,7 +224,7 @@ def manage_chrome_macos(mprefs, prefs)
def manage_chrome_extensions_macos(extprefs)
return if extprefs.empty?
prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition
extprefs.each do |k, v|
chrome_ext_profile = {
'PayloadIdentifier' => "#{prefix}.browsers.chrome.extension.#{k}",
Expand All @@ -238,7 +238,7 @@ def manage_chrome_extensions_macos(extprefs)
'PayloadContent' => [{
'PayloadType' => "com.google.Chrome.extensions.#{k}",
'PayloadVersion' => 1,
'PayloadIdentifier' => "#{prefix}.browsers.chrome.extension.settings.#{k}",
'PayloadIdentifier' => "#{prefix}.browsers.chrome.extension.settings.#{k}", # rubocop:disable Layout/LineLength
'PayloadUUID' => v['payload_uuid'],
'PayloadEnabled' => true,
'PayloadDisplayName' => "Chrome Extension (#{v['display_name']})",
Expand All @@ -247,16 +247,17 @@ def manage_chrome_extensions_macos(extprefs)
v['profile'].each do |k_ext, v_ext|
chrome_ext_profile['PayloadContent'][0][k_ext] = v_ext['value']
end
node.default['cpe_profiles']["#{prefix}.browsers.chrome.extension.#{k}"] = chrome_ext_profile
node.default['cpe_profiles']["#{prefix}.browsers.chrome.extension.#{k}"] =
chrome_ext_profile
end

# Check for Chrome Canary
if node.installed?('com.google.Chrome.canary')
prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition
extprefs.each do |k, v|
canary_ext_profile = {
'PayloadIdentifier' => "#{prefix}.browsers.chromecanary.extension.#{k}",
'PayloadIdentifier' => "#{prefix}.browsers.chromecanary.extension.#{k}", # rubocop:disable Layout/LineLength
'PayloadRemovalDisallowed' => true,
'PayloadScope' => 'System',
'PayloadType' => 'Configuration',
Expand All @@ -267,16 +268,16 @@ def manage_chrome_extensions_macos(extprefs)
'PayloadContent' => [{
'PayloadType' => "com.google.Chrome.canary.extensions.#{k}",
'PayloadVersion' => 1,
'PayloadIdentifier' => "#{prefix}.browsers.chromecanary.extension.settings.#{k}",
'PayloadIdentifier' => "#{prefix}.browsers.chromecanary.extension.settings.#{k}", # rubocop:disable Layout/LineLength
'PayloadUUID' => v['payload_uuid'],
'PayloadEnabled' => true,
'PayloadDisplayName' => "Chrome Canary Extension (#{v['display_name']})",
'PayloadDisplayName' => "Chrome Canary Extension (#{v['display_name']})", # rubocop:disable Layout/LineLength
}],
}
v['profile'].each do |k_ext, v_ext|
canary_ext_profile['PayloadContent'][0][k_ext] = v_ext['value']
end
node.default['cpe_profiles']["#{prefix}.browsers.chromecanary.extension.#{k}"] = canary_ext_profile
node.default['cpe_profiles']["#{prefix}.browsers.chromecanary.extension.#{k}"] = canary_ext_profile # rubocop:disable Layout/LineLength
end
end
end
Expand Down Expand Up @@ -318,6 +319,7 @@ def migrate_chromium_settings_linux
::File.directory?('/etc/chromium') &&
!::File.symlink?('/etc/chromium')
end
# rubocop:disable Naming/HeredocDelimiterNaming
code <<-EOH
find /etc/chromium -type d -exec chmod 0755 {} \\;
find /etc/chromium -type f -exec chmod 0644 {} \\;
Expand All @@ -326,5 +328,6 @@ def migrate_chromium_settings_linux
rm -rf /etc/chromium
EOH
end
# rubocop:enable Naming/HeredocDelimiterNaming
end
end
4 changes: 2 additions & 2 deletions itchef/cookbooks/cpe_munki/resources/cpe_munki_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
action :config do
return unless node['cpe_munki']['configure']

munki_prefs = node['cpe_munki']['preferences'].reject { |_k, v| v.nil? }
munki_prefs = node['cpe_munki']['preferences'].compact
if munki_prefs.empty?
Chef::Log.info("#{cookbook_name}: No prefs found.")
return
end

prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition

munki_profile = {
'PayloadIdentifier' => "#{prefix}.munki",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
return unless node['cpe_munki']['configure']

munki_prefs = node['cpe_munki'][
'defaults_preferences'].reject { |_k, v| v.nil? }
'defaults_preferences'].compact

if munki_prefs.empty?
Chef::Log.info("#{cookbook_name}: No defaults prefs found.")
Expand Down
10 changes: 5 additions & 5 deletions itchef/cookbooks/cpe_nomad/resources/darwin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def configure_login

def configure_profile
nomad_prefs =
node['cpe_nomad']['prefs'].reject { |_k, v| v.nil? }
node['cpe_nomad']['prefs'].compact
login_prefs =
node['cpe_nomad']['login']['prefs'].reject { |_k, v| v.nil? }
node['cpe_nomad']['login']['prefs'].compact
actions_prefs =
node['cpe_nomad']['actions']['prefs'].reject { |_k, v| v.nil? }
node['cpe_nomad']['actions']['prefs'].compact
if [
nomad_prefs,
login_prefs,
Expand Down Expand Up @@ -122,7 +122,7 @@ def configure_profile
end

prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition

{
'NoMAD' => nomad_prefs,
Expand Down Expand Up @@ -172,7 +172,7 @@ def log_vars(action, status)
end

def log_if(msg)
CPE::Log.if(
CPE::Log.if( # rubocop:disable Style/ExplicitBlockArgument
msg, :type => @type, :action => @action, :status => @status
) { yield }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
default_action :config

action :config do
pw_prefs = node['cpe_powermanagement'].reject { |_k, v| v.nil? }
pw_prefs = node['cpe_powermanagement'].compact
if pw_prefs.empty?
Chef::Log.debug("#{cookbook_name}: No prefs found.")
return
Expand All @@ -34,17 +34,17 @@
ident = "com.apple.EnergySaver.#{machine_type}"

prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition
energy_profile = {
'PayloadIdentifier' => "#{prefix}.powermanagement",
'PayloadIdentifier' => "#{prefix}.powermanagement",
'PayloadRemovalDisallowed' => true,
'PayloadScope' => 'System',
'PayloadType' => 'Configuration',
'PayloadUUID' => 'd1207590-f93a-0133-92e4-4cc760f34b36',
'PayloadOrganization' => organization,
'PayloadVersion' => 1,
'PayloadDisplayName' => 'Power Management',
'PayloadContent' => [
'PayloadScope' => 'System',
'PayloadType' => 'Configuration',
'PayloadUUID' => 'd1207590-f93a-0133-92e4-4cc760f34b36',
'PayloadOrganization' => organization,
'PayloadVersion' => 1,
'PayloadDisplayName' => 'Power Management',
'PayloadContent' => [
{
'PayloadType' => 'com.apple.MCX',
'PayloadVersion' => 1,
Expand All @@ -58,13 +58,13 @@

pm_prefs = {
'ACPower' =>
node['cpe_powermanagement']['ACPower'].reject { |_k, v| v.nil? },
node['cpe_powermanagement']['ACPower'].compact,
'Battery' =>
node['cpe_powermanagement']['Battery'].reject { |_k, v| v.nil? },
node['cpe_powermanagement']['Battery'].compact,
}

# Apply all settings to the profile - AC and/or Battery
pm_prefs.keys.each do |type|
pm_prefs.each_key do |type|
next if pm_prefs[type].empty?
energy_profile['PayloadContent'][0]["#{ident}.#{type}-ProfileNumber"] = -1
energy_profile['PayloadContent'][0]["#{ident}.#{type}"] = pm_prefs[type]
Expand Down
4 changes: 2 additions & 2 deletions itchef/cookbooks/cpe_preferencepanes/resources/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

# rubocop:disable Metrics/BlockLength
action :config do
prefs = node['cpe_preferencepanes'].reject { |_k, v| v.nil? }
prefs = node['cpe_preferencepanes'].compact
return if prefs.empty?
prefix = node['cpe_profiles']['prefix']
organization = node['organization'] ? node['organization'] : 'Facebook'
organization = node['organization'] ? node['organization'] : 'Facebook' # rubocop:disable Style/RedundantCondition
pane_profile = {
'PayloadIdentifier' => "#{prefix}.prefpanes",
'PayloadRemovalDisallowed' => true,
Expand Down
4 changes: 2 additions & 2 deletions itchef/cookbooks/cpe_profiles_local/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ to `node.default['cpe_profiles_local']`
For instance, add a hash to manage the loginwindow and use the default prefix:

```
lw_prefs = node['cpe_loginwindow'].reject { |\_k, v| v.nil? }
lw_prefs = node['cpe_loginwindow'].compact
if lw_prefs.empty?
Chef::Log.debug("#{cookbook_name}: No prefs found.")
return
Expand Down Expand Up @@ -77,7 +77,7 @@ Or, if you want to customize the prefix and then add a profile, you would do:
# Override the default prefix value of 'com.facebook.chef'
node.default['cpe_profiles_local']['prefix'] = 'com.company.chef'
# Use the specified prefix to name the configuration profile
lw_prefs = node['cpe_loginwindow'].reject { |\_k, v| v.nil? }
lw_prefs = node['cpe_loginwindow'].compact
if lw_prefs.empty?
Chef::Log.debug("#{cookbook_name}: No prefs found.")
return
Expand Down