Ansible:删除程序并在命令提示符下输入 'yes'?

标签 ansible

我正在尝试删除 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/

相关文章:

ansible - 如何在 Ansible 中跳过主机存储库并指定主机运行时

postgresql - ansible postgres向数据库添加多个扩展(嵌套循环)

jquery - 使用 Jquery (jmespath) 从 Ansible 获取 API 调用

ansible - ansible 是否有任何允许调试/暂停的功能?

powershell - Ansible winrm_server_cert_validation HTTPS 安全

ansible - 当列为依赖项时,如何防止 ansible 角色多次运行?

ssh - 期望脚本运行 Ansible playbook

mongodb - 库存文件 - child 组 - Ansible 中

macos - 如何在 Mac 上降级和安装 ansible 1.9.4

ansible - 在 Ansible 的 vars_prompt 中使用变量作为默认值