On Sun, 9 Feb 2020 19:34:21 -0800 (PST)
Eric Chang <[email protected]> wrote:

> user:
>   name: chchang
>   comment: "Chang Chic Hung"
> 
> and I want to add more attrs like
> 
> last_name: Chang
> mid_name: Chic

The tasks

   - set_fact:
        user: "{{ user|
                  combine({'last_name': comment_split.0})|
                  combine({'mid_name': comment_split.1}) }}"
      vars:
        comment_split: "{{ user.comment.split() }}"
    - debug:
        var: user

give

    "user": {
        "comment": "Chang Chic Hung", 
        "last_name": "Chang", 
        "mid_name": "Chic", 
        "name": "chchang"
    }

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200210054359.26628b69%40gmail.com.

Attachment: pgpE7Hal7L5O2.pgp
Description: OpenPGP digital signature

Reply via email to