Send y key via Ansible

Hi, i want to add this command to my Ansible Playbook
reload from working rollback-timeout 20
The Output should be like this:

-> reload from working rollback-timeout 20 
Confirm Activate (Y/N) :

But in Ansible i receive this Error

FAILED! => {"changed": false, "msg": "y\r\n                               ^\r\nERROR: Invalid entry: \"y\"\r\n\r\n-> "}```

Playbook:

- name: Reload from working
  alcatel.aos8.aos8_command:
    commands:
      - "reload from working no rollback-timeout"
  register: raw_reload_from_working_no_rollback_timeout_output

- name: Handle activation confirmation if required
  when: "'Confirm Activate (Y/N) :' in raw_reload_from_working_no_rollback_timeout_output.stdout"
  alcatel.aos8.aos8_command:
    commands:
      - "Y"
  register: confirm_response_output

- name: Debug output
  debug:
    msg:
      - "Reload command output: {{ raw_reload_from_working_no_rollback_timeout_output }}"
      - "Confirm response output: {{ confirm_response_output | default('No confirmation required') }}"

The alcatel.aos8 collection is not publicly available, so I can’t speak for it, but this is how you do it with ansible.netcommon.cli_command:

- name: Reload from working
  ansible.netcommon.cli_command:
    command: "reload from working no rollback-timeout 20"
    prompt: "Confirm Activate"
    answer: "y"
1 Like