我正在尝试删除 ansible playbook 中的系统 gem,但我正在运行的命令需要用户输入才能完成:
- name: uninstall graphviz gem
command: sudo -i gem uninstall ruby-graphviz
sudo: True
当我运行我的剧本时,我发现 ansible 在到达上面的代码时挂起。我认为这是因为需要用户输入才能完成此任务。
那么我如何告诉 ansible 删除 gem,并对操作系统可能向用户提出的任何后续问题说"is"?
最佳答案
来自文档:
RubyGems will ask for confirmation if you are attempting to uninstall a gem that is a dependency of an existing gem. You can use the –ignore-dependencies option to skip this check.
因此,您只需将命令更改为gem uninstall --ignore-dependencies ruby-graphviz
。
附注你应该更好地使用sudo
or become
directives而不是 sudo 命令。
关于Ansible:删除程序并在命令提示符下输入 'yes'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29818735/