Create variables in hash

2 views
Skip to first unread message

Rafael Tomelin

unread,
Jan 25, 2019, 1:11:03 PM1/25/19
to ansible...@googlegroups.com
Hi dear,

How can create variables in hash, example:

---
# vars file for roles
my_var_root:
my_sub_var:
name: example
env: environment
key: my_key

And how, pull in code?

--
Atenciosamente,

Rafael Tomelin
Tel.: 51-84104084
Skype: rafael.tomelin

LPI ID: LPI000191271

boncalo mihai

unread,
Jan 25, 2019, 2:23:23 PM1/25/19
to ansible...@googlegroups.com
key: {{ my_key | hash('sha1') }} ...

Hashing filters

New in version 1.9.

To get the sha1 hash of a string:

{{ 'test1' | hash('sha1') }}

To get the md5 hash of a string:

{{ 'test1' | hash('md5') }}

Get a string checksum:

{{ 'test2' | checksum }}

Other hashes (platform dependent):

{{ 'test2' | hash('blowfish') }}

To get a sha512 password hash (random salt):

{{ 'passwordsaresecret' | password_hash('sha512') }}

To get a sha256 password hash with a specific salt:

{{ 'secretpassword' | password_hash('sha256', 'mysecretsalt') }}

An idempotent method to generate unique hashes per system is to use a
salt that is consistent between runs:

{{ 'secretpassword' | password_hash('sha512', 65534 |
random(seed=inventory_hostname) | string) }}
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGEUqbApSGKH40R%3Dt3GLv9mccOK9ezEDsSk-DmTgX-apgP1y_g%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Rafael Tomelin

unread,
Jan 28, 2019, 11:43:29 AM1/28/19
to ansible...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages