From 93961530119c858690304a5f30827177ebf50e5b Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 18:36:32 +0200 Subject: [PATCH 1/7] Add Debian support Former-commit-id: 6bdc21d52ee693d16e302cd129df29545cb241a8 --- .gitignore | 2 +- README.md | 1 + meta/main.yml | 8 +++---- molecule/default/molecule.yml | 20 ++++++++++++++++++ tasks/install_deps.yml | 40 +++++++++++++++++++++++++++++------ tasks/install_runner.yml | 2 +- tasks/uninstall_runner.yml | 5 +++++ 7 files changed, 65 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 4af4986..4367d18 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -actions-runner-linux-* \ No newline at end of file +*.gz \ No newline at end of file diff --git a/README.md b/README.md index dbed304..7b0d925 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Requirements * Supported Linux distros: * CentOS/RHEL 7,8 + * Debian 9,10 * Fedora 16+ * Ubuntu 16,18 diff --git a/meta/main.yml b/meta/main.yml index 170ff9d..4985896 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -14,10 +14,10 @@ - name: Fedora versions: - all - # - name: Debian - # versions: - # - jessie - # - stretch + - name: Debian + versions: + - buster + - stretch - name: Ubuntu versions: - xenial diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 58737ae..67d4363 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -44,6 +44,26 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes + - name: Debian9 + image: monolithprojects/systemd-debian9:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes + - name: Debian10 + image: monolithprojects/systemd-debian10:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes provisioner: name: ansible playbooks: diff --git a/tasks/install_deps.yml b/tasks/install_deps.yml index 936dd48..0640669 100644 --- a/tasks/install_deps.yml +++ b/tasks/install_deps.yml @@ -1,5 +1,33 @@ --- -- name: Install dependencies on Debian Stretch / Ubuntu Xenial systems +- name: Install dependencies on Debian Stretch + package: + pkg: + - liblttng-ust0 + - libkrb5-3 + - zlib1g + - libssl1.1 + - libicu57 + state: present + update_cache: yes + when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "9") + tags: + - install + +- name: Install dependencies on Debian Buster + package: + pkg: + - liblttng-ust0 + - libkrb5-3 + - zlib1g + - libssl1.1 + - libicu63 + state: present + update_cache: yes + when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "10") + tags: + - install + +- name: Install dependencies on Ubuntu Xenial systems package: pkg: - liblttng-ust0 @@ -9,12 +37,11 @@ - libicu55 state: present update_cache: yes - when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "9") or - (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16") + when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16") tags: - install - -- name: Install dependencies on Debian Buster / Ubuntu Bionic systems + +- name: Install dependencies on Ubuntu Bionic systems package: pkg: - liblttng-ust0 @@ -24,8 +51,7 @@ - libicu60 state: present update_cache: yes - when: (ansible_distribution == "Debian" and ansible_distribution_major_version == "10") or - (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "18") + when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "18") tags: - install diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index edb7e9a..dc36d76 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -29,7 +29,7 @@ tags: - install -- name: Register runner +- name: Register runner (if new installation) command: "{{ runner_dir }}/./config.sh --url {{ github_server }}/{{ github_account }}/{{ github_repo }} \ --token {{ registration.json.token }} --unattended" args: diff --git a/tasks/uninstall_runner.yml b/tasks/uninstall_runner.yml index 8f94e16..00aed4d 100644 --- a/tasks/uninstall_runner.yml +++ b/tasks/uninstall_runner.yml @@ -7,6 +7,11 @@ when: runner_service in services tags: - uninstall + +- name: Refresh services facts + service_facts: + tags: + - uninstall - name: Remove GitHub Actions Runner service file: From 2dfa90d7767cb9a14167373bac1bfa599277fd11 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 18:37:59 +0200 Subject: [PATCH 2/7] Remove ignored file Former-commit-id: 5fa4fb7c5c7a0da8954727a13570c64464491a06 --- molecule/default/actions-runner-linux.tar.gz.REMOVED.git-id | 1 - 1 file changed, 1 deletion(-) delete mode 100644 molecule/default/actions-runner-linux.tar.gz.REMOVED.git-id diff --git a/molecule/default/actions-runner-linux.tar.gz.REMOVED.git-id b/molecule/default/actions-runner-linux.tar.gz.REMOVED.git-id deleted file mode 100644 index e621040..0000000 --- a/molecule/default/actions-runner-linux.tar.gz.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -505e69bab8d510528aa662ef554436d57c936f38 \ No newline at end of file From 3858a944271886aad681b9a08bddc5d7ca008824 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 20:59:08 +0200 Subject: [PATCH 3/7] Add option for latest version Former-commit-id: f9995ab4141b41a5d02cd7e57f954745e4680f0c --- README.md | 4 ++-- defaults/main.yml | 4 ++-- tasks/install_runner.yml | 23 +++++++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7b0d925..f1b200c 100644 --- a/README.md +++ b/README.md @@ -35,14 +35,14 @@ Role Variables This is a copy from `defaults/main.yml` ```yaml -# Runner user - user inder which is the local runner service running +# Runner user - user under which is the local runner service running runner_user: runner # Directory where the local runner will be installed runner_dir: /opt/actions-runner # Version of the GitHub Actions Runner -runner_version: "2.165.2" +runner_version: "latest" # If found, replace already registered runner replace_runner: yes diff --git a/defaults/main.yml b/defaults/main.yml index fb2786c..96bf3c8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,12 +1,12 @@ --- -# Runner user - user inder which is the local runner service running +# Runner user - user under which is the local runner service running runner_user: runner # Directory where the local runner will be installed runner_dir: /opt/actions-runner # Version of the GitHub Actions Runner -runner_version: "2.165.2" +runner_version: "latest" # If found, replace already registered runner replace_runner: yes diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index dc36d76..3fe3ae4 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -10,6 +10,26 @@ tags: - install +- name: Find the lates runner version + uri: + url: "https://api.github.com/repos/actions/runner/releases/latest" + method: GET + force_basic_auth: yes + return_content: yes + status_code: 200 + body_format: json + register: api_response + # run_once: yes + # delegate_to: localhost + when: runner_version == "latest" + tags: + - install + +- name: Set runner_version variable ("{{ api_response.json.tag_name | regex_replace('^v', '') }}") + set_fact: + runner_version: "{{ api_response.json.tag_name | regex_replace('^v', '') }}" + when: runner_version == "latest" + - name: Download runner package version - "{{ runner_version }}" get_url: url: "https://github.com/actions/runner/releases/download/v{{ runner_version }}/actions-runner-linux-x64-{{ runner_version }}.tar.gz" @@ -17,9 +37,8 @@ force: no run_once: yes delegate_to: localhost - when: runner_version != "latest" tags: - - install + - install - name: Unarchive package unarchive: From 058c9152a33de51332fc3f611e20e0378e56a559 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 20:59:37 +0200 Subject: [PATCH 4/7] Add option for latest version Former-commit-id: 67148c2ab0400a756e4f675f54a165ca1e2f74da --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1b200c..b8741d4 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ In this example the role will deploy (or redeploy) the GitHub Actions runner ser become: yes vars: - runner_version: "2.165.2" - - runner_user: runner + - runner_user: ansible - github_account: myuser - github_repo: my_awesome_repo roles: From 58952c96e0b1d11629e1aee1c5a403255a997c9a Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 21:33:35 +0200 Subject: [PATCH 5/7] Add option for latest version Former-commit-id: 7daec8f87014da16b1f0aeb5f145261e5bc5cc4d --- molecule/default/converge.yml | 1 + tasks/install_runner.yml | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index c350c1b..10531d9 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -4,6 +4,7 @@ hosts: all become: yes vars: + - runner_version: "2.168.0" - runner_user: ansible - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index 3fe3ae4..3a990c1 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -10,22 +10,24 @@ tags: - install -- name: Find the lates runner version +- name: Find the latest runner version uri: url: "https://api.github.com/repos/actions/runner/releases/latest" + url_username: "{{ github_account }}" + url_password: "{{ access_token }}" method: GET force_basic_auth: yes return_content: yes status_code: 200 body_format: json register: api_response - # run_once: yes - # delegate_to: localhost + run_once: yes + delegate_to: localhost when: runner_version == "latest" tags: - install -- name: Set runner_version variable ("{{ api_response.json.tag_name | regex_replace('^v', '') }}") +- name: Set runner_version variable (if it is latest) set_fact: runner_version: "{{ api_response.json.tag_name | regex_replace('^v', '') }}" when: runner_version == "latest" From 205df9d693d7bab7faf0eb2a941cc0acebddaad0 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 21:36:31 +0200 Subject: [PATCH 6/7] Add option for latest version Former-commit-id: 8e7566ccc78057814c3aee5122f5136c6d3fe77c --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8741d4..941e657 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ github_server: "https://github.com" Example Playbook ---------------- -In this example the role will deploy (or redeploy) the GitHub Actions runner service (default version ins ) and register the runner for the GitHub repo. +In this example the role will deploy (or redeploy) the GitHub Actions runner service (version 2.165.2) and register the runner for the GitHub repo. ```yaml --- From 47aafc3a1e2cb6d1bc961c72fcd5e347a182e61c Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Sun, 5 Apr 2020 21:41:40 +0200 Subject: [PATCH 7/7] Add option for latest version Former-commit-id: 97fc12ead693c3aeddd2ba3f9a843aebe6c00d64 --- tasks/install_deps.yml | 2 +- tasks/install_runner.yml | 2 +- tasks/uninstall_runner.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/install_deps.yml b/tasks/install_deps.yml index 0640669..5e26bae 100644 --- a/tasks/install_deps.yml +++ b/tasks/install_deps.yml @@ -40,7 +40,7 @@ when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "16") tags: - install - + - name: Install dependencies on Ubuntu Bionic systems package: pkg: diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index 3a990c1..168e2c3 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -40,7 +40,7 @@ run_once: yes delegate_to: localhost tags: - - install + - install - name: Unarchive package unarchive: diff --git a/tasks/uninstall_runner.yml b/tasks/uninstall_runner.yml index 00aed4d..9818850 100644 --- a/tasks/uninstall_runner.yml +++ b/tasks/uninstall_runner.yml @@ -7,7 +7,7 @@ when: runner_service in services tags: - uninstall - + - name: Refresh services facts service_facts: tags: