【发布时间】:2017-11-21 17:02:37
【问题描述】:
我正在尝试通过 ansible 在 docker 中运行 etcd 集群。
我使用 docker_container ansible 模块,这就是我所拥有的:
- name: Run etcd KV node
docker_container:
name: "etcd0"
image: quay.io/coreos/etcd
network_mode: host
command: [ "/usr/local/bin/etcd", \
"-name etcd0", \
"-advertise-client-urls http://{{ ansible_default_ipv4['address'] }}:2379,http://{{ ansible_default_ipv4['address'] }}:4001", \
"-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001", \
"-initial-advertise-peer-urls http://{{ ansible_default_ipv4['address'] }}:2380", \
"-initial-cluster etcd0=http://{{ ansible_default_ipv4['address'] }}:2380", \
"-initial-cluster-token etcd-cluster", \
"-listen-peer-urls http://0.0.0.0:2380", \
"-initial-cluster-state new" ]
这在单模式下工作,但是超过 1 个节点会出现问题,因为 etcd 参数 -initial-cluster 应该包含所有节点,例如,在 3 个节点的情况下:
-initial-cluster etcd0=http://192.168.12.50:2380,etcd1=http://192.168.12.51:2380,etcd2=http://192.168.12.52:2380
我不知道如何遍历所有节点并构建此字符串以运行一个 docker 容器。有可能吗?
【问题讨论】:
标签: docker ansible cluster-computing etcd