Ah, that's the problem. You're using `name: users` parameter, so in your vars file,

    expires: '{{ timestamp.sep2023 }}'

isn't going to exist. It's going to be

    expires: '{{ users.timestamp.sep2023 }}'

But that's also going to throw errors.

I think you're running into a bug with how `name:` is implemented in ansible.builtin.include_vars.

On 10/25/22 11:26 AM, Jacquelin C wrote:
I source the file with :

      ansible.builtin.include_vars:
        file: users.yml
        name: users

Le mar. 25 oct. 2022 à 17:18, 'Rowe, Walter P. (Fed)' via Ansible Project <[email protected]> a écrit :

    How do you source the vars file? You have two options.

    A vars_files directive before the tasks section.

    vars_files:
      - your_vars_file.yml

    A task that explicitly includes a vars file.

    include_vars:
      file: your_vars_file.yml

    There are other variants of this so read the docs on the ansible
    website.

    Walter
    --
    Walter Rowe, Division Chief
    Infrastructure Services, OISM
    Mobile: 202.355.4123

    On Oct 25, 2022, at 10:58 AM, Jacquelin C
    <[email protected]> wrote:

    Hello team,

    I would like to use variables in a vars file, like this :

    ##############
    ---
    # file vars/users.yml

    timestamp:
      sep2023: 1693864800 # date --date=09/05/2023 +%s


    users:

      a_user:
        name: a_user
        passwd: $6$FF.DN/vbue.2i9/vla6h8xpZhx4L/dppBbnnCWN8hZ0
        uid: 3007
        comment: log receiver
        expires: '{{timestamp.sep2023}}'
    ##############

    but when load the file with ansible.builtin.include_vars
    I get the error : timestamp' is undefined

    How can i do that ?


-- 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/d8b1759f-8f14-419b-baf9-d33809283298n%40googlegroups.com
    
<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Fd8b1759f-8f14-419b-baf9-d33809283298n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7Cbf00d5eba20c44da0e6b08dab6995434%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638023066907532456%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KohOssLC6V%2BPm5Gm5e%2BhK2TrzqUw0vVPIsnGXtQD%2B9A%3D&reserved=0>.

-- 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/37C539F3-623C-4FC3-8DC0-B2CF28DC8667%40nist.gov
    
<https://groups.google.com/d/msgid/ansible-project/37C539F3-623C-4FC3-8DC0-B2CF28DC8667%40nist.gov?utm_medium=email&utm_source=footer>.

--
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/CAMu-cBHkHC1Jx4EhTpyPnSWTW73e%2ByAq2N38RXZ5_3u5P0JO6g%40mail.gmail.com <https://groups.google.com/d/msgid/ansible-project/CAMu-cBHkHC1Jx4EhTpyPnSWTW73e%2ByAq2N38RXZ5_3u5P0JO6g%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
Todd

--
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/a92b94db-16ef-31f5-a54a-22ee3af03808%40gmail.com.

Reply via email to