Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible: dynamically exclude jenkins-workspace #3816

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

richardlau
Copy link
Member

The ansible/playbooks/jenkins/worker/create.yml playbook runs some tasks at the end to remove Node.js and check there is no runnable node in the path. This is done on all test and release machines with the exception of the jenkins-workspace machines, which need a runnable node to run the linters.

Previously each jenkins-workspace machine was listed as an exclusion to hosts. This PR moves the exclusion into the tasks and checks if the host has an alias that begins jenkins-workspace (as all of our jenkins-workspace machines are defined). This will avoid one place that we have to remember to manually update every time we add/remove a jenkins-workspace machine.

The `ansible/playbooks/jenkins/worker/create.yml` playbook runs some
tasks at the end to remove Node.js and check there is no runnable
`node` in the path. This is done on all `test` and `release` machines
with the exception of the `jenkins-workspace` machines, which need a
runnable `node` to run the linters.

Previously each `jenkins-workspace` machine was listed as an exclusion
to `hosts`. This PR moves the exclusion into the tasks and checks if
the host has an alias that begins `jenkins-workspace` (as all of our
`jenkins-workspace` machines are defined). This will avoid one place
that we have to remember to manually update every time we add/remove
a `jenkins-workspace` machine.
@richardlau
Copy link
Member Author

This was something I missed reviewing #3815 and meant that the playbook was removing node from the new jenkins-workspace machines because they weren't being excluded from those tasks.

With this PR they now are excluded without having to manually add them:

PLAY [test,release,!test-equinix-ubuntu2204-x64-1,!test-equinix-ubuntu2204-x64-2,!test-ibm-ubuntu2204-x64-3] ****************************************************************************************************

TASK [remove node and npm packages] *****************************************************************************************************************************************************************************
skipping: [test-mnx-ubuntu2204-x64-1] => (item=node)  => {"ansible_loop_var": "package", "changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "package": "node", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-2] => (item=node)  => {"ansible_loop_var": "package", "changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "package": "node", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-1] => (item=nodejs)  => {"ansible_loop_var": "package", "changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "package": "nodejs", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-1] => (item=npm)  => {"ansible_loop_var": "package", "changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "package": "npm", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-1] => {"changed": false, "msg": "All items skipped"}
skipping: [test-mnx-ubuntu2204-x64-2] => (item=nodejs)  => {"ansible_loop_var": "package", "changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "package": "nodejs", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-2] => (item=npm)  => {"ansible_loop_var": "package", "changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "package": "npm", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-2] => {"changed": false, "msg": "All items skipped"}

TASK [fail if node is in the path - please uninstall it] ********************************************************************************************************************************************************
skipping: [test-mnx-ubuntu2204-x64-1] => {"changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-2] => {"changed": false, "false_condition": "not (alias is defined and alias is match('jenkins-workspace.*'))", "skip_reason": "Conditional result was False"}

TASK [fail if node is in the path - please uninstall it] ********************************************************************************************************************************************************
skipping: [test-mnx-ubuntu2204-x64-1] => {"changed": false, "false_condition": "os|startswith(\"win\")", "skip_reason": "Conditional result was False"}
skipping: [test-mnx-ubuntu2204-x64-2] => {"changed": false, "false_condition": "os|startswith(\"win\")", "skip_reason": "Conditional result was False"}

PLAY RECAP ******************************************************************************************************************************************************************************************************
test-mnx-ubuntu2204-x64-1  : ok=56   changed=1    unreachable=0    failed=0    skipped=125  rescued=0    ignored=0
test-mnx-ubuntu2204-x64-2  : ok=56   changed=1    unreachable=0    failed=0    skipped=125  rescued=0    ignored=0

when: os|startswith("win")
when:
- os|startswith("win")
- not (alias is defined and alias is match('jenkins-workspace.*'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this one isn't needed -- we have no "win*" hosts that are also jenkins-workspace but I've added it for consistency with all the other tasks.

@richardlau richardlau merged commit 1a94c74 into nodejs:main Jul 10, 2024
1 check passed
@richardlau richardlau deleted the jenkinsworkspace branch July 10, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants