There is a variable merging setting, but I prefer being explicit about
having a complex variable, parts of which can be overridden (rather
than magically "doing the right thing").
---
- hosts: myserver
- roles:
- mysql
- vars:
mysql_password: abcdef
- tasks:
- debug: msg="{{ mysql_password | default(mysql.password) }}"
This way it is clear that the password could have come from two
different places.
Hope this helps.
K
Kahlil (Kal) Hodgson GPG: C9A02289
Head of Technology (m) +61 (0) 4 2573 0382
DealMax Pty Ltd (w) +61 (0) 3 9008 5281
Suite 1415
401 Docklands Drive
Docklands VIC 3008 Australia
"All parts should go together without forcing. You must remember that
the parts you are reassembling were disassembled by you. Therefore,
if you can't get them together again, there must be a reason. By all
means, do not use a hammer." -- IBM maintenance manual, 1925
On 2 December 2013 11:04, Eric Chaves <[email protected]> wrote:
> Hi folks,
>
> I created a role with default variables using a nested syntax and not I'd
> like to override just a few of those attributes in the playbook, but
> whenever I do it I end up redefining the entire variable na loosing the
> defaults for the non overrided values.
>
> For example, in role/mysql/defaults/main.yml:
> ---
> mysql:
> address: 127.0.0.1
> admin: admin
> password: 12345
>
> Then in the my_server.yml:
> ---
> - hosts: myserver
> - roles:
> - mysql
> - vars:
> mysql:
> password: abcdef
>
> but once I do this mysql.address and mysql.admin become undefined. I have
> tried the mysql[address] syntax but it didn't work.
>
> Is it possible to override just a few set of nested attributes?
>
> Thanks for the help,
>
> Eric
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.