Refactor completely to improve run speed

This commit is contained in:
Anthony Rose 2019-11-20 10:07:43 +00:00
parent 63ac952e17
commit 0f349ccc59
47 changed files with 251 additions and 177 deletions

16
gui.yml
View file

@ -2,12 +2,22 @@
--- ---
- name: Setup GUI - name: Setup GUI
hosts: localhost hosts: localhost
vars:
gui: true
tasks: tasks:
- include_role: - include_role:
name: distro name: debian
when: ansible_distribution == 'Debian'
- include_role: - include_role:
name: distro-gui name: freebsd
when: ansible_distribution == 'FreeBSD'
- include_role: - include_role:
name: home name: netbsd
when: ansible_distribution == 'NetBSD'
- include_role:
name: ubuntu
when: ansible_distribution == 'Ubuntu'
- include_role:
name: home-cli
- include_role: - include_role:
name: home-gui name: home-gui

View file

@ -2,8 +2,20 @@
--- ---
- name: Setup CLI - name: Setup CLI
hosts: localhost hosts: localhost
vars:
gui: false
tasks: tasks:
- include_role: - include_role:
name: distro name: debian
when: ansible_distribution == 'Debian'
- include_role: - include_role:
name: home name: freebsd
when: ansible_distribution == 'FreeBSD'
- include_role:
name: netbsd
when: ansible_distribution == 'NetBSD'
- include_role:
name: ubuntu
when: ansible_distribution == 'Ubuntu'
- include_role:
name: home-cli

View file

@ -0,0 +1,6 @@
---
- include: packages-cli.yml
- include: packages-gui.yml
when: gui == true
- include: modules.yml
- include: ssh.yml

View file

@ -1,5 +1,5 @@
--- ---
- name: Install Ubuntu CLI packages - name: Install CLI packages
become: true become: true
apt: apt:
name: '{{ packages }}' name: '{{ packages }}'

View file

@ -1,5 +1,5 @@
--- ---
- name: Install Debian GUI packages - name: Install GUI packages
become: true become: true
apt: apt:
name: '{{ packages }}' name: '{{ packages }}'

View file

@ -0,0 +1,20 @@
---
- name: Disable SSH passwords
become: true
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?\w*PasswordAuthentication (yes|no)'
line: 'PasswordAuthentication no'
register: changed_ssh_config
- name: Enable SSH
become: true
systemd:
name: ssh.service
enabled: yes
state: started
- name: Restart SSH
become: true
systemd:
name: ssh.service
state: restarted
when: changed_ssh_config.changed == true

View file

@ -1,9 +0,0 @@
---
- include: debian.yml
when: ansible_distribution == 'Debian'
- include: ubuntu.yml
when: ansible_distribution == 'Ubuntu'
- include: freebsd.yml
when: ansible_distribution == 'FreeBSD'
- include: netbsd.yml
when: ansible_distribution == 'NetBSD'

View file

@ -1,80 +0,0 @@
---
- name: Install FreeBSD core CLI packages
become: true
pkgng:
name: drm-kmod en-freebsd-doc git pkg py36-ansible sudo
state: present
- name: Install FreeBSD additional CLI packages
become: true
pkgng:
name: '{{ packages }}'
state: present
vars:
packages:
- fusefs-ntfs
- gnu-watch
- gnupg
- mc
- nmap
- openvpn
- py36-psutil
- rubygem-asciidoctor
- sqlite3
- tmux
- zsh
- name: Disable core dumps
become: true
sysctl:
name: kern.coredump
value: '0'
sysctl_set: yes
- name: Use IPv6 temporary addresses (sysctl.conf)
become: true
sysctl:
name: net.inet6.ip6.use_tempaddr
value: '1'
sysctl_set: yes
- name: Prefer IPv6 temporary addresses (sysctl.conf)
become: true
sysctl:
name: net.inet6.ip6.prefer_tempaddr
value: '1'
sysctl_set: yes
- name: Disable VT bell
become: true
sysctl:
name: kern.vt.enable_bell
value: '0'
sysctl_set: yes
- name: Enable IPv6 privacy (rc.conf)
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^ipv6_privacy=.*'
line: 'ipv6_privacy="YES"'
- name: Set wlan0 arguments
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^create_args_wlan0=.*'
line: 'create_args_wlan0="country GB"'
- name: Enable WPA/DHCP for wlan0
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^ifconfig_wlan0=.*'
line: 'ifconfig_wlan0="WPA SYNCDHCP"'
- name: Enable IPv6 for wlan0
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^ifconfig_wlan0_ipv6=.*'
line: 'ifconfig_wlan0_ipv6="inet6 accept_rtadv"'
- name: Enable wheel group to use sudo
become: true
lineinfile:
path: /usr/local/etc/sudoers.d/wheel
regexp: 'wheel'
line: '%wheel ALL=(ALL) ALL'
create: yes
mode: '0644'

