I have to run a shell script only if selected server (derived from external vars) is not equal to given ip (in when condition ) , The problem here is there are many ip i can add all the ip list in the when condition but the list is huge which results in lengthy playbook . Is a best way to reduce the line of code . The present script is
- name: Copy self sign certificate script
copy:
src: ../playbooks/self_sign_cert.sh
dest: /tmp/self_sign_cert.sh
mode: 0755
ignore_errors: yes
when: selected_server != '10.0.0.1' and selected_server != '10.0.0.2' and selected_server != '10.0.0.3' and selected_server != '10.0.0.4' and selected_server != '10.0.0.4' and selected_server != '10.0.0.5' and selected_server != '10.0.0.6' and selected_server != '10.0.0.7'