Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ansible/xray] Expect - extra characters after close-quote #424

Open
EmptyByte opened this issue Oct 28, 2024 · 0 comments
Open

[ansible/xray] Expect - extra characters after close-quote #424

EmptyByte opened this issue Oct 28, 2024 · 0 comments

Comments

@EmptyByte
Copy link

The following error is returned when running tasks Interactive with expect:

extra characters after close-quote
    while executing
"send ""h"
    invoked from within
"expect {
                    -nocase -re {(data|installation) directory \(.*} {
                send "/opt/jfrog/xray\n"
            }
               ..."
    ("while" body line 2)
    invoked from within
"while { $CYCLE_END == 0 } {
    expect {
                    -nocase -re {(data|installation) directory \(.*} {
                send "/opt/jfrog/xray\..."

Ansible/ansible_collections/jfrog/platform/roles/xray/tasks/expect.yml

- name: Prepare expect scenario script
  ansible.builtin.set_fact:
    expect_scenario: |
        set timeout 300
        spawn {{ exp_executable_cmd }}
        expect_before timeout { exit 1 }
        set CYCLE_END 0
        set count 0

        while { $CYCLE_END == 0 } {
            expect {
                {% for each_request in exp_scenarios %}
                    -nocase -re {{ '{' }}{{ each_request.expecting }}.*} {
                        send "{{ each_request.sending }}\n"
                    }
                {% endfor %}
                eof {
                    set CYCLE_END 1
                }
            }
            set count "[expr $count + 1]"
            if { $count > 16} {
                exit 128
            }
        }

        expect eof
        lassign [wait] pid spawnid os_error_flag value

        if {$os_error_flag == 0} {
            puts "INSTALLER_EXIT_STATUS-$value"
        } else {
            puts "INSTALLER_EXIT_STATUS-$value"
        }

Maybe the task should have proper closing:

- name: Prepare expect scenario script
  ansible.builtin.set_fact:
    expect_scenario: |
        set timeout 300
        spawn {{ exp_executable_cmd }}
        expect_before timeout { exit 1 }
        set CYCLE_END 0
        set count 0

        while { $CYCLE_END == 0 } {
            expect {
                {% for each_request in exp_scenarios %}
                    -nocase -re {{ '{' }}{{ each_request.expecting }}.*{{ '}' }} {
                        send "{{ each_request.sending }}\n"
                    }
                {% endfor %}
                eof {
                    set CYCLE_END 1
                }
            }
            set count "[expr $count + 1]"
            if { $count > 16 } {
                exit 12
            }
        }

        expect eof
        lassign [wait] pid spawnid os_error_flag value

        if {$os_error_flag == 0} {
            puts "INSTALLER_EXIT_STATUS-$value"
        } else {
            puts "INSTALLER_EXIT_STATUS-$value"
        }
@EmptyByte EmptyByte changed the title [ansible/xray] [ansible/xray] Expect - extra characters after close-quote Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant