Compare commits
	
		
			4 Commits
		
	
	
		
			a4b46fa384
			...
			91d7e727c0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 91d7e727c0 | |||
| b92ae07769 | |||
| 797a010dd0 | |||
| 5d11328a5b | 
							
								
								
									
										51
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								README.md
									
									
									
									
									
								
							@@ -1,3 +1,52 @@
 | 
				
			|||||||
# remco-docker-config
 | 
					# remco-docker-config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Provides remco configs and resources to easily set up Docker and Docker Compose environment files
 | 
					Provides [remco](https://github.com/HeavyHorst/remco) configs and resources to easily set up Docker and Docker Compose environment files with HashiCorp Vault secrets
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# How to run
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Set environment variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Set these mandatory variables, fill in real values
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					# Largely static
 | 
				
			||||||
 | 
					export REMCO_DOCKER_CONFIG='/path/to/this/dir'
 | 
				
			||||||
 | 
					export VAULT_ADDR='https://127.0.0.1:8200/'
 | 
				
			||||||
 | 
					export VAULT_TOKEN='hvs.BerthaIsDeNigrAtinGtHEiMP'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Changes per container and context
 | 
				
			||||||
 | 
					export DOCKER_FQDN='containers-3.example.net'
 | 
				
			||||||
 | 
					export DOCKER_GROUP_NAME='grafana'
 | 
				
			||||||
 | 
					export DOCKER_CTX='bi_shenyang'
 | 
				
			||||||
 | 
					export VAULT_KEY='/kv/data/docker/${DOCKER_GROUP_NAME}/'"${DOCKER_CTX}"
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Treat `DOCKER_CTX` as a team name, purpose or scope. If the same Docker application can run multiple times and serve different tenants then `DOCKER_CTX` is what distinguishes one instance from the other. Here `bi_shenyang` indicates for example a Shenyang-based Business Intelligence team.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Render config files
 | 
				
			||||||
 | 
					Let `remco` generate an environment file
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					remco -config config.toml
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Output will look somewhat like this (no change needed):
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					[INFO]  set backend nodes: backend=vault nodes=["https://127.0.0.1:8200/"] prefix=remco[671145]
 | 
				
			||||||
 | 
					[DEBUG] retrieving keys: backend=vault key_prefix="\"\"" prefix=remco[671145] resource=grafana
 | 
				
			||||||
 | 
					[DEBUG] compiling source template: prefix=remco[671145] resource=grafana template=/tmp/remco-docker-config/templates.d/grafana/fqdn-context.env
 | 
				
			||||||
 | 
					[DEBUG] comparing staged and dest config files: dest=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env prefix=remco[671145] resource=grafana staged=.containers-3.example.net-bi_shenyang.env2016234729
 | 
				
			||||||
 | 
					[DEBUG] target config in sync: config=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env prefix=remco[671145] resource=grafana
 | 
				
			||||||
 | 
					[DEBUG] closing client connection: backend=vault prefix=remco[671145] resource=grafana
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Or like this (target file does not have correct content):
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					[INFO]  set backend nodes: backend=vault nodes=["https://127.0.0.1:8200/"] prefix=remco[675012]
 | 
				
			||||||
 | 
					[DEBUG] retrieving keys: backend=vault key_prefix="\"\"" prefix=remco[675012] resource=grafana
 | 
				
			||||||
 | 
					[DEBUG] compiling source template: prefix=remco[675012] resource=grafana template=/tmp/remco-docker-config/templates.d/grafana/fqdn-context.env
 | 
				
			||||||
 | 
					[DEBUG] comparing staged and dest config files: dest=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env prefix=remco[675012] resource=grafana staged=.containers-3.example.net-bi_shenyang.env3921647901
 | 
				
			||||||
 | 
					[INFO]  wrong hashsum: config=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env current=da39a3ee5e6b4b0d3255bfef95601890afd80709 new=97aacc05e6ccad77fec95cc5daa4b3cb7ccd03eb prefix=remco[675012] resource=grafana
 | 
				
			||||||
 | 
					[INFO]  target config out of sync: config=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env prefix=remco[675012] resource=grafana
 | 
				
			||||||
 | 
					[DEBUG] overwriting target config: config=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env prefix=remco[675012] resource=grafana
 | 
				
			||||||
 | 
					[INFO]  target config has been updated: config=/tmp/remco-docker-config/rendered.d/grafana/containers-3.example.net-bi_shenyang.env prefix=remco[675012] resource=grafana
 | 
				
			||||||
 | 
					[DEBUG] closing client connection: backend=vault prefix=remco[675012] resource=grafana
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								config.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								config.toml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					log_level = "debug"
 | 
				
			||||||
 | 
					log_format = "text"
 | 
				
			||||||
 | 
					retries = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[resource]]
 | 
				
			||||||
 | 
					name = "${DOCKER_GROUP_NAME}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[resource.template]]
 | 
				
			||||||
 | 
					  src = "${REMCO_DOCKER_CONFIG}/templates.d/${DOCKER_GROUP_NAME}/fqdn-context.env"
 | 
				
			||||||
 | 
					  dst = "${REMCO_DOCKER_CONFIG}/rendered.d/${DOCKER_GROUP_NAME}/${DOCKER_FQDN}_${DOCKER_CTX}.env"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  [resource.backend]
 | 
				
			||||||
 | 
					    [resource.backend.vault]
 | 
				
			||||||
 | 
					      node = "${VAULT_ADDR}"
 | 
				
			||||||
 | 
					      auth_type = "token"
 | 
				
			||||||
 | 
					      auth_token = "${VAULT_TOKEN}"
 | 
				
			||||||
 | 
					      onetime = true
 | 
				
			||||||
 | 
					      keys = ["${VAULT_KEY}"]
 | 
				
			||||||
							
								
								
									
										2
									
								
								rendered.d/zabbixserver/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								rendered.d/zabbixserver/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					!.gitignore
 | 
				
			||||||
 | 
					*.env
 | 
				
			||||||
							
								
								
									
										9
									
								
								templates.d/zabbixserver/fqdn-context.env
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								templates.d/zabbixserver/fqdn-context.env
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					{% set VAULT_KEY = getenv("VAULT_KEY") %}
 | 
				
			||||||
 | 
					# This file is maintained by remco and populated with data from HashiCorp
 | 
				
			||||||
 | 
					# Vault. Changes not done in Vault will be reverted when file gets rendered.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% for key in ls(VAULT_KEY|add:"/data") %}
 | 
				
			||||||
 | 
					{{key}}={{ getv(VAULT_KEY|add:"/data/"|add:key) }}
 | 
				
			||||||
 | 
					{% endfor %}
 | 
				
			||||||
 | 
					# When needed for temporary debugging
 | 
				
			||||||
 | 
					# ZBX_DEBUGLEVEL=4
 | 
				
			||||||
		Reference in New Issue
	
	Block a user