Hi people!
NB: I'm working in a test environment which will explain the topology used: I want to register a service on a consul server with the ACL policy enabled ans without using the anonymous token.
In the config file load by my first and only Consul server, I try to register a service: MyService-Foo. Eveything worked when I don't use ACL.
However, since I added ACL support to my cluster (with I think, proper ACL rules), the registration of MyService-Foo is blocked even if the check are done locally.
I expect my consul-server to follow rules put in the Master token but it's not the case. Nevertheless, when I change the anonymous token policy for service to "write", everything works as expected and the service is finally registered. I also tried to add, in addition to the master token declaration, another acl_token to the consul-server but as it is the server, it seems it can't have an acl_token in its config at the same time as serving an acl_master_token (that seems logic to me but if the consul-server acts as a node without a token and gets permissions from the anonymous token).
# Log
2015/12/13 18:52:14 [DEBUG] agent: Check 'service:MyService-Foo' is passing
2015/12/13 18:52:24 [DEBUG] agent: check 'service:MyService-Foo' script '/usr/bin/pgrep -x 'myservicedaemon'' output: 1423
2015/12/13 18:52:24 [DEBUG] agent: Check 'service:MyService-Foo' is passing
2015/12/13 18:52:34 [DEBUG] agent: check 'service:MyService-Foo' script '/usr/bin/pgrep -x 'myservicedaemon'' output: 1423
2015/12/13 18:52:34 [DEBUG] agent: Check 'service:MyService-Foo' is passing
2015/12/13 18:52:39 [DEBUG] agent: Service 'consul' in sync
2015/12/13 18:52:39 [WARN] agent: Service 'MyService-Foo' registration blocked by ACLs
# The configuration runs as followed:
exec /home/consul/bin/consul agent -server -config-file=/home/consul/bin/config.json
exec /home/consul/acl/consul-acl.sh
# Here is my config file for my consul-server:
{
"bootstrap": true,
"server": true,
"datacenter": "d1",
"data_dir": "/home/consul/data/",
"ui_dir": "/home/consul/ui",
"log_level": "debug",
"addresses": {
"http": "10.18.230.89"
},
"service": {
"name": "MyService-Foo",
"port": 6060,
"tags": [
"master"
],
"check": {
"notes": "Retrieve the service pid if it's running",
"script": "/usr/bin/pgrep -x 'myservicedaemon'",
"interval": "10s"
}
},
"acl_datacenter": "d1",
"acl_master_token": "'"$master_token"'",
"acl_default_policy": "deny",
"acl_down_policy": "deny",
"encrypt": "'"$encrypt_key"'"
}
# After launching the Consul startup script, I launch a script with some ACL rules:
"ID": "'"$master_token"'",
"Name": "Master token",
"Type": "management",
"Rules": "{\"service\": {\"\": {\"policy\": \"write\"}},\"event\": {\"\": {\"policy\": \"write\"}},\"keyring\": \"write\"}"
}'
# anonymous token
"ID": "anonymous",
"Name": "Anonymous Token",
"Type": "client",
"Rules": "{\"service\": {\"\": {\"policy\": \"read\"}},\"event\": {\"\": {\"policy\": \"read\"}},\"keyring\": \"read\"}"
}'