# ANSIBLE\_JINJA2\_NATIVE not working in user module for expires key

**URL:** <https://forum.ansible.com/t/ansible-jinja2-native-not-working-in-user-module-for-expires-key/36828>\
**Category:** Ansible Project\
**Created:** [July 11, 2022, 7:07pm UTC](https://forum.ansible.com/t/ansible-jinja2-native-not-working-in-user-module-for-expires-key/36828 "2022-07-11T19:07:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [July 11, 2022, 7:07pm UTC](https://forum.ansible.com/t/ansible-jinja2-native-not-working-in-user-module-for-expires-key/36828/1 "2022-07-11T19:07:33Z")

</div>

I’m trying to pass a generic date to the expires key in the user module and convert it inline so that our inventory doesn’t have to include this same jinja over and over:

```auto
users:
name: asmith
comment: Adam Smith
key_exclusive: true
key: |
abcdefghijklmnopqrstuvwxyz

create_users:
- >
{{ users['asmith'] | combine(
{'expires':("2022-07-12 00:00:00" | to_datetime).strftime("%s")
,'state':'present'
})
}}

```

My try thus far is

```yaml
- name: Create/Remove users
user:
name: "{{ item.name }}"
update_password: "{{ item.update_password | default('always') }}"
password: "{{ item.password | default(omit) }}"
state: "{{ item.state | default('present') }}"
remove: "{{ item.remove | default('no') }}"
shell: "{{ item.shell | default('/bin/bash') }}"
comment: "{{ item.comment | default(omit) }}"
# account expires on whole day only
expires: "{% if 'expires' in item %}{{ ((item.expires + ' 00:00:00') | to_datetime).strftime('%s') | int }}{% else %}-1{% endif %}"
group: "{{ item.name }}"
groups: "{{ item.groups | default(omit) }}"
append: "{{ item.append | default('no') }}" # "no" = always remove from unspecified groups
loop: "{{ create_users }}"
loop_control:
label: "{{ item.name }}"
when:
- create_users is defined

```

I call ansible-playbook with env var ANSIBLE\_JINJA2\_NATIVE=True.

However, I get the error:

```auto
failed: [node1] (item=asmith) => changed=false
ansible_loop_var: item
item:
comment: Adam Smith
groups:
- admin
key: |-
abcdefghijklmnopqrstuvwxyz
name: asmith
msg: 'argument expires is of type <type ''str''> and we were unable to convert to float: <type ''str''> cannot be converted to a float'

```

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [July 11, 2022, 9:35pm UTC](https://forum.ansible.com/t/ansible-jinja2-native-not-working-in-user-module-for-expires-key/36828/2 "2022-07-11T21:35:13Z")

</div>

It looks like I had a typo as everything is now working.
