Use Consulate to export and import ACLs from Consul.
Setup your environment before you run these scripts:
export CONSUL_HOST="localhost"
export MASTER_TOKEN="myMasterToken"
Reference:
Use Consulate to export and import ACLs from Consul.
Setup your environment before you run these scripts:
export CONSUL_HOST="localhost"
export MASTER_TOKEN="myMasterToken"
Reference:
#!/usr/bin/env python | |
import consulate,json,os,sys | |
host=os.environ.get("CONSUL_HOST") | |
token=os.environ.get("MASTER_TOKEN") | |
consul = consulate.Consul(host=host,token=token) | |
print(json.dumps(consul.acl.list(), indent=2) |
#!/usr/bin/env python | |
import consulate,json,os,sys | |
host=os.environ.get("CONSUL_HOST") | |
token=os.environ.get("MASTER_TOKEN") | |
consul = consulate.Consul(host=host,token=token) | |
# Use argument | |
acls = json.loads(open(sys.argv[1]).read()) | |
# Use stdin | |
#j = json.load(sys.stdin) | |
for acl in acls: | |
name = acl.get('Name'), | |
acl_type = acl.get('Type'), | |
rules = acl.get('Rules') | |
acl_id = acl.get('ID') | |
try: | |
consul.acl.update(acl_id=acl_id,name=name,acl_type=acl_type,rules=rules) | |
except: | |
print("Error..") |