# Need Guidance

**URL:** <https://forum.ansible.com/t/need-guidance/33761>\
**Category:** Ansible Project\
**Created:** [September 8, 2020, 8:15am UTC](https://forum.ansible.com/t/need-guidance/33761 "2020-09-08T08:15:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kundan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@Kundan\_Singh](https://forum.ansible.com/u/Kundan_Singh)\
**Post date:** [September 8, 2020, 8:15am UTC](https://forum.ansible.com/t/need-guidance/33761/1 "2020-09-08T08:15:25Z")

</div>

Hi All,

Need your Guidance to achieve the milestone.

I am creating a playbook to validate the user password expiry date . if it expires withing 15 days it should send a mail to user mail id.  
but not sure how to enable mail alter after execution of command .

Below is the palybook task detail :-

tasks:

- name: check users password valid time  
shell: chage -l “{{ item }}”  
register: validate

# loop: users

- debug:  
msg: “{{ validate }}”  
when: validate.rc !=0

- name: Intimate concern team by mail if lock occurs  
mail:  
host: “{{ smtp\_host\_name }}”  
port: “{{ smtp\_port }}”  
attach:

- /home/kundan/  
body: " password getting expires in 10 days"

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [September 8, 2020, 8:22am UTC](https://forum.ansible.com/t/need-guidance/33761/2 "2020-09-08T08:22:07Z")

</div>

“Name or service not known” tells that “smtp\_host\_name” is not reachable.

---

<div class="post-metadata">

**Author:** ![Kundan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@Kundan\_Singh](https://forum.ansible.com/u/Kundan_Singh)\
**Post date:** [September 8, 2020, 8:30am UTC](https://forum.ansible.com/t/need-guidance/33761/3 "2020-09-08T08:30:51Z")

</div>

Thanks Abhijit

I made the changes in the code.  
But still have dout how to use when condition to send a alter so that user can change there password for endpoints

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [September 8, 2020, 9:19am UTC](https://forum.ansible.com/t/need-guidance/33761/4 "2020-09-08T09:19:05Z")

</div>



---

<div class="post-metadata">

**Author:** ![Kundan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@Kundan\_Singh](https://forum.ansible.com/u/Kundan_Singh)\
**Post date:** [September 8, 2020, 12:06pm UTC](https://forum.ansible.com/t/need-guidance/33761/5 "2020-09-08T12:06:11Z")

</div>

Thank you so much Abhijeet.
