Refactor completely to improve run speed
This commit is contained in:
parent
63ac952e17
commit
0f349ccc59
47 changed files with 251 additions and 177 deletions
16
gui.yml
16
gui.yml
|
@ -2,12 +2,22 @@
|
|||
---
|
||||
- name: Setup GUI
|
||||
hosts: localhost
|
||||
vars:
|
||||
gui: true
|
||||
tasks:
|
||||
- include_role:
|
||||
name: distro
|
||||
name: debian
|
||||
when: ansible_distribution == 'Debian'
|
||||
- include_role:
|
||||
name: distro-gui
|
||||
name: freebsd
|
||||
when: ansible_distribution == 'FreeBSD'
|
||||
- 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:
|
||||
name: home-gui
|
||||
|
|
16
main.yml
16
main.yml
|
@ -2,8 +2,20 @@
|
|||
---
|
||||
- name: Setup CLI
|
||||
hosts: localhost
|
||||
vars:
|
||||
gui: false
|
||||
tasks:
|
||||
- include_role:
|
||||
name: distro
|
||||
name: debian
|
||||
when: ansible_distribution == 'Debian'
|
||||
- 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
|
||||
|
|
6
roles/debian/tasks/main.yml
Normal file
6
roles/debian/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- include: packages-cli.yml
|
||||
- include: packages-gui.yml
|
||||
when: gui == true
|
||||
- include: modules.yml
|
||||
- include: ssh.yml
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Install Ubuntu CLI packages
|
||||
- name: Install CLI packages
|
||||
become: true
|
||||
apt:
|
||||
name: '{{ packages }}'
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Install Debian GUI packages
|
||||
- name: Install GUI packages
|
||||
become: true
|
||||
apt:
|
||||
name: '{{ packages }}'
|
20
roles/debian/tasks/ssh.yml
Normal file
20
roles/debian/tasks/ssh.yml
Normal 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
|
|
@ -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'
|
|
@ -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'
|
|
@ -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
|
|
@ -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'
|
10
roles/freebsd/tasks/main.yml
Normal file
10
roles/freebsd/tasks/main.yml
Normal 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
|
24
roles/freebsd/tasks/packages-cli.yml
Normal file
24
roles/freebsd/tasks/packages-cli.yml
Normal 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
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- name: Install FreeBSD core GUI packages
|
||||
- name: Install core GUI packages
|
||||
become: true
|
||||
pkgng:
|
||||
name: drm-kmod mate xdm xorg xterm
|
||||
state: present
|
||||
- name: Install FreeBSD additional GUI packages
|
||||
- name: Install additional GUI packages
|
||||
become: true
|
||||
pkgng:
|
||||
name: '{{ packages }}'
|
||||
|
@ -29,20 +29,3 @@
|
|||
- seahorse
|
||||
- vim
|
||||
- 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
|
25
roles/freebsd/tasks/rc.yml
Normal file
25
roles/freebsd/tasks/rc.yml
Normal 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"'
|
20
roles/freebsd/tasks/ssh.yml
Normal file
20
roles/freebsd/tasks/ssh.yml
Normal 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
|
9
roles/freebsd/tasks/sudo.yml
Normal file
9
roles/freebsd/tasks/sudo.yml
Normal 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'
|
25
roles/freebsd/tasks/sysctl.yml
Normal file
25
roles/freebsd/tasks/sysctl.yml
Normal 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
|
18
roles/freebsd/tasks/xorg.yml
Normal file
18
roles/freebsd/tasks/xorg.yml
Normal 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
|
6
roles/netbsd/tasks/main.yml
Normal file
6
roles/netbsd/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- include: packages-cli.yml
|
||||
- include: packages-gui.yml
|
||||
when: gui == true
|
||||
- include: sudo.yml
|
||||
- include: xorg.yml
|
|
@ -6,16 +6,8 @@
|
|||
regexp: '^CHECK_OSABI='
|
||||
line: 'CHECK_OSABI=no'
|
||||
create: yes
|
||||
- name: Install NetBSD CLI packages
|
||||
- name: Install CLI packages
|
||||
become: true
|
||||
pkgin:
|
||||
name: git,gnupg2,mc,mozilla-rootcerts-openssl,nmap,openvpn,pkgin,py37-pip,python37,sqlite3,sudo,tmux,zsh
|
||||
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'
|
6
roles/netbsd/tasks/packages-gui.yml
Normal file
6
roles/netbsd/tasks/packages-gui.yml
Normal 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
|
9
roles/netbsd/tasks/sudo.yml
Normal file
9
roles/netbsd/tasks/sudo.yml
Normal 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'
|
|
@ -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
|
||||
become: true
|
||||
lineinfile:
|
6
roles/ubuntu/tasks/main.yml
Normal file
6
roles/ubuntu/tasks/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- include: packages-cli.yml
|
||||
- include: packages-gui.yml
|
||||
when: gui == true
|
||||
- include: modules.yml
|
||||
- include: ssh.yml
|
13
roles/ubuntu/tasks/modules.yml
Normal file
13
roles/ubuntu/tasks/modules.yml
Normal 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
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Install Debian CLI packages
|
||||
- name: Install CLI packages
|
||||
become: true
|
||||
apt:
|
||||
name: '{{ packages }}'
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Install Ubuntu GUI packages
|
||||
- name: Install GUI packages
|
||||
become: true
|
||||
apt:
|
||||
name: '{{ packages }}'
|
20
roles/ubuntu/tasks/ssh.yml
Normal file
20
roles/ubuntu/tasks/ssh.yml
Normal 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
|
Loading…
Reference in a new issue