Skip to content

Commit

Permalink
system upgrade patch
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDoobPG authored and MrDoobPG committed Sep 15, 2019
1 parent 4b6acd0 commit ef60576
Show file tree
Hide file tree
Showing 13 changed files with 440 additions and 3 deletions.
4 changes: 2 additions & 2 deletions menu/pg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
- { role: update, tags: ['update'] }
- { role: rcloneinstall, tags: ['rcloneinstall'] }
- { role: mergerfs, tags: ['mergerfs'] }
- { role: gcloud_sdk, tags: ['gcloud_sdk'] }

- { role: gcloud_sdk, tags: ['gcloud_sdk'] }
- { role: system, tags: ['system'] }
1 change: 0 additions & 1 deletion menu/roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@
- switch == "on"
- check.stat.exists == True


- name: Check if docker is running and works
command: systemctl status "{{ item }}"
with_items:
Expand Down
20 changes: 20 additions & 0 deletions menu/roles/mergerfs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
######################################################################
##
## some of this parts are cloned from Cloudbox
## many thanks to all the devs from Cloudbox
##
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
##
## Credits fly to l3uddz and the CBox Boys "!"
## Mod from MrDoob ( main dev of PTS )
## based of PGblitz v8.7.5
#######################################################################

---
- name: Credits
msg: |
some of this parts are cloned from Cloudbox
many thanks to all the devs from Cloudbox
- name: "MergerFS | Get URL for latest mergerfs release"
shell: |
curl -s https://api.github.com/repos/trapexit/mergerfs/releases/latest \
Expand All @@ -20,6 +37,9 @@
deb: "{{ mergerfs_download_url.stdout | default('{{ mergerfs_download_url_backup }}') }}"
state: present




- name: Check if pgunion is running and works
command: systemctl status "{{ item }}"
with_items:
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions menu/roles/system/files/etc/rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
15 changes: 15 additions & 0 deletions menu/roles/system/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#########################################################################
# Title: Cloudbox: System Handler #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: update locales
command: dpkg-reconfigure --frontend noninteractive locales

- name: update tzdata
command: dpkg-reconfigure --frontend noninteractive tzdata
36 changes: 36 additions & 0 deletions menu/roles/system/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#########################################################################
# Title: Cloudbox: System Role #
# Author(s): l3uddz, desimaniac, EnorMOZ #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: APT tasks
include_tasks: "subtasks/apt.yml"

- name: Network tasks
import_tasks: "subtasks/network.yml"

- name: SYSCTL tasks
include_tasks: "subtasks/sysctl.yml"

- name: Check if intel_pstate directory exists.
stat:
path: /sys/devices/system/cpu/intel_pstate
register: p

- name: CPU Frequency tasks
include_tasks: "subtasks/cpufrequency.yml"
when: p.stat.isdir is defined and p.stat.isdir

- name: Remove CPU Power task
include_tasks: "subtasks/remove_cpupower.yml"

- name: Set Locale task
import_tasks: "subtasks/locale.yml"
tags: set-locale

- meta: flush_handlers
65 changes: 65 additions & 0 deletions menu/roles/system/tasks/subtasks/apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#########################################################################
# Title: System: APT Tasks #
# Author(s): l3uddz, desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Set env variables
set_fact:
env_vars:
DEBIAN_FRONTEND: noninteractive
DEBIAN_PRIORITY: critical

- name: Fix any potential dpkg issues
shell: dpkg --configure --pending

- name: Kill existing apt and apt-get
shell: "killall apt apt-get >/dev/null 2>&1 || :"
ignore_errors: yes

- name: Fix any potential apt issues
shell: apt-get install --fix-broken --quiet --yes
environment: "{{ env_vars }}"
ignore_errors: yes

- name: Install required packages
apt:
state: present
name:
- apt-utils
- byobu

- name: APT update
apt:
update_cache: yes
ignore_errors: yes

# https://serverfault.com/a/839563
# https://raymii.org/s/tutorials/Silent-automatic-apt-get-upgrade.html
- name: APT upgrade
shell: apt-get upgrade --quiet --yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
environment: "{{ env_vars }}"
when: not continuous_integration
ignore_errors: yes

# https://serverfault.com/a/839563
# https://raymii.org/s/tutorials/Silent-automatic-apt-get-upgrade.html
- name: APT dist-upgrade
shell: apt-get dist-upgrade --quiet --yes --allow-unauthenticated -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
environment: "{{ env_vars }}"
when: not continuous_integration
ignore_errors: yes

- name: Remove useless packages from the cache
apt:
autoclean: yes
ignore_errors: yes

