Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

user: expires expects float epoch time #4084

Closed
marcusspain opened this issue Jun 30, 2016 · 5 comments · Fixed by ansible/ansible#17325
Closed

user: expires expects float epoch time #4084

marcusspain opened this issue Jun 30, 2016 · 5 comments · Fixed by ansible/ansible#17325

Comments

@marcusspain
Copy link

marcusspain commented Jun 30, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

user module

ANSIBLE VERSION
ansible 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

inventory = /var/local/ansible/hosts
roles_path = /var/local/ansible/roles
log_path = /home/ansible/ansible.log

OS / ENVIRONMENT

CentOS Linux release 7.0.1406 (Core)

SUMMARY

When adding a user, with the expires option, specifying epoch time as an int throws an error.

expires: 3268684800

results in:
"argument expires is of type <type 'int'> and we were unable to convert to float"

It works when changed to:

expires: 3268684800.0
STEPS TO REPRODUCE
  tasks:
  - name: add exampleuser
    user:
      name: exampleuser
      groups: wheel
      append: yes
      password: $1$X65joYEp$WiZRYzEF25NxYjBvmQK/C/
      expires: 3268684800
EXPECTED RESULTS
changed: [192.168.61.180]
ACTUAL RESULTS
fatal: [192.168.61.180]: FAILED! => {"changed": false, "failed": true, "msg": "argument expires is of type <type 'int'> and we were unable to convert to float"}
@rcutmore
Copy link
Contributor

I'm new to Ansible but it seems like there are two options to fix this:

  1. Allow int or float types for the expires parameter. I'm not sure if this is possible, it looks like parameter types can only be set to one type at a time.
  2. Update the float type checking in the AnsibleModule class. If _check_type_float doesn't find a float it checks for a basestring to convert. Perhaps this should check for and convert an int as well?

@ansibot
Copy link

ansibot commented Jul 30, 2016

@grossws, ping. This issue is still waiting on your response.
click here for bot help

@dfederlein
Copy link

Confirmed behavior in 2.2 via customer. Please escalate.

@ansibot
Copy link

ansibot commented Aug 27, 2016

@grossws, ping. This issue is still waiting on your response.
click here for bot help

@abadger
Copy link
Contributor

abadger commented Aug 31, 2016

This should be fixed via ansible/ansible#17325 Merged to devel and the stable-2.1 branch. I believe the plan is to have a 2.1.2rc2 later today so this fix should be included there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.