aboutsummaryrefslogtreecommitdiff
path: root/content/blog/ansible/ansible-vault-example.md
diff options
context:
space:
mode:
authorJulien Dessaux2021-03-11 18:53:14 +0100
committerJulien Dessaux2021-03-11 18:53:14 +0100
commit60d3abc6ecdc21b4ab921d34a55b4af48690f55a (patch)
tree1ee530dd7367d743fb619f341100e41df22e1985 /content/blog/ansible/ansible-vault-example.md
parentUpdated docsy theme (diff)
downloadwww-60d3abc6ecdc21b4ab921d34a55b4af48690f55a.tar.gz
www-60d3abc6ecdc21b4ab921d34a55b4af48690f55a.tar.bz2
www-60d3abc6ecdc21b4ab921d34a55b4af48690f55a.zip
Rewrote the whole website to get rid on a heavy theme
Diffstat (limited to 'content/blog/ansible/ansible-vault-example.md')
-rw-r--r--content/blog/ansible/ansible-vault-example.md36
1 files changed, 36 insertions, 0 deletions
diff --git a/content/blog/ansible/ansible-vault-example.md b/content/blog/ansible/ansible-vault-example.md
new file mode 100644
index 0000000..fb6ef45
--- /dev/null
+++ b/content/blog/ansible/ansible-vault-example.md
@@ -0,0 +1,36 @@
+---
+title: "Ansible vault example"
+linkTitle: "Ansible vault example"
+date: 2018-02-21
+description: >
+ Ansible vault example
+---
+
+Here is how to edit a vault protected file :
+{{< highlight sh >}}
+ansible-vault edit hostvars/blah.yml
+{{< / highlight >}}
+
+Here is how to put a multiline entry like a private key in vault (for a simple value, just don't use a `|`):
+
+{{< highlight yaml >}}
+ssl_key : |
+ ----- BEGIN PRIVATE KEY -----
+ blahblahblah
+ blahblahblah
+ ----- END PRIVATE KEY -----
+{{< /highlight >}}
+
+And here is how to use it in a task :
+{{< highlight yaml >}}
+- copy:
+ path: /etc/ssl/private.key
+ mode: 0400
+ content: '{{ ssl_key }}'
+{{< / highlight >}}
+
+To run a playbook, you will need to pass the `--ask-vault` argument or to export a `ANSIBLE_VAULT_PASSWORD_FILE=/home/julien/.vault_pass.txt` variable (the file needs to contain a single line with your vault password here).
+
+## Ressources
+
+ * how to break long lines in ansible : https://watson-wilson.ca/blog/2018/07/11/ansible-tips/