Vlado, your solution worked like a charm.

Thank you once again and keep up the good work of sharing your
insights/knowledge with community.



On Fri, 21 Feb 2020 at 10:51, Vladimir Botka <vbo...@gmail.com> wrote:

> On Fri, 21 Feb 2020 01:57:32 -0800 (PST)
> João Santos <morgado.san...@gmail.com> wrote:
>
> > The properties file will havethis layout as an example:
> >
> > sw01.local.protocol=${proto}
> > sw01.local.host=${host}
> > sw01.local.user=${user}
> >
> > sw02.local.protocol=${proto}
> > sw02.local.host=${host}
> > sw02.local.user=${user}
> >
> > In the end my goal will be to have like:
> >
> > sw01:
> >   local:
> >     protocol: ${proto}
> >     host: ${host}
> >     user: ${user}
>
> Try this
>
>     - set_fact:
>         prop: "{{ prop|default({})|
>                   combine({my_key0:
>                           {my_key1:
>                           {my_key2: my_value}}}, recursive=True) }}"
>       vars:
>         my_keys: "{{ item.split('=').0 }}"
>         my_value: "{{ item.split('=').1 }}"
>         my_keys_split: "{{ my_keys.split('.') }}"
>         my_key0: "{{ my_keys_split.0 }}"
>         my_key1: "{{ my_keys_split.1 }}"
>         my_key2: "{{ my_keys_split.2 }}"
>       loop: "{{ lookup('file', 'java/springboot').splitlines()|
>                 list|select()|list }}"
>     - debug:
>         var: prop
>
> HTH,
>
>         -vlado
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG3v9he3NJqSNww-nquYJDd1SQU%3DXj6GEYwh8MgiKVJ_1P7K6g%40mail.gmail.com.

Reply via email to