Skip to content
Richard Spindler edited this page Jan 21, 2020 · 1 revision

Ansible

This option outputs example ansible configuration management code/stanzas for implementing the recommendation.

Usage

# ./lunar.sh -a -n

....

Checking:  Internet Sharing
Checking:  Parameter NAT is set to Enabled in /Library/Preferences/SystemConfiguration/com.apple.nat
Warning:   Parameter "NAT" not set to "Enabled" in "/Library/Preferences/SystemConfiguration/com.apple.nat" [61 Warnings]

- name: Checking Parameter NAT is set to Enabled in /Library/Preferences/SystemConfiguration/com.apple.nat
  command: sh -c "sudo defaults read /Library/Preferences/SystemConfiguration/com.apple.nat NAT 2>&1 |grep Enabled"
  register: defaults_check
  failed_when: defaults_check == 1
  changed_when: false
  ignore_errors: true
  when: ansible_facts['ansible_system'] == 'Darwin'

- name: Fixing Parameter NAT is set to Enabled in /Library/Preferences/SystemConfiguration/com.apple.nat
  command: sh -c "sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.nat NAT -dict Enabled -int 0"
  when: defaults_check.rc == 1 and ansible_facts['ansible_system'] == 'Darwin'

Checking:  Checking:  Service com.apple.InternetSharing is disabled

- name: Checking Service com.apple.InternetSharing is disabled
  command: sh -c "launchctl list |grep com.apple.InternetSharing |awk '{print $3}'"
  register: launchd_check
  failed_when: launchd_check == 1
  changed_when: false
  ignore_errors: true
  when: ansible_facts['ansible_system'] == 'Darwin'

- name: Fixing Service com.apple.InternetSharing is disabled
  command: sh -c "sudo launchctl unload -w com.apple.InternetSharing.plist"
  when: launchd_check.rc == 1 and ansible_facts['ansible_system'] == 'Darwin'
Clone this wiki locally