ansible-consul
ansible-consul copied to clipboard
Can't get node to be a bootstrap server
Hi
I'm new to both consul and ansible and i'm trying to get a new datacenter built from the ground easier.
So I've been trying to get the first node to bootstrap the cluster. After dealing with some issues and learning a little how ansible/consul works, I finally get the tasks working.
But when i run "ps fax | grep consul" on the node, i see
13862 ? Ssl 0:00 /usr/local/bin/consul agent -config-file=/etc/consul/config.json -config-dir=/etc/consul/consul.d -pid-file=/var/run/consul/consul.pid
There is no -server, -bootstrap nor -bootstrap-expect=N parameters in the running process.
Here is my /etc/ansible/hosts file
[web_servers]
web.pve1.dc1.ispdigital consul_node_role=server consul_bootstrap_expect=True consul_bootstrap_expect_value=1
[consul_instances]
web.pve1.dc1.ispdigital
Here is my site.yml file
---
- hosts: consul_instances
vars:
consul_services:
- name: "apache"
tags: ['web']
become: yes
tasks:
- name: install apache2
apt:
name: apache2
update_cache: yes
state: latest
- name: install unzip
apt:
name: unzip
update_cache: yes
state: latest
- name: install pip
apt:
name: python-pip
update_cache: yes
state: latest
- name: edit index.html
shell:
echo $(hostname -f) > /var/www/html/index.html
- import_role:
name: consul
Thank you!
PD: Great role you have here!
The command line flags are instead set as configuration in the file, /etc/consul/config.json.
Also consider using consul_node_role for each of servers and clients. consul_bootstrap_expect_value is automatically calculated from the number of hosts with consul_node_role=server.
Hi Gurpartap!
Thank you for answering my post. Now it is working.
Thank you!