From bcbc0269d679d3a9cd0f41ebc5ef92f10fc5783c Mon Sep 17 00:00:00 2001 From: "martin.fencl" Date: Fri, 5 Dec 2025 15:03:50 +0100 Subject: [PATCH] test --- test.yml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test.yml diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..bba62bd --- /dev/null +++ b/test.yml @@ -0,0 +1,58 @@ +- name: Test connectivity from Semaphore container to Homarr VMs + hosts: localhost + gather_facts: false + + vars: + # List of VMs you want to test + vm_targets: + - { ip: "192.168.69.253" } + - { ip: "192.168.69.254" } + + # Credentials (ideálně z env/secret) + vm_user: "{{ lookup('env', 'VM_USER') | default('howard') }}" + vm_pass: "{{ lookup('env', 'VM_PASS') }}" + + tasks: + - name: Ensure sshpass is installed (inside container) # install sshpass + ansible.builtin.apt: + name: sshpass + state: present + update_cache: yes + + - name: Ping VM IPs from container # simple ICMP ping + ansible.builtin.command: "ping -c 2 {{ item.ip }}" + loop: "{{ vm_targets }}" + register: ping_results + ignore_errors: true + + - name: Show ping results + ansible.builtin.debug: + msg: "Ping to {{ item.item.ip }} -> rc={{ item.rc }}, stdout={{ item.stdout }}" + loop: "{{ ping_results.results }}" + + - name: Test SSH to VM with sshpass # real SSH test + ansible.builtin.command: + argv: + - sshpass + - -e + - ssh + - -o + - StrictHostKeyChecking=no + - -o + - ConnectTimeout=5 + - "{{ vm_user }}@{{ item.ip }}" + - "echo OK-from-{{ item.ip }}" + environment: + SSHPASS: "{{ vm_pass }}" + loop: "{{ vm_targets }}" + register: ssh_results + ignore_errors: true + + - name: Show SSH results + ansible.builtin.debug: + msg: | + SSH to {{ item.item.ip }}: + rc={{ item.rc }} + stdout={{ item.stdout }} + stderr={{ item.stderr }} + loop: "{{ ssh_results.results }}"