渲染 SLS 'base:docker.manager.first' 失败:Jinja 变量列表对象没有元素 0

Rendering SLS 'base:docker.manager.first' failed: Jinja variable list object has no element 0

你好,我一直在尝试设置一个 Docker Swarm with Salt,但我有点卡住了...

我在申请时遇到以下错误:

Data failed to compile:
              ----------
                  Rendering SLS 'base:docker.manager.first' failed: Jinja variable list object has no element 0

这是我的 first.sls:

{% set manager_ip = salt['mine.get']('*', 'manager_ip').items()[0][1][0] %}

include:
  - docker.base

init new swarm cluster:
  cmd.run:
    - name: 'docker swarm init --advertise-addr {{ manager_ip }}'
    - require:
      - pkg: docker-ce

这是我的 /srv/pillar/swarm.sls,它提供 mine_functions:

mine_functions:
  network.ip_addrs: [ens32]
  manager_token:
    - mine_function: cmd.run
    - "docker swarm join-token manager -q"
  manager_ip:
    - mine_function: network.ip_addrs
    - ens32
  worker_token:
    - mine_function: cmd.run
    - "docker swarm join-token worker -q"

当运行盐'*'pillar.items:

----------
mine_functions:
    ----------
    manager_ip:
        |_
          ----------
          mine_function:
              network.ip_addrs
        - ens32
    manager_token:
        |_
          ----------
          mine_function:
              cmd.run
        - docker swarm join-token manager -q
    network.ip_addrs:
        - ens32
    worker_token:
        |_
          ----------
          mine_function:
              cmd.run
        - docker swarm join-token worker -q

我该如何解决这个问题,或者有什么已知的方法可以使用 Salt 设置 Docker Swarm?

更改了变量名:

旧:

{% set manager_ip = salt['mine.get']('*', 'manager_ip').items()[0][1][0] %}

include:
  - docker.base

init new swarm cluster:
  cmd.run:
    - name: 'docker swarm init --advertise-addr {{ manager_ip }}'
    - require:
      - pkg: docker-ce

新:

{% set join_ip = salt['mine.get']('*', 'manager_ip').items()[0][1][0] %}

include:
 - docker.base

init cluster:
  cmd.run:
    - name: 'docker swarm init --advertise-addr {{ join_ip }}'
    - require:
      - pkg: docker-ce