When receiving the value of the Service variable in the task "Definition of service", depending on its value, add a path to the task "Detecting the last version of service" according to certain values in the ServiceUp (ServiceUp records the same possible Service values)
vars: Service: "{{ TypeOfService }}" ServiceUP: - { Service: Service.1, ServiceUpSRC: path1 } - { Service: Service.2, ServiceUpSRC: path2 } tasks: - name: Definition of service raw: ls /home/user/ | grep Service register: TypeOfService - debug: msg="{{ TypeOfService.stdout_lines }}" - name: Detecting the last version of service raw: ls -tl /mnt/r/TypeOfService/{{ item.ServiceUpSRC }}/ | grep Linux | awk '{ print $9, $10, $11 }'| head -1 delegate_to: 127.0.0.1 register: version with_items: - "{{ ServiceUP }}" - debug: msg="{{ version.stdout_lines }}"
ServiceUpandServiceUPare different things - andreymal