add linters and refactor bootstraping scripts

- giant refactoring
- add aliases and functions to ease work
- apply linters / fixers / fmt to most files
This commit is contained in:
MorganGeek
2020-07-11 12:25:30 +02:00
parent e48c7e700a
commit 228982a0a8
42 changed files with 1813 additions and 1637 deletions

View File

@ -1,38 +1,38 @@
---
- hosts: localhost
connection: local
become_method: sudo
become: yes
- hosts: localhost
connection: local
become_method: sudo
become: yes
tasks:
- name: Check yubikey binaries are installed
stat:
path: "{{ item }}"
with_items:
- /usr/local/bin/ykpamcfg
- "/Applications/YubiKey\ Manager.app/Contents/MacOS/ykman"
tasks:
- name: Check yubikey binaries are installed
stat:
path: '{{ item }}'
with_items:
- /usr/local/bin/ykpamcfg
- /Applications/YubiKey Manager.app/Contents/MacOS/ykman
- name: Check Yubico is recognized
shell: "'/Applications/YubiKey Manager.app/Contents/MacOS/ykman' list | awk '{print $6}'"
register: yubicoChallenge
failed_when: "yubicoChallenge.rc != 0 or yubicoChallenge.stdout == ''"
- name: Check Yubico is recognized
shell: "'/Applications/YubiKey Manager.app/Contents/MacOS/ykman' list | awk '{print $6}'"
register: yubicoChallenge
failed_when: yubicoChallenge.rc != 0 or yubicoChallenge.stdout == ''
- name: Get current user
become: false
local_action: command whoami
register: username_on_host
- name: Get current user
become: false
local_action: command whoami
register: username_on_host
- name: Check yubico challenge exists
stat:
path: "/Users/{{ username_on_host.stdout }}/.yubico/challenge-{{ yubicoChallenge.stdout }}"
- name: Check yubico challenge exists
stat:
path: /Users/{{ username_on_host.stdout }}/.yubico/challenge-{{ yubicoChallenge.stdout }}
- name: Ensure yubikey is needed for authentication at login screen
lineinfile:
path: "{{ item }}"
regexp: '^auth.*pam_yubico.so.*'
line: "auth required /usr/local/lib/security/pam_yubico.so mode=challenge-response"
insertbefore: "^account required pam_opendirectory.so"
state: absent
with_items:
- /etc/pam.d/screensaver
- /etc/pam.d/authorization
- name: Ensure yubikey is needed for authentication at login screen
lineinfile:
path: '{{ item }}'
regexp: ^auth.*pam_yubico.so.*
line: auth required /usr/local/lib/security/pam_yubico.so mode=challenge-response
insertbefore: ^account required pam_opendirectory.so
state: absent
with_items:
- /etc/pam.d/screensaver
- /etc/pam.d/authorization

View File

@ -1,46 +1,46 @@
---
- hosts: localhost
connection: local
become_method: sudo
become: yes
- hosts: localhost
connection: local
become_method: sudo
become: yes
tasks:
- name: Check yubikey binaries are installed
stat:
path: "{{ item }}"
with_items:
- /usr/local/bin/ykpamcfg
- "/Applications/YubiKey\ Manager.app/Contents/MacOS/ykman"
tasks:
- name: Check yubikey binaries are installed
stat:
path: '{{ item }}'
with_items:
- /usr/local/bin/ykpamcfg
- /Applications/YubiKey Manager.app/Contents/MacOS/ykman
- name: Check Yubico is recognized
shell: "'/Applications/YubiKey Manager.app/Contents/MacOS/ykman' list | awk '{print $6}'"
register: yubicoChallenge
failed_when: "yubicoChallenge.rc != 0 or yubicoChallenge.stdout == ''"
- name: Check Yubico is recognized
shell: "'/Applications/YubiKey Manager.app/Contents/MacOS/ykman' list | awk '{print $6}'"
register: yubicoChallenge
failed_when: yubicoChallenge.rc != 0 or yubicoChallenge.stdout == ''
- name: Get current user
become: false
local_action: command whoami
register: username_on_host
- name: Get current user
become: false
local_action: command whoami
register: username_on_host
- name: Check yubico challenge exists
stat:
path: "/Users/{{ username_on_host.stdout }}/.yubico/challenge-{{ yubicoChallenge.stdout }}"
- name: Check yubico challenge exists
stat:
path: /Users/{{ username_on_host.stdout }}/.yubico/challenge-{{ yubicoChallenge.stdout }}
- name: Ensure yubikey is needed for authentication at login screen
lineinfile:
path: "{{ item }}"
regexp: '^auth.*pam_yubico.so.*'
line: "auth required /usr/local/lib/security/pam_yubico.so mode=challenge-response"
insertbefore: "^account required pam_opendirectory.so"
with_items:
- /etc/pam.d/screensaver
- /etc/pam.d/authorization
- name: Ensure yubikey is needed for authentication at login screen
lineinfile:
path: '{{ item }}'
regexp: ^auth.*pam_yubico.so.*
line: auth required /usr/local/lib/security/pam_yubico.so mode=challenge-response
insertbefore: ^account required pam_opendirectory.so
with_items:
- /etc/pam.d/screensaver
- /etc/pam.d/authorization
- name: Ensure touch id is enough to authenticate with sudo
lineinfile:
path: "{{ item }}"
regexp: '^auth.*sufficient.*pam_tid.so.*'
line: "auth sufficient pam_tid.so"
insertafter: "^#.*"
with_items:
- /etc/pam.d/sudo
- name: Ensure touch id is enough to authenticate with sudo
lineinfile:
path: '{{ item }}'
regexp: ^auth.*sufficient.*pam_tid.so.*
line: auth sufficient pam_tid.so
insertafter: ^#.*
with_items:
- /etc/pam.d/sudo