Hi,
I am new to ansible and trying to test a playbook to check availability of a port number. If one found then use it, if not then go to the next one. Following is my playbook code,
tasks:
- name: check port number
become: yes
become_user: root
command: /bin/netstat -anp | grep “{{ item }}”
register: result
until: result.stdout.split()|length > 0
with_sequence: start=5432 end=5500
Unfortunately it did not work and get me the following error.
TASK [check port number] *******************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘int’
fatal: [pmr71dev402.auiag.corp]: FAILED! => {“failed”: true, “msg”: “Unexpected failure during module execution.”, “stdout”: “”}
Could someone please help and advise?
Also, if there is a better way to do this please feel free to advise me too.
Regards,
Andrew