Skip to content

Commit 1a94c74

Browse files
authored
ansible: dynamically exclude jenkins-workspace (#3816)
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.
1 parent 1e39f05 commit 1a94c74

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ansible/playbooks/jenkins/worker/create.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@
8686
- hosts:
8787
- test
8888
- release
89-
- "!test-equinix-ubuntu2204-x64-1"
90-
- "!test-equinix-ubuntu2204-x64-2"
91-
- "!test-ibm-ubuntu2204-x64-3"
9289
tasks:
9390
- name: remove node and npm packages
9491
when:
@@ -97,20 +94,25 @@
9794
- not os|startswith("win")
9895
- not os|startswith("zos")
9996
- os != "macos11.0"
97+
- not (alias is defined and alias is match('jenkins-workspace.*'))
10098
package:
10199
name: "{{ package }}"
102100
state: absent
103101
loop_control:
104102
loop_var: package
105103
with_items: [ "node", "nodejs", "npm" ]
106104
- name: fail if node is in the path - please uninstall it
107-
when: not os|startswith("win")
105+
when:
106+
- not os|startswith("win")
107+
- not (alias is defined and alias is match('jenkins-workspace.*'))
108108
shell: "node -v"
109109
register: node_check_cmd
110110
failed_when: node_check_cmd.rc == 0
111111
changed_when: False
112112
- name: fail if node is in the path - please uninstall it
113-
when: os|startswith("win")
113+
when:
114+
- os|startswith("win")
115+
- not (alias is defined and alias is match('jenkins-workspace.*'))
114116
win_shell: "node -v"
115117
register: node_check_cmd_win
116118
failed_when: node_check_cmd_win.rc == 0

0 commit comments

Comments
 (0)