View file

@ -1,12 +0,0 @@
---
- include: debian.yml
when: ansible_distribution == 'Debian'
- include: ubuntu.yml
when: ansible_distribution == 'Ubuntu'
- include: freebsd.yml
when: ansible_distribution == 'FreeBSD'
- include: netbsd.yml
when: ansible_distribution == 'NetBSD'
- include: modules.yml
when: ansible_system == 'Linux'
- include: ssh.yml

View file

@ -1,34 +0,0 @@
---
- name: Disable SSH passwords
become: true
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?\w*PasswordAuthentication (yes|no)'
line: 'PasswordAuthentication no'
register: changed_ssh_config
- name: Enable SSH (Linux)
become: true
systemd:
name: ssh.service
enabled: yes
state: started
when: ansible_system == 'Linux'
- name: Enable SSH (FreeBSD)
become: true
service:
name: sshd
enabled: yes
state: started
when: ansible_system == 'FreeBSD'
- name: Restart SSH (Linux)
become: true
systemd:
name: ssh.service
state: restarted
when: changed_ssh_config.changed == true and ansible_system == 'Linux'
- name: Restart SSH (FreeBSD)
become: true
service:
name: sshd
state: restarted
when: changed_ssh_config.changed == true and ansible_system == 'FreeBSD'

View file

@ -0,0 +1,10 @@
---
- include: packages-cli.yml
- include: packages-gui.yml
when: gui == true
- include: rc.yml
- include: sysctl.yml
- include: sudo.yml
- include: ssh.yml
- include: xorg.yml
when: gui == true

View file

@ -0,0 +1,24 @@
---
- name: Install core CLI packages
become: true
pkgng:
name: drm-kmod en-freebsd-doc git pkg py36-ansible sudo
state: present
- name: Install additional CLI packages
become: true
pkgng:
name: '{{ packages }}'
state: present
vars:
packages:
- fusefs-ntfs
- gnu-watch
- gnupg
- mc
- nmap
- openvpn
- py36-psutil
- rubygem-asciidoctor
- sqlite3
- tmux
- zsh

View file

@ -1,10 +1,10 @@
--- ---
- name: Install FreeBSD core GUI packages - name: Install core GUI packages
become: true become: true
pkgng: pkgng:
name: drm-kmod mate xdm xorg xterm name: drm-kmod mate xdm xorg xterm
state: present state: present
- name: Install FreeBSD additional GUI packages - name: Install additional GUI packages
become: true become: true
pkgng: pkgng:
name: '{{ packages }}' name: '{{ packages }}'
@ -29,20 +29,3 @@
- seahorse - seahorse
- vim - vim
- xinput - xinput
- name: Start DBUS service
become: true
service:
name: dbus
state: started
enabled: yes
- name: Enable XDM
become: true
lineinfile:
path: /etc/ttys
regexp: '^ttyv8\s.*'
line: 'ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure'
- name: Set xorg keyboard layout
become: true
copy:
src: keyboard-gb.conf
dest: /usr/local/etc/X11/xorg.conf.d/keyboard-gb.conf

View file

@ -0,0 +1,25 @@
---
- name: Enable IPv6 privacy
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^ipv6_privacy=.*'
line: 'ipv6_privacy="YES"'
- name: Set wlan0 arguments
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^create_args_wlan0=.*'
line: 'create_args_wlan0="country GB"'
- name: Enable WPA/DHCP for wlan0
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^ifconfig_wlan0=.*'
line: 'ifconfig_wlan0="WPA SYNCDHCP"'
- name: Enable IPv6 for wlan0
become: true
lineinfile:
path: /etc/rc.conf
regexp: '^ifconfig_wlan0_ipv6=.*'
line: 'ifconfig_wlan0_ipv6="inet6 accept_rtadv"'

View file

@ -0,0 +1,20 @@
---
- name: Disable SSH passwords
become: true
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?\w*PasswordAuthentication (yes|no)'
line: 'PasswordAuthentication no'
register: changed_ssh_config
- name: Enable SSH
become: true
service:
name: sshd
enabled: yes
state: started
- name: Restart SSH
become: true
service:
name: sshd
state: restarted
when: changed_ssh_config.changed == true

View file

@ -0,0 +1,9 @@
---
- name: Enable wheel group to use sudo
become: true
lineinfile:
path: /usr/local/etc/sudoers.d/wheel
regexp: 'wheel'
line: '%wheel ALL=(ALL) ALL'
create: yes
mode: '0644'

View file

