diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml new file mode 100644 index 00000000..89482b6e --- /dev/null +++ b/.github/workflows/ansible-deployments.yml @@ -0,0 +1,34 @@ +name: Test contest deployment (ansible scripts) + +on: [push,pull_request] + +jobs: + test_domjudge_role: + strategy: + matrix: + os: [22.04, 20.04] + role: [domserver] + runs-on: ubuntu-20.04 + container: ubuntu:${{ matrix.os }} + + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: remove package + run: apt update; apt purge mysql-server -y + - name: Install ansible lint tools + SQL server + run: apt install ansible sudo make -y + - run: mount + #mariadb-server -y + #- name: Check that mariadb works + # if: ${{ matrix.os == '22.04' }} + # run: service mariadb restart; service mariadb status + - name: Setup the hosts file + working-directory: ./icpc-wf/ansible + run: sed -i 's/\[${{ matrix.role }}\]/[removed]/g' hosts; printf '\n[${{ matrix.role }}]\ngithub-action\tansible_host=localhost ansible_connection=local' >> hosts + - name: Generate insecure credentials + working-directory: ./icpc-wf/ansible + run: mv group_vars/all/secret.yml.example group_vars/all/secret.yml + - name: Run the default deployment method + working-directory: ./icpc-wf/ansible + run: make ${{ matrix.role }} diff --git a/icpc-wf/ansible/group_vars/all/all.yml b/icpc-wf/ansible/group_vars/all/all.yml index 47de5730..75787d11 100644 --- a/icpc-wf/ansible/group_vars/all/all.yml +++ b/icpc-wf/ansible/group_vars/all/all.yml @@ -18,6 +18,9 @@ DOMSERVER_URL: "{{DOMSERVER}}" DOMSERVER_SSL_CERT: /etc/ssl/certs/domserver.crt DOMSERVER_SSL_KEY: /etc/ssl/private/domserver.key +# Set this to true when you are using an image with a graphical desktop +GRAPHICAL: false + # Set this to true when you are using the ICPC World Finals Contest Image ICPC_IMAGE: false diff --git a/icpc-wf/ansible/judgehost.yml b/icpc-wf/ansible/judgehost.yml index b280db72..fe759dc6 100644 --- a/icpc-wf/ansible/judgehost.yml +++ b/icpc-wf/ansible/judgehost.yml @@ -41,11 +41,14 @@ tags: prometheus_target_all when: GRAFANA_MONITORING pre_tasks: + - name: Get current services + service_facts: - name: Disable all cores service: name="domjudge-judgedaemon@{{item}}" state=stopped with_sequence: start=0 end={{ ansible_processor_vcpus }} format=domjudge-judgedaemon@%1x + when: '"domjudge-judgedaemon@0.service" in services' tasks: - name: add autostart shortcuts template: diff --git a/icpc-wf/ansible/mysqlhandler.yml b/icpc-wf/ansible/mysqlhandler.yml new file mode 100644 index 00000000..f03e12c9 --- /dev/null +++ b/icpc-wf/ansible/mysqlhandler.yml @@ -0,0 +1,5 @@ +--- +# Define here handlers associated to this role. + +- name: restart mysql + command: ls diff --git a/icpc-wf/ansible/roles/domjudge_user/tasks/main.yml b/icpc-wf/ansible/roles/domjudge_user/tasks/main.yml index 0f448a67..60fc251d 100644 --- a/icpc-wf/ansible/roles/domjudge_user/tasks/main.yml +++ b/icpc-wf/ansible/roles/domjudge_user/tasks/main.yml @@ -43,6 +43,7 @@ line: 'AutomaticLoginEnable=true' create: yes notify: restart gdm + when: GRAPHICAL - name: Automatically login domjudge user lineinfile: @@ -50,6 +51,7 @@ regexp: 'AutomaticLogin=' line: 'AutomaticLogin=domjudge' notify: restart gdm + when: GRAPHICAL - name: make sure autostart directory exists file: dest=/home/domjudge/.config/autostart state=directory owner=domjudge group=domjudge diff --git a/icpc-wf/ansible/roles/system_fixes/tasks/main.yml b/icpc-wf/ansible/roles/system_fixes/tasks/main.yml index 5743386e..9306e23e 100644 --- a/icpc-wf/ansible/roles/system_fixes/tasks/main.yml +++ b/icpc-wf/ansible/roles/system_fixes/tasks/main.yml @@ -28,3 +28,4 @@ - name: Force enable alt-tab for switching windows copy: src=dconf/ dest=/etc/dconf/ notify: update dconf + when: GRAPHICAL