File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,10 +21,12 @@ vault write identity/alias name=fprefect mount_accessor=$mount_accessor canonica
2121# Vault Agent later
2222vault write identity/ entity name= vaultagent
2323
24+ $role_id = $ (vault read auth/ approle/ role/ web- role/ role- id - format= json) | ConvertFrom-Json
25+
2426$mount_accessor = $authmethods.data ." approle/" .accessor
2527$vaultagent_id = $ (vault read identity/ entity/ name/ vaultagent - format= json) | ConvertFrom-Json
2628$canonical_id = $vaultagent_id.data.id
27- vault write identity/ alias name= vaultagent mount_accessor= $mount_accessor canonical_id= $canonical_id
29+ vault write identity/ alias name= $ ( $role_id .data.role_id ) mount_accessor= $mount_accessor canonical_id= $canonical_id
2830
2931# Now onto creating an internal group for Arthur and Ford as administrators
3032vault path- help identity/ group
Original file line number Diff line number Diff line change @@ -21,9 +21,13 @@ vault write identity/alias name=fprefect \
2121# Vault Agent later
2222vault write identity/entity name=vaultagent
2323
24+ # We need to get the role-id for the name
25+ role_id=$( vault read auth/approle/role/web-role/role-id -format=json | jq .data.role_id -r)
26+
2427mount_accessor=$( vault read sys/auth/ -format=json | jq .data.\" approle/\" .accessor -r)
2528canonical_id=$( vault read identity/entity/name/vaultagent -format=json | jq .data.id -r)
26- vault write identity/alias name=vaultagent \
29+
30+ vault write identity/alias name=$role_id \
2731 mount_accessor=$mount_accessor \
2832 canonical_id=$canonical_id
2933
Original file line number Diff line number Diff line change 1+ # Make sure you are in the m7 directory or this won't work very well
2+
3+ # Make sure your Vault server container is up and running
4+ docker container ls
5+
6+ # Let's set our vault env variables
7+ export VAULT_ADDR=" https://127.0.0.1:8200"
8+ export VAULT_SKIP_VERIFY=true
9+
10+ # Make sure vault isn't sealed
11+ vault status
12+ vault login
13+
14+ # We need to get the role-id and secret-id for the vault agent
15+ role_id=$( vault read auth/approle/role/web-role/role-id -format=json | jq .data.role_id -r)
16+
17+ secret_id=$( vault write -f auth/approle/role/web-role/secret-id -format=json | jq .data.secret_id -r)
18+
19+ # Now we'll write both values out to files for use by the agent
20+ echo $role_id > role_id.txt
21+ echo $secret_id > secret_id.txt
22+
23+ # Next we'll put a secret into the apikeys secrets engine
24+ vault kv put apikeys/key1 key=456yujnbgty678ikjhgty67u
25+
26+ # And now we can start up the vault agent
27+ vault agent -config=vault-agent.hcl
Original file line number Diff line number Diff line change 1+ {{ with secret "apikeys/key1" }}
2+ {{ .Data.data.key }}
3+ {{ end }}
Original file line number Diff line number Diff line change 1+ vault {
2+ address = " https://127.0.0.1:8200"
3+ }
4+
5+ auto_auth {
6+ method "approle" {
7+ mount_path = " auth/approle"
8+ config = {
9+ role_id_file_path = " role_id.txt"
10+ secret_id_file_path = " secret_id.txt"
11+ remove_secret_id_file_after_reading = false
12+ }
13+ }
14+
15+ sink "file" {
16+ config = {
17+ path = " token.txt"
18+ }
19+ }
20+
21+ }
22+
23+ cache {
24+ use_auto_auth_token = true
25+ }
26+
27+ listener "tcp" {
28+ address = " 127.0.0.1:8100"
29+ tls_disable = true
30+ }
31+
32+ template {
33+ source = " template.ctmpl"
34+ destination = " render.txt"
35+ }
You can’t perform that action at this time.
0 commit comments