From 712f3c831d993c381b5384d89053a6d79e4570d9 Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+mvr320@users.noreply.github.com> Date: Wed, 2 Feb 2022 21:35:01 +0100 Subject: [PATCH 01/15] Test ansible scripts with default linter We use the github action runner as the machine to test against. The connection is local instead of ssh to make this simpler. The used credentials are default and insecure. Default we now assume machines without GDM to configure --- .github/workflows/ansible-deployments.yml | 28 +++++++++++++++++++ icpc-wf/ansible/group_vars/all/all.yml | 3 ++ icpc-wf/ansible/judgehost.yml | 3 ++ .../roles/domjudge_user/tasks/main.yml | 2 ++ .../ansible/roles/system_fixes/tasks/main.yml | 1 + 5 files changed, 37 insertions(+) create mode 100644 .github/workflows/ansible-deployments.yml diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml new file mode 100644 index 00000000..b7ec7cc2 --- /dev/null +++ b/.github/workflows/ansible-deployments.yml @@ -0,0 +1,28 @@ +name: Test contest deployment (ansible scripts) + +on: [push,pull_request] + +jobs: + test_domjudge_role: + strategy: + #matrix: + # os: [ubuntu-latest, ubuntu-20.04] + # role: [domserver,judgehost] + matrix: + os: [ubuntu-latest] + role: [domserver] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Install ansible lint tools + run: sudo apt update; sudo apt install ansible + - 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,} + - 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/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 From 60cdefc5f379d5312194de78ac508374190af079 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 May 2022 21:41:03 +0200 Subject: [PATCH 02/15] action already has mysql installed --- .github/workflows/ansible-deployments.yml | 18 ++++++++++++++++-- icpc-wf/ansible/mysqlhandler.yml | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 icpc-wf/ansible/mysqlhandler.yml diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index b7ec7cc2..89c6291c 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -15,8 +15,22 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v2 - - name: Install ansible lint tools - run: sudo apt update; sudo apt install ansible + - name: remove package + run: sudo apt update; sudo apt purge mysql-server + - name: Install ansible lint tools + SQL server + run: sudo apt install ansible mariadb-server + - name: Check that mariadb works + run: sudo systemctl status mariadb.service || true + - name: Check that mariadb works + run: sudo journalctl -xe || true + - name: Check that mariadb works + run: sudo service mariadb restart || true + - name: Check that mariadb works + run: sudo systemctl status mariadb.service || true + - name: Check that mariadb works + run: sudo journalctl -xe || true + - name: Fix service + run: cp icpc-wf/ansible/mysqlhandler.yml icpc-wf/ansible/roles/mysql_server/handlers/main.yml - 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 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 From f1521f63f0a97de16412d0d07c67b36f980869d9 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 May 2022 22:58:23 +0200 Subject: [PATCH 03/15] journal doesnt have entries --- .github/workflows/ansible-deployments.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 89c6291c..94f8d645 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -18,17 +18,14 @@ jobs: - name: remove package run: sudo apt update; sudo apt purge mysql-server - name: Install ansible lint tools + SQL server - run: sudo apt install ansible mariadb-server - - name: Check that mariadb works - run: sudo systemctl status mariadb.service || true - - name: Check that mariadb works - run: sudo journalctl -xe || true + run: sudo apt install ansible + - run: sudo apt install mariadb-server - name: Check that mariadb works run: sudo service mariadb restart || true - name: Check that mariadb works run: sudo systemctl status mariadb.service || true - name: Check that mariadb works - run: sudo journalctl -xe || true + run: sudo systemctl status mariadb.service || true - name: Fix service run: cp icpc-wf/ansible/mysqlhandler.yml icpc-wf/ansible/roles/mysql_server/handlers/main.yml - name: Setup the hosts file From c10bb88823c6529f936f859e6662d64b20f34d15 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 May 2022 23:06:11 +0200 Subject: [PATCH 04/15] journal doesnt have entries --- .github/workflows/ansible-deployments.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 94f8d645..fdc6e7e9 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -26,6 +26,8 @@ jobs: run: sudo systemctl status mariadb.service || true - name: Check that mariadb works run: sudo systemctl status mariadb.service || true + - run: cat /var/log/syslog + - run: ls -atrl /var/log/mysql - name: Fix service run: cp icpc-wf/ansible/mysqlhandler.yml icpc-wf/ansible/roles/mysql_server/handlers/main.yml - name: Setup the hosts file From ee83935747f1c047435f31edbda4f4fb5e698c96 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 May 2022 23:13:07 +0200 Subject: [PATCH 05/15] See if it works in a container --- .github/workflows/ansible-deployments.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index fdc6e7e9..e3718ac8 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -12,6 +12,7 @@ jobs: os: [ubuntu-latest] role: [domserver] runs-on: ${{ matrix.os }} + container: ubuntu steps: - name: Checkout repo uses: actions/checkout@v2 From c65122f9da42449e596b10d32cfd33a7a3461ff1 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 May 2022 23:16:23 +0200 Subject: [PATCH 06/15] See if it works in a container --- .github/workflows/ansible-deployments.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index e3718ac8..437ad10c 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -17,12 +17,12 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: remove package - run: sudo apt update; sudo apt purge mysql-server + run: apt update; apt purge mysql-server - name: Install ansible lint tools + SQL server - run: sudo apt install ansible - - run: sudo apt install mariadb-server + run: apt install ansible sudo + - run: apt install mariadb-server - name: Check that mariadb works - run: sudo service mariadb restart || true + run: service mariadb restart || true - name: Check that mariadb works run: sudo systemctl status mariadb.service || true - name: Check that mariadb works From a3b362fded09060659788de4dfe5e95f73e1ad04 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 1 May 2022 23:17:31 +0200 Subject: [PATCH 07/15] See if it works in a container --- .github/workflows/ansible-deployments.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 437ad10c..79ffa2e8 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -17,10 +17,10 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - name: remove package - run: apt update; apt purge mysql-server + run: apt update; apt purge mysql-server -y - name: Install ansible lint tools + SQL server - run: apt install ansible sudo - - run: apt install mariadb-server + run: apt install ansible sudo -y + - run: apt install mariadb-server -y - name: Check that mariadb works run: service mariadb restart || true - name: Check that mariadb works From 505a8b783624ade9a7540bb4ea5a5ce44070e0f3 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:06:41 +0200 Subject: [PATCH 08/15] gogo --- .github/workflows/ansible-deployments.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 79ffa2e8..99514e0b 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -22,15 +22,11 @@ jobs: run: apt install ansible sudo -y - run: apt install mariadb-server -y - name: Check that mariadb works - run: service mariadb restart || true + run: service mariadb restart - name: Check that mariadb works - run: sudo systemctl status mariadb.service || true - - name: Check that mariadb works - run: sudo systemctl status mariadb.service || true - - run: cat /var/log/syslog - - run: ls -atrl /var/log/mysql - - name: Fix service - run: cp icpc-wf/ansible/mysqlhandler.yml icpc-wf/ansible/roles/mysql_server/handlers/main.yml + run: systemctl status mariadb.service + #- name: Fix service + # run: cp icpc-wf/ansible/mysqlhandler.yml icpc-wf/ansible/roles/mysql_server/handlers/main.yml - 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 From 6f6ff358ff4a929024ea8ddb6168b7aca91d1f3b Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:17:26 +0200 Subject: [PATCH 09/15] ggo --- .github/workflows/ansible-deployments.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 99514e0b..2bd990c3 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -24,9 +24,7 @@ jobs: - name: Check that mariadb works run: service mariadb restart - name: Check that mariadb works - run: systemctl status mariadb.service - #- name: Fix service - # run: cp icpc-wf/ansible/mysqlhandler.yml icpc-wf/ansible/roles/mysql_server/handlers/main.yml + run: 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 From 48e922bcc579f77a549d7cc99e419f12f3f7df6e Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:19:30 +0200 Subject: [PATCH 10/15] gogo --- .github/workflows/ansible-deployments.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 2bd990c3..f0a37306 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -5,14 +5,12 @@ on: [push,pull_request] jobs: test_domjudge_role: strategy: - #matrix: - # os: [ubuntu-latest, ubuntu-20.04] - # role: [domserver,judgehost] matrix: - os: [ubuntu-latest] + os: [22.04, 20.04] role: [domserver] - runs-on: ${{ matrix.os }} - container: ubuntu + runs-on: ubuntu-20.04 + container: ubuntu:${{ matrix.os }} + steps: - name: Checkout repo uses: actions/checkout@v2 From 9895792684f309098d57fbf3168293ca2290fca1 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:35:00 +0200 Subject: [PATCH 11/15] GoGo3 --- .github/workflows/ansible-deployments.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index f0a37306..edded758 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -20,9 +20,9 @@ jobs: run: apt install ansible sudo -y - run: apt install mariadb-server -y - name: Check that mariadb works - run: service mariadb restart + run: service mysql restart - name: Check that mariadb works - run: service mariadb status + run: service mysql 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 From 7cb3cb01dfef5909756eb1d3a662268e11469654 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:40:02 +0200 Subject: [PATCH 12/15] gogog --- .github/workflows/ansible-deployments.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index edded758..619266f3 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -28,7 +28,7 @@ jobs: 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,} + 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 }} From 389cb815c14ae345d653274ca389c1ce0d313881 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:50:41 +0200 Subject: [PATCH 13/15] gogog5 --- .github/workflows/ansible-deployments.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 619266f3..8e8d0acf 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -17,12 +17,14 @@ jobs: - name: remove package run: apt update; apt purge mysql-server -y - name: Install ansible lint tools + SQL server - run: apt install ansible sudo -y - - run: apt install mariadb-server -y + run: apt install ansible sudo make mariadb-server -y + - name: Set SQL server name + run: export name=mysql; if [ "${{ matrix.os }}" = "22.04"]; then name=mariadb; fi + - run: echo $name - name: Check that mariadb works - run: service mysql restart + run: service $name restart - name: Check that mariadb works - run: service mysql status + run: service $name 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 From c42f38fb6993b3616495d891ae5978797f8d9360 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 21:55:43 +0200 Subject: [PATCH 14/15] gg --- .github/workflows/ansible-deployments.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 8e8d0acf..2b6b56be 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -17,14 +17,11 @@ jobs: - name: remove package run: apt update; apt purge mysql-server -y - name: Install ansible lint tools + SQL server - run: apt install ansible sudo make mariadb-server -y - - name: Set SQL server name - run: export name=mysql; if [ "${{ matrix.os }}" = "22.04"]; then name=mariadb; fi - - run: echo $name - - name: Check that mariadb works - run: service $name restart - - name: Check that mariadb works - run: service $name status + run: apt install ansible sudo make -y + #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 From 2507b6e78422af600c67077ceff90709c5033c07 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 2 May 2022 22:00:50 +0200 Subject: [PATCH 15/15] gogo --- .github/workflows/ansible-deployments.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ansible-deployments.yml b/.github/workflows/ansible-deployments.yml index 2b6b56be..89482b6e 100644 --- a/.github/workflows/ansible-deployments.yml +++ b/.github/workflows/ansible-deployments.yml @@ -18,6 +18,7 @@ jobs: 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' }}