-2

I'm trying to install no-ip's Dynamic Update Client. I'm using the expect module to answer every prompt, but each time the script ask for my password, it adds another character and does not enter the password (the command exceeded timeout).

Here is my task (noip_email and noip_password are variables from a vault. I tried printing them and they are correct).

- name: DNS - install no-ip DUC
  ansible.builtin.expect:
    command: "make install"
    chdir: /usr/local/src/noip
    echo: true
    responses:
      "By typing the number associated with it": "0"
      "login/email": "{{ noip_email }}"
      "password": "{{ noip_password }}"
      "update interval": "20"
      "run something": "n"

I tried to simplify the matching word; using the full sentence; not using variables (from a vault); I tried not to match output (see the second example in ansible's doc), tried a bigger timeout, and also tried adding manual "enter" with \n at the end of the prompt.

None of the solution I tried or found on the internet worked, and I ran out of ideas. I really don't know why it adds another character to the password input, and why it doesn't enter (\n) my password, especially when every other prompt is correct and entered.

System:

  • Ansible 2.13.5
  • Python 3.10
  • Ubuntu 22.04, Raspberry Pi 4 8Gb
tholeb
  • 174
  • 3
  • 13
  • My guess is that the password is encrypted with ansible-vault? could it be that the value encrypted has the extra-character? if you print the value with `debug`, does the extra character appear? – Carlos Monroy Nieblas Dec 27 '22 at 01:40
  • No, i've tried that, and it prints the good password. Also, I tried putting a single char, and it always ends up with 2 '*' for the password – tholeb Dec 27 '22 at 09:25
  • I've been unable to replicate the issue, could you give us more detail of the steps, environment (like the ansible version used)? – Carlos Monroy Nieblas Dec 27 '22 at 16:31
  • of course, i'm using Ansible 2.13.5 with python 3.10. I'm trying to install this on a raspberry pi 8Gb, with Ubuntu 22.04. – tholeb Dec 27 '22 at 20:29

1 Answers1

0

I've solved my issue by using the expect binary with the shell module.

- name: DNS - install no-ip DUC
  ansible.builtin.shell: |
    set timeout 30
    spawn make install

    expect "number associated"
    send "0\n"

    expect "email"
    send "{{ noip_email }}\n"

    expect "password"
    send "{{ noip_password }}\n"

    expect "update"
    send "20\n"

    expect "run"
    send "n\n"
  args:
    executable: /usr/bin/expect
    chdir: /usr/local/src/noip
tholeb
  • 174
  • 3
  • 13