|
Currently we have a case where we want to either run a command locally or remotely. If running locally it is likely a different command for the task than remotely. Here is how I currently understand how we might do that: target def: targets:
groups:
some_list:
- host: 1.2.3.4
name: node_1
- host: 5.6.7.8
name: node_2playbook: tasks:
- name: Run a check via ssh
targets:
- some_list
commands:
- name: Run the check and store result
script: |
if [[ `echo ${SPOT_REMOTE_NAME} |grep 'helm_'` ]]; then
exit;
fi
ls -a
options:
ignore_errors: true
sudo: true
- name: Run a check using kubectl
commands:
- name: Run the check and store result
script: |
if [[ `echo ${SPOT_REMOTE_NAME} |grep 'helm_'` ]]; then
kubectl do something;
fi
options:
ignore_errors: true
sudo: true
local: trueHowever, this adds overhead as it contains twice as many commands when we only really need one. Ideally, we could toggle That might look something like this: target def: targets:
groups:
some_list:
- host: 127.0.0.1
name: node_1
- host: 5.6.7.8
name: node_2
- host: 127.0.0.1
name: node_3tasks:
- name: Run a check
targets:
- some_list
commands:
- name: Run the check and store result
script: |
if [[ `echo ${SPOT_REMOTE_NAME} |grep 'helm_'` ]]; then
kubectl do something;
else
ls -a
fi
options:
ignore_errors: true
sudo: trueIn the proposed approach here, spot would not use Does something like this seam reasonable, or would you suggest another approach? |
added with
--localflag, see #318