@@ -18,6 +18,12 @@ chmod 0600 ~/.ssh/maguec1.pem
# After ansible
+```
+# download roles
+cd ansible && rm -rf roles/* && ansible-galaxy install --roles-path roles -r requirements.yml
+
```
ansible-playbook ansible/cp_nodes.yml --private-key ~/.ssh/maguec1.pem -i inventories/maguec1_all_nodes.ini
@@ -27,6 +27,12 @@
- 19911
- 19912
+ handlers:
+ - name: restart_consul
+ service:
+ name: consul
+ state: restarted
pre_tasks:
- name: Update Apt Cache
apt: update_cache=yes cache_valid_time=86400
@@ -96,3 +102,16 @@
roles:
- consul
+ post_tasks:
+ - name: Redis Consul Services
+ template:
+ src: redis.services.j2
+ dest: /opt/consul/consul.d/redis.json
+ owner: consul
+ group: consul
+ mode: 0644
+ notify:
+ - restart_consul
@@ -0,0 +1,9 @@
+{"services": [
+{% for port in redis_ports -%}
+ {"name": "redis-{{ port }}",
+ "port": {{ port }},
+ "checks": [{"script": "redis-cli -p {{ port }} --raw RAFT.INFO |grep -q '^role:leader'", "interval": "0.5s"}]
+ }{% if port != redis_ports[-1] %},{% endif %}
+{% endfor -%}
+]}