- name: Remove dependencies that are no longer required
apt:
autoremove: yes
ignore_errors: yes
68 changes: 68 additions & 0 deletions menu/roles/system/tasks/subtasks/cpufrequency.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#########################################################################
# Title: System: CPU Frequency Tasks #
# Author(s): l3uddz, EnorMOZ, desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Install 'cpufrequtils'
apt:
name: cpufrequtils
state: present

- name: Install 'linux-tools' for Ubuntu
apt:
state: present
name:
- linux-tools-common
- linux-tools-generic
when: ansible_distribution == 'Ubuntu'

- name: Install 'linux-tools' for Debian
apt:
name: linux-tools
state: present
when: ansible_distribution == 'Debian'

- name: "Install linux-tools-{{ ansible_kernel }}"
shell: "apt-get install -qq $(apt-cache search -n linux-tools-{{ ansible_kernel }} | awk '{print $1}' | tail -n 1)"
ignore_errors: yes

- name: Check /etc/default/cpufrequtils exists
stat:
path: /etc/default/cpufrequtils
register: cpufrequtils_file

- name: Create /etc/default/cpufrequtils
file:
path: /etc/default/cpufrequtils
state: touch
when: not cpufrequtils_file.stat.exists

- name: Set CPU frequency scaling governor to performance
lineinfile:
path: "/etc/default/cpufrequtils"
regexp: '^GOVENOR\s?='
line: 'GOVENOR="performance"'
state: present

- name: Set CPU frequency scaling governor to performance
lineinfile:
path: "/etc/default/cpufrequtils"
regexp: '^GOVERNOR\s?='
line: 'GOVERNOR="performance"'
state: present

- name: Ensure governor is enabled
lineinfile:
path: "/etc/default/cpufrequtils"
regexp: '^ENABLE\s?='
line: 'ENABLE="true"'
state: present

- name: Disable ondemand CPU frequency scaling daemon
shell: "update-rc.d ondemand disable"
when: ansible_distribution_version == "16.04"
36 changes: 36 additions & 0 deletions menu/roles/system/tasks/subtasks/locale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#########################################################################
# Title: System: Locale Tasks #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: "Install 'locales'"
apt:
name: locales
state: present

- name: "Generate 'locales'"
locale_gen:
name: "en_US.UTF-8"
state: present
notify: update locales

- name: "Uncomment 'LANG='"
replace:
path: "/etc/default/locale"
regexp: '^#(LANG=.*)'
replace: '\1'

- name: "Set Default 'locale'"
ini_file:
path: "/etc/default/locale"
section: null
option: "LANG"
value: "en_US.UTF-8"
state: present
no_extra_spaces: yes
notify: update locales
63 changes: 63 additions & 0 deletions menu/roles/system/tasks/subtasks/network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#########################################################################
# Title: System: Network Tasks #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Install common packages
apt:
state: present
name:
- vnstat
- pciutils

- block:

- name: Check for '/etc/vnstat.conf'
stat:
path: "/etc/vnstat.conf"
register: vnstat_conf

- name: Set vnstat to proper default interface
lineinfile:
path: "/etc/vnstat.conf"
regexp: '(Interface)\s?.*'
line: '\1 "{{ ansible_default_ipv4.interface }}"'
state: present
backrefs: yes
when: (vnstat_conf.stat.exists)

- name: Import rc.local if missing
copy:
src: "etc/rc.local"
dest: "/etc/rc.local"
owner: "root"
group: "root"
mode: 0755
force: no

- name: Get nic info
shell: lspci
register: nic

- name: Disable TSO / TX
blockinfile:
path: "/etc/rc.local"
state: present
create: no
marker: "### {mark} CLOUDBOX MANAGED BLOCK ###"
block: |
/sbin/ifconfig {{ ansible_default_ipv4.interface }} txqueuelen 10000
ethtool -G {{ ansible_default_ipv4.interface }} rx 4096 tx 4096
ethtool -K {{ ansible_default_ipv4.interface }} tso off tx off
insertbefore: "^exit 0"
owner: "root"
group: "root"
mode: 0755
when: ('I218' in nic.stdout) or ('I219' in nic.stdout)

when: (ansible_default_ipv4 is defined) and (ansible_default_ipv4.type == "ether")
29 changes: 29 additions & 0 deletions menu/roles/system/tasks/subtasks/remove_cpupower.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#########################################################################
# Title: System: Remove CPU Power Tasks #
# Author(s): desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Check if cpupower.service exists
stat:
path: "/etc/systemd/system/cpupower.service"
register: cpupower_service

- name: Stop and disable cpupower.service
systemd:
state: stopped
name: cpupower
daemon_reload: yes
enabled: no
ignore_errors: yes
when: cpupower_service.stat.exists

- name: Delete cpupower.service
file:
path: /etc/systemd/system/cpupower.service
state: absent
when: cpupower_service.stat.exists
Loading

0 comments on commit ef60576

Please sign in to comment.