chore: complete generate-vault-secret
This commit is contained in:
parent
bfb3ec3d34
commit
547ce05466
@ -26,7 +26,7 @@ class Vault:
|
|||||||
|
|
||||||
def create_vault_secret (self,secret: VaultSecret) -> None:
|
def create_vault_secret (self,secret: VaultSecret) -> None:
|
||||||
resp=requests.post(
|
resp=requests.post(
|
||||||
url= f'{self.URL}/v1/secrets/data/{secret.path}',
|
url= f'{self.URL}v1/secrets/data/{secret.path}',
|
||||||
headers={
|
headers={
|
||||||
'X-Vault-Token': self.token
|
'X-Vault-Token': self.token
|
||||||
},
|
},
|
||||||
@ -34,16 +34,32 @@ class Vault:
|
|||||||
"options": {"cas": 0}
|
"options": {"cas": 0}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
print(resp.url)
|
||||||
|
if resp.status_code == 200:
|
||||||
|
print(f"Create {secret.path} done")
|
||||||
|
else:
|
||||||
|
print(resp.status_code)
|
||||||
print(resp.content)
|
print(resp.content)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
secretList=[]
|
|
||||||
secretList.append(VaultSecret("nomad/ldap",{"admin":""}))
|
listSecret={
|
||||||
|
"nomad/ldap":{
|
||||||
|
"admin":""
|
||||||
|
},
|
||||||
|
"nomad/gitea":{
|
||||||
|
"internal_token":"",
|
||||||
|
"jwt_secret":"",
|
||||||
|
"secret_key":""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
token=os.getenv('VAULT_TOKEN',"")
|
token=os.getenv('VAULT_TOKEN',"")
|
||||||
vault_addr=os.getenv('VAULT_ADDR',"")
|
vault_addr=os.getenv('VAULT_ADDR',"")
|
||||||
vault=Vault(vault_addr,token)
|
vault=Vault(vault_addr,token)
|
||||||
for secret in secretList:
|
for k,v in listSecret.items():
|
||||||
|
secret=VaultSecret(k,v)
|
||||||
vault.create_vault_secret(secret)
|
vault.create_vault_secret(secret)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user