Ansible - 错误!无法解析模块/操作'docker_swarm'

问题描述 投票:0回答:0

我创建了一个角色来使用下面的代码初始化 docker swarm

---
- name: Init docker swarm
  docker_swarm:
    state: present
  register: init_swarm

我还为docker安装创建了另一个角色:

---
- name: install libs
  apt:
    name:
      - apt-transport-https
      - ca-certificates
      - curl
      - gnupg
      - lsb-release
      - python3-pip
      - virtualenv
      - python3-setuptools
    state: present
    update_cache: yes

- name: install docker gpg key
  apt_key:
    url: https://download.docker.com/linux/ubuntu/gpg
    state: present

- name: Add docker repository
  apt_repository:
    repo: deb https://download.docker.com/linux/ubuntu bionic stable
    state: present

- name: install docker
  apt:
    name: 
      - docker-ce
      - docker-ce-cli 
      - containerd.io
    state: present

- name: install jsondiff
  pip:
    name: jsondiff  
    state: present
    
- name: install docker-compose
  apt:
    name: docker-compose
    state: present

但是我收到这个错误:

ERROR! couldn't resolve module/action 'docker_swarm'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/matheuslino86/projetos/fc-ansible/roles/docker_swarm_manager/tasks/main.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- name: Init docker swarm
  ^ here

我尝试通过执行“sudo ansible-galaxy collection install docker_swarm”来安装 docker swarm collection

docker ansible docker-swarm
© www.soinside.com 2019 - 2024. All rights reserved.