Ansible - Control commands when need users input when executing

蹲街弑〆低调 提交于 2019-12-06 08:20:54

Here is the Solution : add this before installing mariadb 10 task in your playbook

- name: debconf asking for password
  debconf:
   name: maria-db-10.0
   question: "{{ item }}"
   vtype: password
   value: "{{ mariadb_root_password }}"
  with_items:
   - mysql-server/root_password
   - mysql-server/root_password_again
trmiller

This is less of an ansible question and really a bash question. I'd suggest you take a look at this post and tie some of those into your playbook to do what you need.

The easiest for you in this case, is likely using a here string

tasks:
  - shell: "apt-get install mariadb-server <<< $'password\otherprompts\n'"
    sudo: true
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!