--- # Stand-ins for what the scenario cannot have: the Cloudflare API (a stub on the controller's # loopback), an installed cloudflared (a stub binary reporting 2026.1.0, so the converge updates # it), and the release files of two newer versions behind file:// URLs. The configured sha256 is # the hash of the stub of the requested version, so 2026.2.0 verifies and 2026.3.0 does only when # a case passes its hash. A stale tunnel credentials file and an unrelated JSON file are seeded # in the config directory: configure must remove the first and keep the second. - name: Prepare hosts: all gather_facts: false tasks: - name: Remove the state of an earlier stub run delegate_to: localhost run_once: true ansible.builtin.file: path: "{{ cloudflared_test_stub_dir }}" state: absent # Runs in the background until cleanup.yml stops it, or until its lifetime, kept below the # workflow's 30-minute job timeout, runs out. - name: Start the Cloudflare API stub on the controller delegate_to: localhost run_once: true ansible.builtin.command: argv: - "{{ ansible_playbook_python }}" - -I - "{{ playbook_dir }}/files/cloudflare_api_stub.py" - --state-dir - "{{ cloudflared_test_stub_dir }}" - --lifetime - "1500" async: 1500 poll: 0 changed_when: true - name: Wait for the stub to listen delegate_to: localhost run_once: true ansible.builtin.wait_for: path: "{{ cloudflared_test_stub_dir }}/port" timeout: 30 - name: Create the download and config directories ansible.builtin.file: path: "{{ cloudflared_test_dir }}" state: directory mode: "0755" loop: [/opt/molecule-download, /etc/cloudflared] loop_control: loop_var: cloudflared_test_dir - name: Write the installed stub binary and the release files ansible.builtin.copy: dest: "{{ cloudflared_test_release.dest }}" mode: "0755" content: "{{ cloudflared_test_stub | replace('@VERSION@', cloudflared_test_release.version) }}" loop: - {dest: /usr/local/bin/cloudflared, version: 2026.1.0} - {dest: /opt/molecule-download/cloudflared-2026.2.0, version: 2026.2.0} - {dest: /opt/molecule-download/cloudflared-2026.3.0, version: 2026.3.0} loop_control: loop_var: cloudflared_test_release label: "{{ cloudflared_test_release.dest }}" - name: Seed a stale credentials file and an unrelated JSON file ansible.builtin.copy: dest: "/etc/cloudflared/{{ cloudflared_test_seed }}" mode: "0600" content: "{}\n" loop: - 6f1a6e2c-0000-4000-8000-000000000000.json - notes.json loop_control: loop_var: cloudflared_test_seed