I’m trynna automate the intialization process of hashicorp vault using this playbook :
- hosts: 10.0.0.108 # Replace with your actual VM hostname or group
become: true
tasks:
- name: Create file
ansible.builtin.file:
path: /home/Documents/vault2.hcl
state: touch
- name: Write in configuration file
ansible.builtin.blockinfile:
path: /home/Documents/vault2.hcl
append_newline: true
prepend_newline: true
block: |
storage "raft" {
path = "/home/vault/data"
node_id = "node1"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = true
}
api_addr = "http://127.0.0.1:8200"
cluster_addr = "https://127.0.0.1:8201"
ui = true
disable_mlock = true
- name: Enable configuration and intializing vault
ansible.builtin.shell: |
export VAULT_ADDR=http://127.0.0.1:8200
vault server -config /home/Documents/vault2.hcl
vault operator init
args:
chdir: /home/ubuntu
But the “vault operator init
” command isn’t working does anyone know what’s wrong in this playbook ?
Is there a better way to automate the deployement of vault with ansible ?