I would like to detect if a server listens on port 80 or 443, I have a list of IPs that I get from an API.
- name: "Try https on the remote server"
uri:
url: "https://{{ item.ipAdress }}"
method: GET
timeout: 1
validate_certs: no
register: https_result
failed_when: "'FAILED' in https_result"
with_items: "{{ results.json }}"
When I run this code I get status -1 if the connection fails and status 200 if the connection works.
After this I would like to make 2 lists with IPs, one that failed and one that worked, then I use these two lists in a template and make a working config.
But I can’t figure out how to solve this bit. Does anyone have any ideas?