AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Ansible troubleshooting - user module password_expiry_min bug and workaround — Video Tutorial
Join Luca Berton on Ansible Pilot as we troubleshoot the user module bug, exploring effective workarounds through live Playbooknstrations.
What You'll Learn
- Introduction
- Demo
- error code
- error execution
- Troubleshoot
- workaround
- workaround execution
- Conclusion
- Related Articles
- Workaround Summary
Full Tutorial Content
Introduction
Today we're going to talk about Ansible troubleshooting, specifically about the user module bug and possible workaround.
I'm Luca Berton and welcome to today's episode of Ansible Pilot
Demo
The best way of talking about Ansible troubleshooting is to jump in a live Playbook to show you practically the user module bug triage and possible workaround!
error code
- userbug_error.yml
```yaml
---
- name: user module Playbook
hosts: all
become: true
vars:
myuser: "example"
tasks:
- name: password expiration
ansible.builtin.user:
name: "{{ myuser }}"
password_expire_min: 7
password_expire_max: 90
```
error execution
```bash
$ ansible-playbook -i Playbook/inventory troubleshooting/userbug_error.yml.yml
PLAY [user module Playbook] **********************************************************************************
TASK [Gathering Facts] ***********************************************************************************
ok: [demo.example.com]
TASK [password expiration] *******************************************************************************
changed: [demo.example.com]
PLAY RECAP ***********************************************************************************************
demo.example.com : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ansible-pilot $ ansible-playbook -i Playbook/inventory user\ expiration/user.yml
PLAY [user module Playbook] **********************************************************************************
TASK [Gathering Facts] ***********************************************************************************
ok: [demo.example.com]
TASK [password expiration] *******************************************************************************
ok: [demo.example.com]
PLAY RECAP ***********************************************************************************************
demo.example.com : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ansible-pilot $ ssh devops@demo.example.com
Last login: Mon Nov 8 17:09:16 2021 from 192.168.43.5
[devops@demo ~]$ sudo su
[root@demo devops]# chage -l example
Last password change : Nov 08, 2021
Password expires : Feb 06, 2022
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
```
We expected a `7` value for `Minimum number of days between password change` but we obtain `0`.
Troubleshoot
- [bug report - user module can't handle password expiration parameters correctly #75017](https://github.com/ansible/ansible/issues/75017)
- [pull request - user module password expiration fixes #75390](https://github.com/ansible/ansible/pull/75390)
workaround
- userbug_workaround.yml
```yaml
---
- name: user module Playbook
hosts: all
become: true
vars:
myuser: "e
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 4 min
- Category: installation
Read the full written article: Ansible troubleshooting - user module password_expiry_min bug and workaround
Related Video Tutorials
- Ansible Fix 'Missing sudo Password' Error: Become Configuration — Fix Ansible 'missing sudo password' error. Configure become_password, passwordless sudo, ask-become-pass, and proper privilege escalation settings.
- Ansible 'Missing Required Arguments' Error: Fix Missing Module Parameters — Fix the Ansible 'missing required arguments' error. Identify required vs optional module parameters, check documentation, and troubleshoot common parameter.
- Ansible troubleshooting - AWS Failed to import the required Python library (botocore or boto3) — Learn how to troubleshoot and fix the \"Failed to import the required Python library (botocore or boto3)\" error in Ansible for AWS with a live Playbook.
- Ansible Vault Error: Fix 'Attempting to Decrypt but No Vault Secrets Found' — How to fix Ansible 'attempting to decrypt but no vault secrets found' error. Configure vault password file, --ask-vault-pass, vault-id.
- Ansible troubleshooting - Destination does not exist rc 257 — Troubleshoot the "Destination does not exist" error (return code 257) in Ansible with Luca Berton on Ansible Pilot! Learn to fix file path issues effectively.
- Ansible 'Failed to Connect via SSH localhost:22': Fix Guide — Fix Ansible 'failed to connect to the host via ssh localhost port 22' error. Resolve SSH config, connection type, host key, and authentication issues.