You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ansible中使用snap模块安装未签名Cider时如何传递--dangerous参数?

解决方案

方法1:使用community.general.snap模块的extra_args参数

community.general.snap模块的options参数仅支持传递snap命令的全局选项(如--verbose),而--dangerous是snap install子命令的专属选项,需要通过extra_args参数传递——该参数专门用于追加子命令的额外参数。

示例Playbook任务:

- name: 安装未签名的Cider snap包
  community.general.snap:
    name: /tmp/cider_1.5.9_amd64.snap
    state: present
    extra_args: "--dangerous"

方法2:用ansible.builtin.command模块实现安全幂等安装

如果你的community.general集合版本过低(无extra_args参数),可以使用command模块替代shell模块,通过creates参数确保任务幂等性(仅当目标文件不存在时执行),避免重复安装:

- name: 安装未签名的Cider snap包
  ansible.builtin.command:
    cmd: snap install /tmp/cider_1.5.9_amd64.snap --dangerous
    creates: /snap/bin/cider

内容的提问来源于stack exchange,提问作者Cdhippen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 16:50:22