@ -0,0 +1,25 @@
---
- name: Disable core dumps
become: true
sysctl:
name: kern.coredump
value: '0'
sysctl_set: yes
- name: Use IPv6 temporary addresses
become: true
sysctl:
name: net.inet6.ip6.use_tempaddr
value: '1'
sysctl_set: yes
- name: Prefer IPv6 temporary addresses
become: true
sysctl:
name: net.inet6.ip6.prefer_tempaddr
value: '1'
sysctl_set: yes
- name: Disable VT bell
become: true
sysctl:
name: kern.vt.enable_bell
value: '0'
sysctl_set: yes

View file

@ -0,0 +1,18 @@
---
- name: Start DBUS service
become: true
service:
name: dbus
state: started
enabled: yes
- name: Enable XDM
become: true
lineinfile:
path: /etc/ttys
regexp: '^ttyv8\s.*'
line: 'ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure'
- name: Set xorg keyboard layout
become: true
copy:
src: keyboard-gb.conf
dest: /usr/local/etc/X11/xorg.conf.d/keyboard-gb.conf

View file

@ -0,0 +1,6 @@
---
- include: packages-cli.yml
- include: packages-gui.yml
when: gui == true
- include: sudo.yml
- include: xorg.yml

View file

@ -6,16 +6,8 @@
regexp: '^CHECK_OSABI=' regexp: '^CHECK_OSABI='
line: 'CHECK_OSABI=no' line: 'CHECK_OSABI=no'
create: yes create: yes
- name: Install NetBSD CLI packages - name: Install CLI packages
become: true become: true
pkgin: pkgin:
name: git,gnupg2,mc,mozilla-rootcerts-openssl,nmap,openvpn,pkgin,py37-pip,python37,sqlite3,sudo,tmux,zsh name: git,gnupg2,mc,mozilla-rootcerts-openssl,nmap,openvpn,pkgin,py37-pip,python37,sqlite3,sudo,tmux,zsh
state: present state: present
- name: Enable wheel group to use sudo
become: true
lineinfile:
path: /usr/pkg/etc/sudoers.d/wheel
regexp: 'wheel'
line: '%wheel ALL=(ALL) ALL'
create: yes
mode: '0644'

View file

@ -0,0 +1,6 @@
---
- name: Install GUI packages
become: true
pkgin:
name: adwaita-icon-theme,atril,firefox,fvwm,liberation-ttf,mate-terminal,rxvt-unicode,vim-gtk3,xlockmore-lite
state: present

View file

@ -0,0 +1,9 @@
---
- name: Enable wheel group to use sudo
become: true
lineinfile:
path: /usr/pkg/etc/sudoers.d/wheel
regexp: 'wheel'
line: '%wheel ALL=(ALL) ALL'
create: yes
mode: '0644'

View file

@ -1,9 +1,4 @@
--- ---
- name: Install NetBSD GUI packages
become: true
pkgin:
name: adwaita-icon-theme,atril,firefox,fvwm,liberation-ttf,mate-terminal,rxvt-unicode,vim-gtk3,xlockmore-lite
state: present
- name: Enable xdm - name: Enable xdm
become: true become: true
lineinfile: lineinfile:

View file

@ -0,0 +1,6 @@
---
- include: packages-cli.yml
- include: packages-gui.yml
when: gui == true
- include: modules.yml
- include: ssh.yml

View file

@ -0,0 +1,13 @@
---
- name: Blacklist pcspkr module
become: true
lineinfile:
path: /etc/modprobe.d/blacklist.conf
line: blacklist pcspkr
create: yes
- name: Blacklist dvb_usb_rtl28xxu module
become: true
lineinfile:
path: /etc/modprobe.d/blacklist.conf
line: blacklist dvb_usb_rtl28xxu
create: yes

View file

@ -1,5 +1,5 @@
--- ---
- name: Install Debian CLI packages - name: Install CLI packages
become: true become: true
apt: apt:
name: '{{ packages }}' name: '{{ packages }}'

View file

@ -1,5 +1,5 @@
--- ---
- name: Install Ubuntu GUI packages - name: Install GUI packages
become: true become: true
apt: apt:
name: '{{ packages }}' name: '{{ packages }}'

View file

@ -0,0 +1,20 @@
---
- name: Disable SSH passwords
become: true
lineinfile:
path: /etc/ssh/sshd_config
regexp: '^#?\w*PasswordAuthentication (yes|no)'
line: 'PasswordAuthentication no'
register: changed_ssh_config
- name: Enable SSH
become: true
systemd:
name: ssh.service
enabled: yes
state: started
- name: Restart SSH
become: true
systemd:
name: ssh.service
state: restarted
when: changed_ssh_config.changed == true