如何通过Ansible在气隙系统上安装snap软件包

如何通过Ansible在气隙系统上安装snap软件包,ansible,offline,snapcraft,Ansible,Offline,Snapcraft,在连接到internet的系统上通过Ansible安装snap软件包相当简单。例如: - name: Install microk8s become: yes snap: name: microk8s classic: yes channel: "{{ microk8s_version }}" 现在,我需要在一组有气隙的节点(没有直接连接到internet)上执行同样的操作。 我可以对所需的软件包进行“快照下载”,并将

在连接到internet的系统上通过Ansible安装snap软件包相当简单。例如:

  - name: Install microk8s
    become: yes
    snap:
      name: microk8s
      classic: yes
      channel: "{{ microk8s_version }}"
现在,我需要在一组有气隙的节点(没有直接连接到internet)上执行同样的操作。 我可以对所需的软件包进行“快照下载”,并将其移动到目标计算机。 但在Ansible中如何做到这一点呢?有人支持吗?还是必须使用shell/命令模块


thx

如果您可以将软件包放到Ansible服务器上,以下代码将文件复制到目标服务器。下面的代码应该可以工作

  - name: copy files/local/microk8s.deb
    copy: 
      src: "files/local/microk8s.deb"
      dest: "~/microk8s.deb"
      remote_src: no

其中
文件/
与剧本处于同一级别。

我没有测试过,但此方法适用于其他模块

  - name: install microk8s, file on local disk
    become: yes
    snap:
      name: /path/to/file

使用@Kevin C的提示,我能够使用下面的剧本解决这个问题

  - name: copy microk8s snap to remote
    copy: 
      src: "{{ item }}"
      dest: "~/microk8s/"
      remote_src: no
    with_fileglob: 
      - "../files/microk8s/*"

  - name: snap ack the new package
    become: yes
    shell: |
       snap ack ~/microk8s/microk8s_1910.assert
       snap ack ~/microk8s/core_10583.assert

  - name: install microk8s, file on local disk
    become: yes
    snap:
      name: "~/microk8s/core_10583.snap"

  - name: install microk8s, file on local disk
    become: yes
    snap:
      name: "~/microk8s/microk8s_1910.snap"
      classic: yes
我希望这对其他人也有帮助。
很高兴看到这篇文档。

Thx。但这仍然意味着我需要通过“shell:snap install microk8s.deb”进行“安装”,并处理周围的任何问题,对吗?是的,你是对的。虽然有一个安装程序,但它似乎没有从本地文件安装的选项。所以这需要一个shell命令。对,有可能。thx@Kevin C。我设法让它工作。我将在单独的答案中添加代码