Начиная с текущей версии Redis (5.0.5), под --cluster
нет флага, который мог бы заставить замолчать или автоматически ответить на интерактивный вопрос:
$ redis-cli --cluster help
Cluster Manager Commands:
create host1:port1 ... hostN:portN
--cluster-replicas <arg>
check host:port
--cluster-search-multiple-owners
info host:port
fix host:port
--cluster-search-multiple-owners
reshard host:port
--cluster-from <arg>
--cluster-to <arg>
--cluster-slots <arg>
--cluster-yes
--cluster-timeout <arg>
--cluster-pipeline <arg>
--cluster-replace
rebalance host:port
--cluster-weight <node1=w1...nodeN=wN>
--cluster-use-empty-masters
--cluster-timeout <arg>
--cluster-simulate
--cluster-pipeline <arg>
--cluster-threshold <arg>
--cluster-replace
add-node new_host:new_port existing_host:existing_port
--cluster-slave
--cluster-master-id <arg>
del-node host:port node_id
call host:port command arg arg .. arg
set-timeout host:port milliseconds
import host:port
--cluster-from <arg>
--cluster-copy
--cluster-replace
help
Используя echo
, вы можете выполнить команду и автоматически ответить на приглашение:
echo "yes" | redis-cli --cluster create host1:6379 host2:6379 host3:6379
Модуль по умолчанию * Ansible Redis поддерживает только несколько команд, а не --cluster
, поэтому вам придется создавать собственную логику с задачами команда / оболочка:
- name: Create cluster
shell: echo "yes" | redis-cli --cluster create host1:6379 host2:6379 host3:6379
run_once: true
when: not cluster_setup_done