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

时间:2019-03-01 18:47:12

标签: docker jinja2 docker-swarm salt-stack

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

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

public class ProcessKeyOnTextFieldTest {

    @Test
    public void pressKeyTest() throws Exception {
        JTextFieldWithTypedKeySupport textField = new JTextFieldWithTypedKeySupport();

        textField.pressKey('a');
        textField.pressKey('b');

        assertEquals("ab", textField.getText());
    }

    class JTextFieldWithTypedKeySupport extends JTextField {

        int timestamp;

        void pressKey(char key) throws InvocationTargetException, InterruptedException {
            SwingUtilities.invokeAndWait(() -> super.processKeyEvent(createEvent(key)));
        }

        KeyEvent createEvent(char keyChar) {
            return new KeyEvent(this, KeyEvent.KEY_TYPED, timestamp++, 0, KeyEvent.VK_UNDEFINED, keyChar);
        }
    }
}

这是我的first.sls:

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

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

{% 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

运行盐“ *”支柱时。

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"

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

1 个答案:

答案 0 :(得分:0)

更改了变量名称:

OLD:

{% 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