---
- name: Playbook to conditionally wait for 10 minutes if hostname contains "pattern"
  hosts: all
  gather_facts: yes  # Ensures facts are available
  strategy: free  # Allows hosts to execute tasks independently
  tasks:
    - name: Display the hostname
      ansible.builtin.debug:
        msg: "The hostname is: {{ ansible_facts['hostname'] }}"

    - name: Wait for 10 minutes if hostname contains "pattern"
      ansible.builtin.wait_for:
        timeout: 600  # Wait for 600 seconds (10 minutes)
      when: "'pattern' in ansible_facts['hostname']"

    - name: Dummy task to output hello world
      ansible.builtin.debug:
        msg: "Hello, world!"
