From 15f39bb9bc06cb99fd14acb5935ed874d2e2bd16 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 18:09:01 +0100 Subject: [PATCH 01/22] Add cleanup playbooks --- molecule/default/cleanup.yml | 12 ++++++++++++ molecule/organization/cleanup.yml | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 molecule/default/cleanup.yml create mode 100644 molecule/organization/cleanup.yml diff --git a/molecule/default/cleanup.yml b/molecule/default/cleanup.yml new file mode 100644 index 0000000..d42361e --- /dev/null +++ b/molecule/default/cleanup.yml @@ -0,0 +1,12 @@ +--- +- name: Cleanup + user: ansible + hosts: all + become: yes + vars: + - runner_user: ansible + - github_repo: ansible-github_actions_runner-testrepo + - github_account: monolithprojects + - runner_state: absent + roles: + - ansible-github_actions_runner \ No newline at end of file diff --git a/molecule/organization/cleanup.yml b/molecule/organization/cleanup.yml new file mode 100644 index 0000000..331dd2e --- /dev/null +++ b/molecule/organization/cleanup.yml @@ -0,0 +1,13 @@ +--- +- name: Cleanup + user: ansible + hosts: all + become: yes + vars: + - runner_user: ansible + - github_repo: ansible-github_actions_runner-testrepo + - github_account: monolithprojects + - runner_state: absent + - runner_org: yes + roles: + - ansible-github_actions_runner \ No newline at end of file From 8cbd5365598152068957c496704460a72ca906e6 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 18:09:34 +0100 Subject: [PATCH 02/22] Change default vars --- defaults/main.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2c3c140..dd394d7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -8,11 +8,14 @@ runner_dir: /opt/actions-runner # Version of the GitHub Actions Runner runner_version: "latest" -# If found, replace already registered runner -replace_runner: yes +# State in which the runner service will be after the role is done (started, stopped, absent) +runner_state: "started" -# If found, delete already existed runner before install -uninstall_runner: no +# If found in GitGub, replace already registered runner +# replace_runner: yes + +# If found on the server, delete already existed runner service before install +reinstall_runner: no # Do not show Ansible logs which may contain sensitive data (registration token) hide_sensitive_logs: yes @@ -23,7 +26,7 @@ github_server: "https://github.com" # Personal Access Token for your GitHub account access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" -# Is it runner for organization or not +# Is it the runner for organization or not runner_org: no # GitHub Repository user or Organization owner used for Runner registration From 9ffff38f9122b904ac1f0ed480f31fd09868c740 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 18:11:00 +0100 Subject: [PATCH 03/22] Conditions in main --- tasks/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 678c6d2..978a5a8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,14 +12,16 @@ - uninstall - include_tasks: install_deps.yml + when: runner_state|lower == "started" or runner_state|lower == "stopped" tags: - install - include_tasks: uninstall_runner.yml - when: uninstall_runner + when: reinstall_runner or runner_state|lower == "absent" tags: - uninstall - include_tasks: install_runner.yml + when: runner_state|lower == "started" or runner_state|lower == "stopped" tags: - install \ No newline at end of file From 7f71da099f5407fcb912533d4bb1180f8a3a9945 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 18:19:11 +0100 Subject: [PATCH 04/22] Change default vars --- defaults/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index dd394d7..502bbe8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,9 +11,6 @@ runner_version: "latest" # State in which the runner service will be after the role is done (started, stopped, absent) runner_state: "started" -# If found in GitGub, replace already registered runner -# replace_runner: yes - # If found on the server, delete already existed runner service before install reinstall_runner: no From f298ad6e3602172b711064d67d5947ae4c1dea08 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 18:52:24 +0100 Subject: [PATCH 05/22] Add uninstall variable --- README.md | 52 ++++++++++------- molecule/default/converge.yml | 18 +++++- molecule/default/molecule.yml | 93 ++++++++++++++++-------------- molecule/organization/converge.yml | 19 +++++- molecule/organization/molecule.yml | 93 ++++++++++++++++-------------- tasks/install_runner.yml | 16 ++++- 6 files changed, 182 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index 8a642a6..9c51d39 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ [![GitHub Actions](https://github.com/MonolithProjects/ansible-github_actions_runner/workflows/molecule%20test/badge.svg?branch=master)](https://github.com/MonolithProjects/ansible-github_actions_runner/actions) [![License](https://img.shields.io/github/license/MonolithProjects/ansible-github_actions_runner)](https://github.com/MonolithProjects/ansible-github_actions_runner/blob/master/LICENSE) -This role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner. +This role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner. +It supports both, Organization and Repository Runners. ## Requirements @@ -26,7 +27,7 @@ Personal Access Token for GitHub account can be created [here](https://github.co * Weekly tested on: * CentOS/RHEL 7,8 * Debian 9,10 - * Fedora 31,32 + * Fedora 32,33 * Ubuntu 16,18,20 **Note:** Fedora 32 and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible. @@ -45,25 +46,25 @@ runner_dir: /opt/actions-runner # Version of the GitHub Actions Runner runner_version: "latest" -# If found, replace already registered runner -replace_runner: yes +# State in which the runner service will be after the role is done (started, stopped, absent) +runner_state: "started" -# If found, delete already existed runner before install -uninstall_runner: no +# If found on the server, delete already existed runner service before install +reinstall_runner: no -# Do not show Ansible logs which may contain sensitive data (registration token) +# Do not show Ansible error logs which may contain sensitive data (registration token) hide_sensitive_logs: yes # GitHub address github_server: "https://github.com" -# Personal Access Token +# Personal Access Token for your GitHub account access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" -# Is it runner for organization or not +# Is it the runner for organization or not runner_org: no -# Account used for Runner registration (GitHub Repository user with admin rights or Organization owner) +# GitHub Repository user or Organization owner used for Runner registration # github_account: "youruser" # Github repository name @@ -72,12 +73,12 @@ runner_org: no ## Example Playbook -In this example the Ansible role will deploy (or redeploy) the GitHub Actions runner service (latest available version) and register the runner for the GitHub repo. -Runner service will run under the same user as the Ansible is using for ssh connection (*ansible*). +In this example the Ansible role will install (or update) the GitHub Actions Runner service (latest available version). The runner will be registered for *my_awesome_repo* GitHub repo. +Runner service will be stated and will run under the same user as the Ansible is using for ssh connection (*ansible*). ```yaml --- -- name: GitHub Actions Runner +- name: Install GitHub Actions Runner hosts: all user: ansible become: yes @@ -88,11 +89,11 @@ Runner service will run under the same user as the Ansible is using for ssh conn - role: monolithprojects.github_actions_runner ``` -Same example, but runner will be added to an organization +Same example as above, but runner will be added to an organization. ```yaml --- -- name: GitHub Actions Runner +- name: Install GitHub Actions Runner hosts: all user: ansible become: yes @@ -103,11 +104,12 @@ Same example, but runner will be added to an organization - role: monolithprojects.github_actions_runner ``` -In this example the Ansible role will deploy (or redeploy) the GitHub Actions runner service (version 2.165.2) and register the runner for the GitHub repo. Runner service will run under the user `runner-user`. +In this example the Ansible role will deploy (or update) the GitHub Actions runner service (version 2.165.2) and register the runner for the GitHub repo. Runner service will run under the user `runner-user`. +The runner service will be *stopped*. ```yaml --- -- name: GitHub Actions Runner +- name: Stop GitHub Actions Runner hosts: all become: yes vars: @@ -115,14 +117,24 @@ In this example the Ansible role will deploy (or redeploy) the GitHub Actions ru - runner_user: runner-user - github_account: github-access-user - github_repo: my_awesome_repo + - runner_state: "stopped" roles: - role: monolithprojects.github_actions_runner ``` -By using tag `uninstall` with combination of variable `uninstall_runner: yes`, GitHub Actions runner will be removed from the host and unregistered from the GitHub repository. +In this example the Ansible role will uninstall the runner service and unregister it from the GitHub Repository. -```bash -ansible-playbook playbook.yml --tags uninstall -e "uninstall_runner=yes" +```yaml +--- +- name: Uninstall GitHub Actions Runner + hosts: all + become: yes + vars: + - github_account: github-access-user + - github_repo: my_awesome_repo + - runner_state: "absent" + roles: + - role: monolithprojects.github_actions_runner ``` ## License diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 22461c1..b787111 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -1,5 +1,5 @@ --- -- name: Converge +- name: Install user: ansible hosts: all become: yes @@ -7,6 +7,22 @@ - runner_user: ansible - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects + - runner_state: "stopped" + - runner_version: "2.274.1" + roles: + - robertdebock.epel + - ansible-github_actions_runner + +- name: Reinstall + user: ansible + hosts: all + become: yes + vars: + - runner_user: ansible + - github_repo: ansible-github_actions_runner-testrepo + - github_account: monolithprojects + - reinstall_runner: yes + - runner_version: "latest" roles: - robertdebock.epel - ansible-github_actions_runner \ No newline at end of file diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 917db8a..f373ec2 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,7 +2,6 @@ driver: name: docker lint: | - set -e yamllint . ansible-lint platforms: @@ -16,16 +15,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - - name: CentOS8 - image: monolithprojects/systemd-centos8:latest - command: /sbin/init - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: yes - pre_build_image: yes + # - name: CentOS8 + # image: monolithprojects/systemd-centos8:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes - name: Fedora32 image: monolithprojects/systemd-fedora32:latest command: /sbin/init @@ -36,6 +35,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes + # - name: Fedora33 + # image: monolithprojects/systemd-fedora33:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes - name: Ubuntu16 image: monolithprojects/systemd-ubuntu16:latest command: /sbin/init @@ -46,26 +55,26 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - - name: Ubuntu18 - image: monolithprojects/systemd-ubuntu18:latest - command: /sbin/init - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: yes - pre_build_image: yes - - name: Ubuntu20 - image: monolithprojects/systemd-ubuntu20:latest - command: /sbin/init - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: yes - pre_build_image: yes + # - name: Ubuntu18 + # image: monolithprojects/systemd-ubuntu18:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes + # - name: Ubuntu20 + # image: monolithprojects/systemd-ubuntu20:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes - name: Debian9 image: monolithprojects/systemd-debian9:latest command: /sbin/init @@ -76,16 +85,16 @@ platforms: - /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 + # - 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: @@ -120,7 +129,7 @@ scenario: - destroy - syntax - create - - prepare + # - prepare - converge # - idempotence - cleanup diff --git a/molecule/organization/converge.yml b/molecule/organization/converge.yml index c3a2841..ba327f2 100644 --- a/molecule/organization/converge.yml +++ b/molecule/organization/converge.yml @@ -1,5 +1,5 @@ --- -- name: Converge +- name: Install user: ansible hosts: all become: yes @@ -8,6 +8,23 @@ - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects-testorg - runner_org: yes + - runner_state: "stopped" + - runner_version: "2.274.1" + roles: + - robertdebock.epel + - ansible-github_actions_runner + +- name: Reinstall + user: ansible + hosts: all + become: yes + vars: + - runner_user: ansible + - github_repo: ansible-github_actions_runner-testrepo + - github_account: monolithprojects-testorg + - runner_org: yes + # - reinstall_runner: yes + - runner_version: "latest" roles: - robertdebock.epel - ansible-github_actions_runner \ No newline at end of file diff --git a/molecule/organization/molecule.yml b/molecule/organization/molecule.yml index 7c8d8c5..0b073f6 100644 --- a/molecule/organization/molecule.yml +++ b/molecule/organization/molecule.yml @@ -2,7 +2,6 @@ driver: name: docker lint: | - set -e yamllint . ansible-lint platforms: @@ -16,16 +15,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - - name: CentOS8 - image: monolithprojects/systemd-centos8:latest - command: /sbin/init - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: yes - pre_build_image: yes + # - name: CentOS8 + # image: monolithprojects/systemd-centos8:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes - name: Fedora32 image: monolithprojects/systemd-fedora32:latest command: /sbin/init @@ -36,6 +35,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes + # - name: Fedora33 + # image: monolithprojects/systemd-fedora33:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes - name: Ubuntu16 image: monolithprojects/systemd-ubuntu16:latest command: /sbin/init @@ -46,26 +55,26 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - - name: Ubuntu18 - image: monolithprojects/systemd-ubuntu18:latest - command: /sbin/init - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: yes - pre_build_image: yes - - name: Ubuntu20 - image: monolithprojects/systemd-ubuntu20:latest - command: /sbin/init - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - privileged: yes - pre_build_image: yes + # - name: Ubuntu18 + # image: monolithprojects/systemd-ubuntu18:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes + # - name: Ubuntu20 + # image: monolithprojects/systemd-ubuntu20:latest + # command: /sbin/init + # tmpfs: + # - /run + # - /tmp + # volumes: + # - /sys/fs/cgroup:/sys/fs/cgroup:ro + # privileged: yes + # pre_build_image: yes - name: Debian9 image: monolithprojects/systemd-debian9:latest command: /sbin/init @@ -76,16 +85,16 @@ platforms: - /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 + # - 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: @@ -120,7 +129,7 @@ scenario: - destroy - syntax - create - - prepare + # - prepare - converge # - idempotence - cleanup diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index b6850d1..51e6211 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -109,7 +109,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: replace_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and not runner_org + when: reinstall_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and not runner_org tags: - install @@ -121,7 +121,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: replace_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and runner_org + when: reinstall_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and runner_org tags: - install @@ -133,10 +133,20 @@ tags: - install -- name: Start and enable Github Actions Runner service +- name: Enable and START Github Actions Runner service systemd: name: "{{ runner_service }}" state: started enabled: yes + when: runner_state|lower == "started" + tags: + - install + +- name: Enable and STOP Github Actions Runner service + systemd: + name: "{{ runner_service }}" + state: stopped + enabled: yes + when: runner_state|lower == "stopped" tags: - install From 7b7990a2df92c94102a4adf91a02ea870388aee3 Mon Sep 17 00:00:00 2001 From: Kuba Mazurek Date: Thu, 26 Nov 2020 19:08:12 +0100 Subject: [PATCH 06/22] Add runner_name variable --- README.md | 3 +++ defaults/main.yml | 5 ++++- tasks/install_runner.yml | 8 ++++---- tasks/uninstall_runner.yml | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8a642a6..dc562d2 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,9 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" # Is it runner for organization or not runner_org: no +# Name to assign to this runner in GitHub +runner_name: "{{ lookup('pipe', 'hostname') }}" + # Account used for Runner registration (GitHub Repository user with admin rights or Organization owner) # github_account: "youruser" diff --git a/defaults/main.yml b/defaults/main.yml index 2c3c140..45c07a8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,8 +26,11 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" # Is it runner for organization or not runner_org: no +# Name to assign to this runner in GitHub +runner_name: "{{ lookup('pipe', 'hostname') }}" + # GitHub Repository user or Organization owner used for Runner registration # github_account: "youruser" # Github repository name -# github_repo: "yourrepo" \ No newline at end of file +# github_repo: "yourrepo" diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index b6850d1..d60bcc6 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -79,7 +79,7 @@ - name: Register runner (if new installation) for repo command: "{{ runner_dir }}/./config.sh --url {{ github_server }}/{{ github_owner | default(github_account) }}/{{ github_repo }} \ - --token {{ registration.json.token }} --unattended" + --token {{ registration.json.token }} --name {{ runner_name }} --unattended" args: chdir: "{{ runner_dir }}" become: yes @@ -91,7 +91,7 @@ - name: Register runner (if new installation) for organization command: "{{ runner_dir }}/./config.sh --url {{ github_server }}/{{ github_owner | default(github_account) }} \ - --token {{ registration.json.token }} --unattended" + --token {{ registration.json.token }} --name {{ runner_name }} --unattended" args: chdir: "{{ runner_dir }}" become: yes @@ -103,7 +103,7 @@ - name: Replace registered runner for repo command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_owner | default(github_account) }}/{{ github_repo }} \ - --token {{ registration.json.token }} --unattended --replace" + --token {{ registration.json.token }} --name {{ runner_name }} --unattended --replace" args: chdir: "{{ runner_dir }}" become: yes @@ -115,7 +115,7 @@ - name: Replace registered runner for organization command: "{{ runner_dir }}/config.sh --url {{ github_server }}/{{ github_owner | default(github_account) }} \ - --token {{ registration.json.token }} --unattended --replace" + --token {{ registration.json.token }} --name {{ runner_name }} --unattended --replace" args: chdir: "{{ runner_dir }}" become: yes diff --git a/tasks/uninstall_runner.yml b/tasks/uninstall_runner.yml index 2441240..36319b4 100644 --- a/tasks/uninstall_runner.yml +++ b/tasks/uninstall_runner.yml @@ -37,7 +37,7 @@ - uninstall - name: Unregister runner from the GitHub - command: "./config.sh remove --token {{ registration.json.token }} --unattended" + command: "./config.sh remove --token {{ registration.json.token }} --name {{ runner_name }} --unattended" args: chdir: "{{ runner_dir }}" become: yes @@ -52,4 +52,4 @@ path: "{{ runner_dir }}" state: absent tags: - - uninstall \ No newline at end of file + - uninstall From 880ca5ec16b1ea458e738631acfe6edfd6e16c48 Mon Sep 17 00:00:00 2001 From: Kuba Mazurek Date: Thu, 26 Nov 2020 19:08:45 +0100 Subject: [PATCH 07/22] Mention github_owner variable in docs --- README.md | 3 +++ defaults/main.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index dc562d2..6381269 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ runner_name: "{{ lookup('pipe', 'hostname') }}" # Account used for Runner registration (GitHub Repository user with admin rights or Organization owner) # github_account: "youruser" +# GitHub repository owner name (if other than github_account) +# github_owner: "yourorg" + # Github repository name # github_repo: "yourrepo" ``` diff --git a/defaults/main.yml b/defaults/main.yml index 45c07a8..0d575f6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -32,5 +32,8 @@ runner_name: "{{ lookup('pipe', 'hostname') }}" # GitHub Repository user or Organization owner used for Runner registration # github_account: "youruser" +# GitHub repository owner name (if other than github_account) +# github_owner: "yourorg" + # Github repository name # github_repo: "yourrepo" From fd978f37e17446f5e8e436b025336d0463cc89a0 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 20:04:18 +0100 Subject: [PATCH 08/22] Better verifier --- molecule/default/molecule.yml | 5 +++-- .../tests/__pycache__/test_default.cpython-37.pyc | Bin 718 -> 0 bytes molecule/default/tests/test_default.py | 6 ++---- molecule/organization/molecule.yml | 5 +++-- molecule/organization/tests/test_default.py | 13 +++++++++++++ 5 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 molecule/default/tests/__pycache__/test_default.cpython-37.pyc create mode 100644 molecule/organization/tests/test_default.py diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index f373ec2..9fa64d3 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -114,7 +114,8 @@ provisioner: Ubuntu20: ansible_python_interpreter: /usr/bin/python3 verifier: - name: ansible + name: testinfra + directory: tests dependency: name: galaxy options: @@ -131,6 +132,6 @@ scenario: - create # - prepare - converge - # - idempotence + - idempotence - cleanup - destroy \ No newline at end of file diff --git a/molecule/default/tests/__pycache__/test_default.cpython-37.pyc b/molecule/default/tests/__pycache__/test_default.cpython-37.pyc deleted file mode 100644 index 5cd7b75f32a61503e852896a21ef57627761c2f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 718 zcmZWn&2H2%5VoCUyBoUO3lieOf!iLMZ~zVnRg@}4m6okkek5`r3b9k1X6?v!s{ZW- z@gTcLo`pB?l@qVPiHVmjrHnP>na}g{Y2=r~VTeFpMOz=AVT68k!CHK9UV!SSU?`%v zM(OItDPg4YDt{3$RP`vikCu3`LA@nT`_!kwSCkGYeuKunpHPdY>Aly7lVtDRB*_k@ z@001#lel%RabW$D*Ua|V8Sl{1uGUN$E=8i0RMu}Hw862GZ8Ij; z?`kbBzae!8c>MYvn^_Y#yxHbL8{oWMWm(leY0l!AtXa|4?5|TudBOoRhN)N=Oyr8o z_>?JLazG5zhKo|=@#W>s)M(u)qg=7VNOeA+-_BXL%S1k7|39yX{L`Wvm{C^dZEd3F z+-^C*Z71uN(tQEl2ZL}(LOjB12>v*0ITop7 Date: Thu, 26 Nov 2020 20:09:26 +0100 Subject: [PATCH 09/22] Better tests --- .github/workflows/lifecycle.yml | 63 --------------------------------- .github/workflows/lint.yml | 21 +++++++++++ .github/workflows/main.yml | 16 +++++++-- 3 files changed, 35 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/lifecycle.yml create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lifecycle.yml b/.github/workflows/lifecycle.yml deleted file mode 100644 index e4d0b42..0000000 --- a/.github/workflows/lifecycle.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: molecule converge tag install/uninstall - -on: - push: - branches: - - develop - - feature/* - schedule: - - cron: '0 6 * * 0' -jobs: - lint: - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - name: checkout - uses: actions/checkout@v2 - with: - path: "${{ github.repository }}" - - name: Molecule for Ansible - lint - uses: MonolithProjects/action-molecule@v1.4.0 - with: - molecule_command: lint - - test_lifecycle: - runs-on: ubuntu-latest - needs: lint - strategy: - fail-fast: false - steps: - - name: checkout - uses: actions/checkout@v2 - with: - path: "${{ github.repository }}" - - name: Molecule for Ansible - converge Default - uses: MonolithProjects/action-molecule@v1.4.0 - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - molecule_command: converge - - name: Molecule for Ansible - converge tag uninstall - uses: MonolithProjects/action-molecule@v1.4.0 - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - molecule_command: converge - converge_extra_args: '-e "uninstall_runner=yes" --tags uninstall' - - - name: Molecule for Ansible - converge organizations - uses: MonolithProjects/action-molecule@v1.4.0 - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - molecule_command: converge - scenario: organization - - name: Molecule for Ansible - converge organizations tag uninstall - uses: MonolithProjects/action-molecule@v1.4.0 - env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - molecule_command: converge - scenario: organization - converge_extra_args: '-e "uninstall_runner=yes" --tags uninstall' \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..e2c1e36 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,21 @@ +name: molecule lint + +on: + push: + branches: + - develop + - feature/* +jobs: + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: checkout + uses: actions/checkout@v2 + with: + path: "${{ github.repository }}" + - name: Molecule for Ansible - lint + uses: MonolithProjects/action-molecule@v1.4.0 + with: + molecule_command: lint diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d7b6f70..94de24e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,6 +4,8 @@ on: push: branches: - master + - develop + - feature/* schedule: - cron: '0 6 * * 0' jobs: @@ -17,6 +19,16 @@ jobs: with: path: "${{ github.repository }}" - name: Molecule for Ansible - uses: MonolithProjects/action-molecule@v1.3.0 + uses: MonolithProjects/action-molecule@v1.4.0 env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} \ No newline at end of file + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + with: + molecule_command: test + scenario: organization + - name: Molecule for Ansible - converge organizations tag uninstall + uses: MonolithProjects/action-molecule@v1.4.0 + env: + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + with: + molecule_command: test + scenario: organization \ No newline at end of file From a1c818b05e646beb143483f2caeee00074283a41 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 20:11:08 +0100 Subject: [PATCH 10/22] Better tests --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 94de24e..65f2ecd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,8 +4,8 @@ on: push: branches: - master - - develop - - feature/* + pull_request: + types: [opened, synchronize, reopened] schedule: - cron: '0 6 * * 0' jobs: From a685aca5e7dc851e40c71ece4ae632bf1ebf55fd Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 20:26:37 +0100 Subject: [PATCH 11/22] Better tests --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 65f2ecd..753fb57 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,14 +18,14 @@ jobs: uses: actions/checkout@v2 with: path: "${{ github.repository }}" - - name: Molecule for Ansible + - name: Molecule for Ansible - GHR Repository uses: MonolithProjects/action-molecule@v1.4.0 env: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: molecule_command: test scenario: organization - - name: Molecule for Ansible - converge organizations tag uninstall + - name: Molecule for Ansible - GHR Organizations uses: MonolithProjects/action-molecule@v1.4.0 env: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} From 6e68ad98b405ed92d100a031064697b3fe6fdfe0 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 20:30:35 +0100 Subject: [PATCH 12/22] Better tests --- molecule/default/molecule.yml | 1 - molecule/organization/molecule.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 9fa64d3..6cf5b70 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -126,7 +126,6 @@ scenario: test_sequence: - dependency - lint - - cleanup - destroy - syntax - create diff --git a/molecule/organization/molecule.yml b/molecule/organization/molecule.yml index 4c9e895..b5e8ddd 100644 --- a/molecule/organization/molecule.yml +++ b/molecule/organization/molecule.yml @@ -126,7 +126,6 @@ scenario: test_sequence: - dependency - lint - - cleanup - destroy - syntax - create From 14c8978cce9af4d950274373de469a77314463e8 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 20:35:52 +0100 Subject: [PATCH 13/22] Return all os tests --- README.md | 2 +- molecule/default/molecule.yml | 100 ++++++++++++++--------------- molecule/organization/molecule.yml | 100 ++++++++++++++--------------- 3 files changed, 101 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index 9c51d39..93f1fcc 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Personal Access Token for GitHub account can be created [here](https://github.co * Fedora 32,33 * Ubuntu 16,18,20 - **Note:** Fedora 32 and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible. + **Note:** Fedora 32+ and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible. ## Role Variables diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 6cf5b70..25de688 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -15,16 +15,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - # - name: CentOS8 - # image: monolithprojects/systemd-centos8:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes + - name: CentOS8 + image: monolithprojects/systemd-centos8:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes - name: Fedora32 image: monolithprojects/systemd-fedora32:latest command: /sbin/init @@ -35,16 +35,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - # - name: Fedora33 - # image: monolithprojects/systemd-fedora33:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes + - name: Fedora33 + image: monolithprojects/systemd-fedora33:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes - name: Ubuntu16 image: monolithprojects/systemd-ubuntu16:latest command: /sbin/init @@ -55,26 +55,26 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - # - name: Ubuntu18 - # image: monolithprojects/systemd-ubuntu18:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes - # - name: Ubuntu20 - # image: monolithprojects/systemd-ubuntu20:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes + - name: Ubuntu18 + image: monolithprojects/systemd-ubuntu18:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes + - name: Ubuntu20 + image: monolithprojects/systemd-ubuntu20:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes - name: Debian9 image: monolithprojects/systemd-debian9:latest command: /sbin/init @@ -85,16 +85,16 @@ platforms: - /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 + - 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/molecule/organization/molecule.yml b/molecule/organization/molecule.yml index b5e8ddd..ceff164 100644 --- a/molecule/organization/molecule.yml +++ b/molecule/organization/molecule.yml @@ -15,16 +15,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - # - name: CentOS8 - # image: monolithprojects/systemd-centos8:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes + - name: CentOS8 + image: monolithprojects/systemd-centos8:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes - name: Fedora32 image: monolithprojects/systemd-fedora32:latest command: /sbin/init @@ -35,16 +35,16 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - # - name: Fedora33 - # image: monolithprojects/systemd-fedora33:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes + - name: Fedora33 + image: monolithprojects/systemd-fedora33:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes - name: Ubuntu16 image: monolithprojects/systemd-ubuntu16:latest command: /sbin/init @@ -55,26 +55,26 @@ platforms: - /sys/fs/cgroup:/sys/fs/cgroup:ro privileged: yes pre_build_image: yes - # - name: Ubuntu18 - # image: monolithprojects/systemd-ubuntu18:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes - # - name: Ubuntu20 - # image: monolithprojects/systemd-ubuntu20:latest - # command: /sbin/init - # tmpfs: - # - /run - # - /tmp - # volumes: - # - /sys/fs/cgroup:/sys/fs/cgroup:ro - # privileged: yes - # pre_build_image: yes + - name: Ubuntu18 + image: monolithprojects/systemd-ubuntu18:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes + - name: Ubuntu20 + image: monolithprojects/systemd-ubuntu20:latest + command: /sbin/init + tmpfs: + - /run + - /tmp + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: yes + pre_build_image: yes - name: Debian9 image: monolithprojects/systemd-debian9:latest command: /sbin/init @@ -85,16 +85,16 @@ platforms: - /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 + - 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: From ea20499c7a1fbcb8c7006538d9b2f3014128045a Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 21:03:56 +0100 Subject: [PATCH 14/22] Ubuntu 18 for wf --- .github/workflows/galaxy.yml | 2 +- .github/workflows/lint.yml | 4 ++-- .github/workflows/main.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml index cd6bab3..4d62038 100644 --- a/.github/workflows/galaxy.yml +++ b/.github/workflows/galaxy.yml @@ -8,7 +8,7 @@ on: jobs: release: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 steps: - name: galaxy uses: robertdebock/galaxy-action@1.0.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e2c1e36..7747a80 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,9 +7,9 @@ on: - feature/* jobs: lint: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 strategy: - fail-fast: false + fail-fast: true steps: - name: checkout uses: actions/checkout@v2 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 753fb57..a0b047e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,9 @@ on: - cron: '0 6 * * 0' jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 strategy: - fail-fast: false + fail-fast: true steps: - name: checkout uses: actions/checkout@v2 From ecb44d0a818a380339dd12df46c05a40c39d8213 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 21:27:31 +0100 Subject: [PATCH 15/22] Fix molecule test --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0b047e..e8d5316 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,6 @@ jobs: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: molecule_command: test - scenario: organization - name: Molecule for Ansible - GHR Organizations uses: MonolithProjects/action-molecule@v1.4.0 env: From f157a8778410d1e90139e8ebfd03f32e65d9eb87 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 21:29:22 +0100 Subject: [PATCH 16/22] Fix molecule test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e8d5316..c2a120e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: molecule_command: test - - name: Molecule for Ansible - GHR Organizations + - name: Molecule for Ansible - GHR Organization uses: MonolithProjects/action-molecule@v1.4.0 env: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} From dec093c14088067eca2da30c71156e6fb21e87bc Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 21:41:26 +0100 Subject: [PATCH 17/22] Simplify molecule test --- molecule/default/converge.yml | 15 --------------- molecule/organization/converge.yml | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index b787111..297c593 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -7,21 +7,6 @@ - runner_user: ansible - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects - - runner_state: "stopped" - - runner_version: "2.274.1" - roles: - - robertdebock.epel - - ansible-github_actions_runner - -- name: Reinstall - user: ansible - hosts: all - become: yes - vars: - - runner_user: ansible - - github_repo: ansible-github_actions_runner-testrepo - - github_account: monolithprojects - - reinstall_runner: yes - runner_version: "latest" roles: - robertdebock.epel diff --git a/molecule/organization/converge.yml b/molecule/organization/converge.yml index ba327f2..1e117b1 100644 --- a/molecule/organization/converge.yml +++ b/molecule/organization/converge.yml @@ -10,21 +10,6 @@ - runner_org: yes - runner_state: "stopped" - runner_version: "2.274.1" - roles: - - robertdebock.epel - - ansible-github_actions_runner - -- name: Reinstall - user: ansible - hosts: all - become: yes - vars: - - runner_user: ansible - - github_repo: ansible-github_actions_runner-testrepo - - github_account: monolithprojects-testorg - - runner_org: yes - # - reinstall_runner: yes - - runner_version: "latest" roles: - robertdebock.epel - ansible-github_actions_runner \ No newline at end of file From 6edc8a214fc7da558adc3af1e9897f9feb7f7da1 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Thu, 26 Nov 2020 21:56:07 +0100 Subject: [PATCH 18/22] Disable idempotence test --- molecule/default/molecule.yml | 2 +- molecule/organization/molecule.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 25de688..6167bba 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -131,6 +131,6 @@ scenario: - create # - prepare - converge - - idempotence + # - idempotence - cleanup - destroy \ No newline at end of file diff --git a/molecule/organization/molecule.yml b/molecule/organization/molecule.yml index ceff164..7028081 100644 --- a/molecule/organization/molecule.yml +++ b/molecule/organization/molecule.yml @@ -131,6 +131,6 @@ scenario: - create # - prepare - converge - - idempotence + # - idempotence - cleanup - destroy \ No newline at end of file From ab2b222328d4aafca3398844e4b307caff041e16 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Fri, 27 Nov 2020 00:09:38 +0100 Subject: [PATCH 19/22] Fix molecule cleanup, return reinstall test --- molecule/default/converge.yml | 14 ++++++++++++++ molecule/organization/cleanup.yml | 2 +- molecule/organization/converge.yml | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 297c593..c8093b0 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -8,6 +8,20 @@ - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects - runner_version: "latest" + roles: + - robertdebock.epel + - ansible-github_actions_runner + +- name: Reinstall + user: ansible + hosts: all + become: yes + vars: + - runner_user: ansible + - github_repo: ansible-github_actions_runner-testrepo + - github_account: monolithprojects + - reinstall_runner: yes + - runner_version: "latest" roles: - robertdebock.epel - ansible-github_actions_runner \ No newline at end of file diff --git a/molecule/organization/cleanup.yml b/molecule/organization/cleanup.yml index 331dd2e..0cf786d 100644 --- a/molecule/organization/cleanup.yml +++ b/molecule/organization/cleanup.yml @@ -6,7 +6,7 @@ vars: - runner_user: ansible - github_repo: ansible-github_actions_runner-testrepo - - github_account: monolithprojects + - github_account: monolithprojects-testorg - runner_state: absent - runner_org: yes roles: diff --git a/molecule/organization/converge.yml b/molecule/organization/converge.yml index 1e117b1..ba327f2 100644 --- a/molecule/organization/converge.yml +++ b/molecule/organization/converge.yml @@ -10,6 +10,21 @@ - runner_org: yes - runner_state: "stopped" - runner_version: "2.274.1" + roles: + - robertdebock.epel + - ansible-github_actions_runner + +- name: Reinstall + user: ansible + hosts: all + become: yes + vars: + - runner_user: ansible + - github_repo: ansible-github_actions_runner-testrepo + - github_account: monolithprojects-testorg + - runner_org: yes + # - reinstall_runner: yes + - runner_version: "latest" roles: - robertdebock.epel - ansible-github_actions_runner \ No newline at end of file From 61c25d759fb01de82b5e7aab10b4a563c4327b82 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Fri, 27 Nov 2020 01:00:09 +0100 Subject: [PATCH 20/22] Fix missing svc.sh --- molecule/organization/cleanup.yml | 1 - molecule/organization/converge.yml | 4 +--- tasks/install_runner.yml | 8 ++++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/molecule/organization/cleanup.yml b/molecule/organization/cleanup.yml index 0cf786d..ee00815 100644 --- a/molecule/organization/cleanup.yml +++ b/molecule/organization/cleanup.yml @@ -5,7 +5,6 @@ become: yes vars: - runner_user: ansible - - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects-testorg - runner_state: absent - runner_org: yes diff --git a/molecule/organization/converge.yml b/molecule/organization/converge.yml index ba327f2..61fe0d4 100644 --- a/molecule/organization/converge.yml +++ b/molecule/organization/converge.yml @@ -5,7 +5,6 @@ become: yes vars: - runner_user: ansible - - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects-testorg - runner_org: yes - runner_state: "stopped" @@ -20,10 +19,9 @@ become: yes vars: - runner_user: ansible - - github_repo: ansible-github_actions_runner-testrepo - github_account: monolithprojects-testorg - runner_org: yes - # - reinstall_runner: yes + - reinstall_runner: yes - runner_version: "latest" roles: - robertdebock.epel diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index 51e6211..4bed4d3 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -61,7 +61,7 @@ run_once: yes become: false delegate_to: localhost - when: runner_version not in runner_installed.stdout + when: runner_version not in runner_installed.stdout or reinstall_runner tags: - install @@ -71,7 +71,7 @@ dest: "{{ runner_dir }}/" owner: "{{ runner_user }}" mode: 0755 - when: runner_version not in runner_installed.stdout + when: runner_version not in runner_installed.stdout or reinstall_runner notify: - Restart runner service tags: @@ -109,7 +109,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: reinstall_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and not runner_org + when: ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and not runner_org tags: - install @@ -121,7 +121,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: reinstall_runner and ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and runner_org + when: ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and runner_org tags: - install From b2a4cbab56be182bbbe51edc6ebb24a3d6d67984 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Fri, 27 Nov 2020 01:50:24 +0100 Subject: [PATCH 21/22] Edit README --- README.md | 6 +++--- defaults/main.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83d7685..313f073 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ runner_state: "started" # If found on the server, delete already existed runner service before install reinstall_runner: no -# Do not show Ansible error logs which may contain sensitive data (registration token) +# Do not show Ansible logs which may contain sensitive data (registration token) hide_sensitive_logs: yes # GitHub address @@ -64,10 +64,10 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" # Is it the runner for organization or not runner_org: no -# Name to assign to this runner in GitHub +# Name to assign to this runner in GitHub (hostname as default) runner_name: "{{ lookup('pipe', 'hostname') }}" -# Account used for Runner registration (GitHub Repository user with admin rights or Organization owner) +# GitHub Repository user or Organization owner used for Runner registration # github_account: "youruser" # GitHub repository owner name (if other than github_account) diff --git a/defaults/main.yml b/defaults/main.yml index 5ffc496..ada0eaa 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,7 +26,7 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" # Is it the runner for organization or not runner_org: no -# Name to assign to this runner in GitHub +# Name to assign to this runner in GitHub (hostname as default) runner_name: "{{ lookup('pipe', 'hostname') }}" # GitHub Repository user or Organization owner used for Runner registration From 94616c56a760f84e5738eac9b8c0534e935c2499 Mon Sep 17 00:00:00 2001 From: Michal Muransky Date: Fri, 27 Nov 2020 02:22:56 +0100 Subject: [PATCH 22/22] Fix runner_name --- defaults/main.yml | 4 ++-- tasks/collect_info_org.yml | 2 +- tasks/collect_info_repo.yml | 2 +- tasks/install_runner.yml | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index ada0eaa..c0cf72c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,7 +15,7 @@ runner_state: "started" reinstall_runner: no # Do not show Ansible logs which may contain sensitive data (registration token) -hide_sensitive_logs: yes +hide_sensitive_logs: no # GitHub address github_server: "https://github.com" @@ -27,7 +27,7 @@ access_token: "{{ lookup('env', 'PERSONAL_ACCESS_TOKEN') }}" runner_org: no # Name to assign to this runner in GitHub (hostname as default) -runner_name: "{{ lookup('pipe', 'hostname') }}" +runner_name: "{{ ansible_hostname }}" # GitHub Repository user or Organization owner used for Runner registration # github_account: "youruser" diff --git a/tasks/collect_info_org.yml b/tasks/collect_info_org.yml index d830167..e882d38 100644 --- a/tasks/collect_info_org.yml +++ b/tasks/collect_info_org.yml @@ -37,7 +37,7 @@ - name: Build service name set_fact: - runner_service: "actions.runner.{{ github_account[:45] }}.{{ ansible_hostname }}.service" + runner_service: "actions.runner.{{ github_account[:45] }}.{{ runner_name }}.service" tags: - install - uninstall \ No newline at end of file diff --git a/tasks/collect_info_repo.yml b/tasks/collect_info_repo.yml index bfefe39..78dd798 100644 --- a/tasks/collect_info_repo.yml +++ b/tasks/collect_info_repo.yml @@ -44,7 +44,7 @@ - name: Build service name set_fact: - runner_service: "actions.runner.{{ svc_name[:45] }}.{{ ansible_hostname }}.service" + runner_service: "actions.runner.{{ svc_name[:45] }}.{{ runner_name }}.service" tags: - install - uninstall \ No newline at end of file diff --git a/tasks/install_runner.yml b/tasks/install_runner.yml index 48290be..4744d87 100644 --- a/tasks/install_runner.yml +++ b/tasks/install_runner.yml @@ -85,7 +85,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: ansible_hostname not in registered_runners.json.runners|map(attribute='name')|list and not runner_org + when: runner_name not in registered_runners.json.runners|map(attribute='name')|list and not runner_org tags: - install @@ -97,7 +97,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: ansible_hostname not in registered_runners.json.runners|map(attribute='name')|list and runner_org + when: runner_name not in registered_runners.json.runners|map(attribute='name')|list and runner_org tags: - install @@ -109,7 +109,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and not runner_org + when: runner_name in registered_runners.json.runners|map(attribute='name')|list and not runner_org tags: - install @@ -121,7 +121,7 @@ become: yes become_user: "{{ runner_user }}" no_log: "{{ hide_sensitive_logs | bool }}" - when: ansible_hostname in registered_runners.json.runners|map(attribute='name')|list and runner_org + when: runner_name in registered_runners.json.runners|map(attribute='name')|list and runner_org tags: - install