diff --git a/icpc-wf/ansible/domserver.yml b/icpc-wf/ansible/domserver.yml index 5d9e6a1f..5b9a1d66 100644 --- a/icpc-wf/ansible/domserver.yml +++ b/icpc-wf/ansible/domserver.yml @@ -12,12 +12,6 @@ - name: include global variables include_vars: variables.yml - - name: install public key - authorized_key: - user: icpc2017 - state: present - key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCsQqeY+oNN50KjnHQDg0U1nrOQoQxibZBgHs7oA26Tmg3tsp46+jNNZoB9WWwQZff/bEusmn6VKy5MVx8syXvXDUoLc6MhHn4mxZuOJ8EYidoAbO5DGIGZFgSHJ1sj8cp+4Wc4jYaXLtatsWaUCa1sLnztL7+9Dtz7lYl/R4/MtAHnyICwSX+G1Q8gqZuq8ftmmbVAEj6GL280F06iFfzZNPAvo7fAzwV76cvWFOAn5HnffKVM7ckryRmg5C7y3z5ygIRURDDbmhcwKw9/I7T0fckkjRbAb0x75topF7c1ihim4dOQrzLpB5U7Ag82ov+ZXyaxsq60jwdNm2mePWo+hzhK6lA44rbx2em7IW+NNXAQrPsfInp2lA+3vCRcsiF+cIbGilkXHMB/gNH6tu+jFa6ZxYk9dhys6uajduINOmvunLIMPIZXU1/A6Hcb+W1L4HFW2v5k80wScbR/84Cc14jARJ6UVa91KZUDvuJ3M1cv20eWoiWBjBgmLZXVnsLDW0ZfyVa9id/IzHpVcV+1zEgMdJSbF6rcZBwp40w41lmBNUS0GssO5HA2bw2TN6Rf/HyAo5R3Kc++apPxmPA34Z6FaafU0S8QzUg/khxLtxmxcc32CwxHHbnz1GQX4Nf3yIKuebc06O7Paul0kHbDGWLAQ05ghWQhSElEJcjRRw== kjohnson - - name: Allow 'sudo' group to have passwordless sudo lineinfile: dest: /etc/sudoers @@ -27,15 +21,29 @@ - name: create domjudge user user: name: domjudge + + - name: set timezone + timezone: + name: Europe/London + + - name: set PHP timezone + lineinfile: + dest: /etc/php/7.0/apache2/php.ini + state: present + regexp: 'date\.timezone\s*=' + line: 'date.timezone = Europe/London' + - name: install required packages apt: pkg={{item}} state=present with_items: - autoconf - automake + - curl - git - gcc - g++ - make + - ntp - zip - unzip - mysql-server @@ -57,26 +65,11 @@ - libmagic-dev - composer - - name: enable php modules - command: phpenmod {{item}} - args: - creates: /etc/php/7.0/apache2/conf.d/20-{{item}}.ini - with_items: - - mcrypt - - zip - - name: update systemd so mysql has bigger limits - copy: src=files/mysql.override.cnf dest=/etc/systemd/system/mysql.service.d/override.conf - name: update mysql max connections lineinfile: regexp: '^.*max_connections' line: 'max_connections = 1000' - dest: /etc/mysql/mysql.conf.d/mysqld.cnf - notify: restart mysql - - name: update mysql max open files - lineinfile: - regexp: '^.*open_files_limit' - line: 'open_files_limit = 10000' - dest: /etc/mysql/mysql.conf.d/mysqld.cnf + dest: /etc/mysql/mariadb.conf.d/50-server.cnf notify: restart mysql - name: configure git as domjudge user @@ -86,42 +79,33 @@ ini_file: dest=/home/domjudge/.gitconfig section=user option="{{item.name}}" value="{{item.value}}" with_items: - { name: 'email', value: 'team@domjudge.org' } - - { name: 'name', value: 'DOMjudge @ ICPC WF' } + - { name: 'name', value: 'DOMjudge @ NWERC' } - - name: create bare repository + - name: create domjudge git repo become: yes become_user: domjudge - git: bare=yes repo=http://github.com/domjudge/domjudge dest=/home/domjudge/domjudge-bare.git - register: create_bare_repo + git: repo=https://github.com/DOMjudge/domjudge.git dest={{DJDIR}} version=master update=no + register: create_repo - - name: create working copy from the bare repo +# Update separately to preserve local (un)committed changes: + - name: update domjudge git repo become: yes become_user: domjudge - git: repo=/home/domjudge/domjudge-bare.git dest={{DJDIR}} version=ICPC-live - when: create_bare_repo.changed - - - name: Copy in composer dependencies - #copy: src=files/lib/vendor/ dest={{DJDIR}}/lib/vendor/ owner=domjudge group=domjudge - become: no - tags: sync - synchronize: - src: files/lib/vendor/ - dest: "{{DJDIR}}/lib/vendor/" - owner: no - use_ssh_args: true - rsync_path: sudo rsync - - - name: fix permissions on composer directory - file: path="{{DJDIR}}/lib/vendor/" group=domjudge owner=domjudge recurse=yes + shell: cd {{DJDIR}} && git stash && git pull --rebase && git stash pop || true - name: run maintainer-conf become: yes become_user: domjudge - command: make maintainer-conf CONFIGURE_FLAGS='--disable-doc-build' + command: make maintainer-conf register: dj_configured args: chdir: "{{DJDIR}}" creates: "{{DJDIR}}/paths.mk" + + - name: clear symfony cache + command: rm -rf {{DJDIR}}/webapp/var/cache/dev {{DJDIR}}/webapp/var/cache/prod + when: dj_configured.changed + - name: build domjudge become: yes become_user: domjudge @@ -129,7 +113,7 @@ when: dj_configured.changed - name: fix permissions on things - file: path={{DJDIR}}/etc/dbpasswords.secret group=www-data mode=g+r + shell: make -C {{DJDIR}} maintainer-postinstall-permissions - name: copy domjudge-sudoers file copy: remote_src=True src={{DJDIR}}/etc/sudoers-domjudge dest=/etc/sudoers.d/domjudge mode=0440 owner=root group=root @@ -149,13 +133,6 @@ dest: "{{DJDIR}}/webapp/web/style.css" when: BACKGROUND_COLOR is defined - - name: create a self signed cert - shell: "openssl req -newkey rsa:2048 -new -x509 -days 365 -nodes -out /etc/ssl/certs/domjudge.crt -keyout /etc/ssl/private/domjudge.pem -subj /CN={{ansible_hostname}}" - args: - creates: /etc/ssl/private/domjudge.pem - #- name: update apache to use new cert - # lineinfile: - - name: Update servername in apache config lineinfile: insertbefore: '^#Global config' @@ -167,20 +144,30 @@ notify: restart apache2 - name: enable apache2 conf for domjudge - file: src=/etc/apache2/conf-available/domjudge.conf dest=/etc/apache2/conf-enabled/domjudge.conf state=link + file: + src: /etc/apache2/conf-available/domjudge.conf + dest: /etc/apache2/conf-enabled/domjudge.conf + state: link notify: restart apache2 - name: enable apache2 modules - apache2_module: name=ssl state=present + apache2_module: name={{item}} state=present + with_items: + - ssl + - php7.0 notify: restart apache2 - - name: disable default apache site - file: state=absent path=/etc/apache2/sites-enabled/000-default + - name: apache2 http redirect + lineinfile: + dest: /etc/apache2/sites-available/000-default.conf + state: present + insertafter: '^\s*DocumentRoot\s' + line: ' Redirect permanent / {{DOMSERVER}}/' notify: restart apache2 - - name: enable default-ssl apache site - file: src=/etc/apache2/sites-available/default-ssl.conf dest=/etc/apache2/sites-enabled/000-default-ssl state=link + - name: enable apache2 default site + file: + src: /etc/apache2/sites-available/000-default.conf + dest: /etc/apache2/sites-enabled/000-default.conf + state: link notify: restart apache2 - - - diff --git a/icpc-wf/ansible/files/composer.json b/icpc-wf/ansible/files/composer.json deleted file mode 100644 index 352e0cb1..00000000 --- a/icpc-wf/ansible/files/composer.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "domjudge/domjudge", - "description": "DOMjudge Programming Contest Control System", - "homepage": "https://www.domjudge.org", - "license": "GPL-2.0+", - "require": { - "ext-curl": "*", - "ext-gmp": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-mcrypt": "*", - "ext-mysqli": "*", - "jumbojett/openid-connect-php": "0.1.*", - "mustangostang/spyc": "0.5.*", - "php": ">= 5.4", - "ircmaxell/password-compat": "*", - "twig/twig": "~1.0" - }, - "config": { - "vendor-dir": "lib/vendor" - } -} diff --git a/icpc-wf/ansible/files/composer.lock b/icpc-wf/ansible/files/composer.lock deleted file mode 100644 index cda2054c..00000000 --- a/icpc-wf/ansible/files/composer.lock +++ /dev/null @@ -1,305 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "422b11f9511af576f6fe868b10e969fb", - "content-hash": "c136ca5847e64d970f6d05f337ba746b", - "packages": [ - { - "name": "ircmaxell/password-compat", - "version": "v1.0.4", - "source": { - "type": "git", - "url": "https://github.com/ircmaxell/password_compat.git", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "type": "library", - "autoload": { - "files": [ - "lib/password.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" - } - ], - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "homepage": "https://github.com/ircmaxell/password_compat", - "keywords": [ - "hashing", - "password" - ], - "time": "2014-11-20 16:49:30" - }, - { - "name": "jumbojett/openid-connect-php", - "version": "0.1.0", - "source": { - "type": "git", - "url": "https://github.com/jumbojett/OpenID-Connect-PHP.git", - "reference": "b9624675d5cfe78c07511314d91af02fd332ee25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jumbojett/OpenID-Connect-PHP/zipball/b9624675d5cfe78c07511314d91af02fd332ee25", - "reference": "b9624675d5cfe78c07511314d91af02fd332ee25", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "php": ">=5.2", - "phpseclib/phpseclib": "~0.3.10" - }, - "type": "library", - "autoload": { - "classmap": [ - "OpenIDConnectClient.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "description": "Bare-bones OpenID Connect client", - "time": "2016-03-04 02:50:16" - }, - { - "name": "mustangostang/spyc", - "version": "0.5.1", - "source": { - "type": "git", - "url": "https://github.com/mustangostang/spyc.git", - "reference": "dc4785b4d7227fd9905e086d499fb8abfadf9977" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mustangostang/spyc/zipball/dc4785b4d7227fd9905e086d499fb8abfadf9977", - "reference": "dc4785b4d7227fd9905e086d499fb8abfadf9977", - "shasum": "" - }, - "require": { - "php": ">=5.3.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.5.x-dev" - } - }, - "autoload": { - "files": [ - "Spyc.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT License" - ], - "authors": [ - { - "name": "mustangostang", - "email": "vlad.andersen@gmail.com" - } - ], - "description": "A simple YAML loader/dumper class for PHP", - "homepage": "https://github.com/mustangostang/spyc/", - "keywords": [ - "spyc", - "yaml", - "yml" - ], - "time": "2013-02-21 10:52:01" - }, - { - "name": "phpseclib/phpseclib", - "version": "0.3.10", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d15bba1edcc7c89e09cc74c5d961317a8b947bf4", - "reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4", - "shasum": "" - }, - "require": { - "php": ">=5.0.0" - }, - "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "~4.0", - "sami/sami": "~2.0", - "squizlabs/php_codesniffer": "~1.5" - }, - "suggest": { - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", - "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-0": { - "Crypt": "phpseclib/", - "File": "phpseclib/", - "Math": "phpseclib/", - "Net": "phpseclib/", - "System": "phpseclib/" - }, - "files": [ - "phpseclib/Crypt/Random.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "phpseclib/" - ], - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ], - "time": "2015-01-28 21:50:33" - }, - { - "name": "twig/twig", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "3c6c0033fd3b5679c6e1cb60f4f9766c2b424d97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/3c6c0033fd3b5679c6e1cb60f4f9766c2b424d97", - "reference": "3c6c0033fd3b5679c6e1cb60f4f9766c2b424d97", - "shasum": "" - }, - "require": { - "php": ">=5.2.7" - }, - "require-dev": { - "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.27-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "http://twig.sensiolabs.org/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ], - "time": "2016-10-25 19:17:17" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "ext-curl": "*", - "ext-gmp": "*", - "ext-json": "*", - "ext-mbstring": "*", - "ext-mcrypt": "*", - "ext-mysqli": "*", - "php": ">= 5.4" - }, - "platform-dev": [] -} diff --git a/icpc-wf/ansible/files/composer.phar b/icpc-wf/ansible/files/composer.phar deleted file mode 100755 index 35779317..00000000 Binary files a/icpc-wf/ansible/files/composer.phar and /dev/null differ diff --git a/icpc-wf/ansible/files/disable-turboboost_ht b/icpc-wf/ansible/files/disable-turboboost_ht new file mode 120000 index 00000000..94a598c0 --- /dev/null +++ b/icpc-wf/ansible/files/disable-turboboost_ht @@ -0,0 +1 @@ +../../disable-turboboost_ht \ No newline at end of file diff --git a/icpc-wf/ansible/files/domjudge-bare.git b/icpc-wf/ansible/files/domjudge-bare.git deleted file mode 120000 index 5c6e8eec..00000000 --- a/icpc-wf/ansible/files/domjudge-bare.git +++ /dev/null @@ -1 +0,0 @@ -/home/domjudge/domjudge-bare.git/ \ No newline at end of file diff --git a/icpc-wf/ansible/files/icpc-kotlinc_1.1.4-3~icpc1_all.deb b/icpc-wf/ansible/files/icpc-kotlinc_1.1.4-3~icpc1_all.deb new file mode 100644 index 00000000..35ff41c2 Binary files /dev/null and b/icpc-wf/ansible/files/icpc-kotlinc_1.1.4-3~icpc1_all.deb differ diff --git a/icpc-wf/ansible/files/lib-vendor.tgz b/icpc-wf/ansible/files/lib-vendor.tgz deleted file mode 100644 index 30ba372e..00000000 Binary files a/icpc-wf/ansible/files/lib-vendor.tgz and /dev/null differ diff --git a/icpc-wf/ansible/files/tune_cpu.service b/icpc-wf/ansible/files/tune_cpu.service new file mode 100644 index 00000000..9431a617 --- /dev/null +++ b/icpc-wf/ansible/files/tune_cpu.service @@ -0,0 +1,7 @@ +[Unit] +Description=Tune CPU cores: disable turboboost, downclocking, etc. + +[Service] +Type=oneshot +ExecStart=/home/domjudge/domjudge/bin/disable-turboboost_ht +RemainAfterExit=true diff --git a/icpc-wf/ansible/hosts b/icpc-wf/ansible/hosts index a5ca705d..a0e754d5 100644 --- a/icpc-wf/ansible/hosts +++ b/icpc-wf/ansible/hosts @@ -2,13 +2,11 @@ localhost ansible_user=root [judgehost] -#domjudge-judgehost1 ansible_host=10.2.2.192 ansible_user=root -domjudge-judgehost2 ansible_host=10.2.2.193 ansible_user=root -#domjudge-judgehost3 ansible_host=10.2.2.194 ansible_user=root -domjudge-judgehost4 ansible_host=10.2.2.195 ansible_user=root -domjudge-judgehost5 ansible_host=10.2.2.196 ansible_user=root -domjudge-judgehost6 ansible_host=10.2.2.197 ansible_user=root -domjudge-judgehost7 ansible_host=10.2.2.198 ansible_user=root -domjudge-judgehost8 ansible_host=10.2.2.199 ansible_user=root -domjudge-judgehost9 ansible_host=10.2.2.200 ansible_user=root -domjudge-judgehost10 ansible_host=10.2.2.201 ansible_user=root +judge-a ansible_host=172.25.37.12 ansible_user=root +judge-b ansible_host=172.25.37.13 ansible_user=root +judge-c ansible_host=172.25.37.14 ansible_user=root +judge-d ansible_host=172.25.37.15 ansible_user=root +judge-e ansible_host=172.25.37.16 ansible_user=root +judge-f ansible_host=172.25.37.17 ansible_user=root +judge-g ansible_host=172.25.37.18 ansible_user=root +judge-h ansible_host=172.25.37.19 ansible_user=root diff --git a/icpc-wf/ansible/judgehost.yml b/icpc-wf/ansible/judgehost.yml index ea67c26e..bbb27184 100644 --- a/icpc-wf/ansible/judgehost.yml +++ b/icpc-wf/ansible/judgehost.yml @@ -3,6 +3,8 @@ - name: setup judgehost hosts: judgehost become: yes + vars: + KOTLINDEB: 'icpc-kotlinc_1.1.4-3~icpc1_all.deb' handlers: - name: update-grub command: update-grub @@ -26,27 +28,9 @@ - name: create domjudge-run group group: name=domjudge-run state=present - - name: fix apt sources list - tags: packages - replace: - dest: /etc/apt/sources.list - regexp: 'pc2cancer\.ecs\.csus\.edu' - replace: 'packages' - - - name: add packages to hosts file - tags: packages - lineinfile: - dest: /etc/hosts - regexp: '^10\.3\.3\.209' - line: "10.3.3.209 packages" - - - name: update ssl certificate for packages - tags: packages - copy: src=files/packages.pem dest=/usr/local/share/ca-certificates/packages.crt - notify: update-ca-certificates - - - meta: flush_handlers - tags: packages + - name: set timezone + timezone: + name: Europe/London - name: install required packages tags: packages @@ -54,28 +38,42 @@ with_items: - autoconf - automake + - curl - git - gcc - g++ + - openjdk-8-jdk-headless - make - zip - unzip + - ntp - php - php-cli - php-gd - php-curl - php-mysql - php-json + - php-xml - php-zip - php-mbstring + - pypy - bsdmainutils - libcgroup-dev - libcurl4-gnutls-dev - libjsoncpp-dev - libmagic-dev + - linuxdoc-tools - composer - debootstrap + - name: copy ICPC kotlin deb package + copy: src=files/{{KOTLINDEB}} dest=/root/ + register: copy_debs + + - name: install ICPC kotlin deb package + apt: deb=/root/{{KOTLINDEB}} + when: copy_debs.changed + - name: configure git as domjudge user become: yes become_user: domjudge @@ -83,40 +81,13 @@ ini_file: dest=/home/domjudge/.gitconfig section=user option="{{item.name}}" value="{{item.value}}" with_items: - { name: 'email', value: 'team@domjudge.org' } - - { name: 'name', value: 'DOMjudge @ ICPC WF' } - - #- name: create bare repository - # become: yes - # become_user: domjudge - # git: bare=yes repo=http://github.com/domjudge/domjudge dest=/home/domjudge/domjudge-bare.git - # register: create_bare_repo + - { name: 'name', value: 'DOMjudge @ NWERC' } - name: sync domjudge git repo from this workstation to the host - register: create_bare_repo - become: no - synchronize: - src: files/domjudge-bare.git/ - dest: /home/domjudge/domjudge-bare.git - use_ssh_args: true - rsync_path: sudo rsync - - - - name: create working copy from the bare repo become: yes become_user: domjudge - git: repo=/home/domjudge/domjudge-bare.git dest={{DJDIR}} version=ICPC-live - when: create_bare_repo.changed - - - name: Copy in composer dependencies - become: no - synchronize: - src: files/lib/vendor/ - dest: "{{DJDIR}}/lib/vendor/" - use_ssh_args: true - rsync_path: sudo rsync - - - name: fix permissions on composer directory - file: path="{{DJDIR}}/lib/vendor/" group=domjudge owner=domjudge recurse=yes + git: repo={{DOMSERVER_IP}}:domjudge dest={{DJDIR}} version=master + register: create_repo - name: run maintainer-conf become: yes @@ -134,7 +105,7 @@ become: yes become_user: domjudge shell: make dist && make maintainer-install chdir={{DJDIR}} - when: create_bare_repo.changed or dj_configured.changed or not judgedaemon_binary.stat.exists + when: create_repo.changed or dj_configured.changed or not judgedaemon_binary.stat.exists - name: fix permissions on things file: path={{DJDIR}}/etc/dbpasswords.secret group=www-data mode=g+r @@ -151,12 +122,13 @@ dest: /etc/hosts regexp: '^.*domserver$' line: "{{DOMSERVER_IP}} domserver" + - name: install server certificate - copy: src=files/domserver.crt dest=/usr/local/share/ca-certificates/domserver.crt + copy: src=/etc/ssl/certs/ukiepc-judge.bath.ac.uk.pem dest=/etc/ssl/certs/ukiepc-judge.bath.ac.uk.pem notify: update-ca-certificates - name: create chroot - command: "{{DJDIR}}/misc-tools/dj_make_chroot" + shell: "{{DJDIR}}/misc-tools/dj_make_chroot -y -i openjdk-8-jdk-headless,pypy -l /root/{{KOTLINDEB}}" args: creates: "/chroot/domjudge" @@ -168,25 +140,29 @@ line: 'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash cgroup_enable=memory swapaccount=1"' notify: update-grub + - name: copy script to disable turboboost etc. + copy: src=files/disable-turboboost_ht dest={{DJDIR}}/bin/ mode=0755 - name: copy systemd unit files for starting judgedaemon copy: src=files/judgedaemon.service dest=/etc/systemd/system/ tags: updateservice + - name: copy systemd unit for creating cgroups copy: src=files/create_cgroups.service dest=/etc/systemd/system/ + - name: copy systemd unit for tuning cpu + copy: src=files/tune_cpu.service dest=/etc/systemd/system/ + - name: enable the services we just copied service: name={{item}} enabled=yes with_items: - judgedaemon - create_cgroups + - tune_cpu - - name: make sure directory exists - file: dest=/home/domjudge/.config/autostart state=directory owner=domjudge group=domjudge - tags: fix_autostart - - - name: add shortcut to autostart terminal tailing the log file - copy: src=files/taillog.desktop dest=/home/domjudge/.config/autostart/taillog.desktop owner=domjudge group=domjudge mode=0755 - - - name: add shortcut to autostart screen rotation - copy: src=files/rotate.desktop dest=/home/domjudge/.config/autostart/rotate.desktop owner=domjudge group=domjudge mode=0755 + - name: restart services + service: name={{item}} state=restarted + with_items: + - create_cgroups + - tune_cpu + - judgedaemon diff --git a/icpc-wf/disable-turboboost_ht b/icpc-wf/disable-turboboost_ht index 516b391f..4572a4df 100755 --- a/icpc-wf/disable-turboboost_ht +++ b/icpc-wf/disable-turboboost_ht @@ -1,35 +1,28 @@ #!/bin/bash -e -# let's disable threads on different cores -cpu0=$(cat /sys/devices/system/cpu/cpu0/topology/core_id) -cpu1=$(cat /sys/devices/system/cpu/cpu1/topology/core_id) -cpu2=$(cat /sys/devices/system/cpu/cpu2/topology/core_id) -cpu3=$(cat /sys/devices/system/cpu/cpu3/topology/core_id) - -# set governor to performance -echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor -echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor -echo performance > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor -echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor - -# do not allow changes later on -chmod -w /sys/devices/system/cpu/cpu?/cpufreq/scaling_governor - -# disable last thread -echo 0 > /sys/devices/system/cpu/cpu3/online - -# disable thread with different core id -if [ $cpu3 -ne $cpu2 ]; then - echo 0 > /sys/devices/system/cpu/cpu2/online -elif [ $cpu3 -ne $cpu1 ]; then - echo 0 > /sys/devices/system/cpu/cpu1/online -elif [ $cpu3 -ne $cpu0 ]; then - echo 0 > /sys/devices/system/cpu/cpu0/online -else - # found no thread with different core id - exit -1 -fi +shopt -s extglob +declare -A core_ids + +for cpu in /sys/devices/system/cpu/cpu* ; do + [[ $(basename $cpu) =~ ^cpu[0-9]+$ ]] || continue + + # Reenable stuff in case we are rerunning this script. + chmod u+w $cpu/cpufreq/scaling_governor + [ -f $cpu/online ] && echo 1 > $cpu/online + + # Set governor to performance and do not allow changes later on. + echo performance > $cpu/cpufreq/scaling_governor + chmod a-w $cpu/cpufreq/scaling_governor + + # Disable all but one thread on each core. + core_id=$(cat $cpu/topology/core_id) + if [[ ${core_ids[$core_id]} ]]; then + echo 0 > $cpu/online + else + core_ids[$core_id]=1 + fi +done # now disable turbo boost echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo