アンサーブルでヒントを渡す方法は?

アンサーブルでヒントを渡す方法は?

次のコマンドの実行中に、ansibleからプロンプトyを渡そうとします。サーバーで手動で実行すると、プロンプトが表示されます。シェルモジュールを使用して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): 

私のAnsibleスクリプト:

- 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"

ベストアンサー1

これはアンサーブル期待モジュール使用:

- 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"

(テストすることはできませんが、似たようなものはこれと同じです)

おすすめ記事