--- # Nmap port test - name: General | Tests | nmap | Set Facts set_fact: nmap_file: "{{ user_user.home }}/Reports/{{ ansible_hostname }}.{{ nmap_report }}" nmap_separator: "\n*******************************\n" - name: General | Tests | nmap | Set Facts 2 set_fact: nmap_temp_file: "{{ nmap_file }}.tmp" - name: General | Tests | nmap | Create Report shell: "{{ item }}" loop: - "date > {{ nmap_temp_file }}" - "printf '{{ nmap_separator }}' >> {{ nmap_temp_file }}" - "echo '\n-=Open Ports=-\n' >> {{ nmap_temp_file }}" - "printf 'Number of open ports: ' >> {{ nmap_temp_file }}" - "nmap --open localhost | grep -c open >> {{ nmap_temp_file }}; echo success" - "nmap --open localhost | grep open >> {{ nmap_temp_file }}; echo success" - "printf '{{ nmap_separator }}' >> {{ nmap_temp_file }}" - "echo '\n-=Aggressive Vulnerability Check=-\n' >> {{ nmap_temp_file }}" - "nmap -A localhost >> {{ nmap_temp_file }}; echo success" - "mv {{ nmap_temp_file }} {{ nmap_file }}" - name: General | Tests | nmap | Make Viewable file: path: "{{ nmap_file }}" mode: '0644'