0

I am trying to pass a prompt y in ansible when it executes the below command. When i do manually on server it asks for a prompt. How should i do it with ansible using shell module.Please help with passing the prompt in ansible

ubuntu@ip-xx-xxx-xx-xx:~$ tsm pending-changes apply
This operation will perform a server restart. Are you sure you wish to continue?
(y/n): 

My ansible script:

- name: Apply pending configuration changes
  shell: source /etc/profile.d/tableau_server.sh && tsm pending-changes apply -u ubuntu -p '{{ tableau_server_admin_password }}' |
    expect "This operation will perform a server restart. Are you sure you wish to continue?\(y\/n\)"
    send "y\n"
  args:
    executable: /bin/bash
  when: inventory_hostname == "xx.xxx.xx.xx"
0

This is what the ansible expect module is for:

- name: Apply pending configuration changes
  expect:
    command: /bin/bash -c "source /etc/profile.d/tableau_server.sh && tsm pending-changes apply -u ubuntu -p '{{ tableau_server_admin_password }}'"
    responses:
      '(y/n):': y
  when: inventory_hostname == "xx.xxx.xx.xx"

(Not able to test but something like this is how it should work)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.