# Updateing a password in Grub.conf file using Ansible and Replace

**URL:** <https://forum.ansible.com/t/updateing-a-password-in-grub-conf-file-using-ansible-and-replace/22780>\
**Category:** Ansible Project\
**Created:** [October 12, 2016, 7:36pm UTC](https://forum.ansible.com/t/updateing-a-password-in-grub-conf-file-using-ansible-and-replace/22780 "2016-10-12T19:36:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan\_Harkleroad1](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@Alan\_Harkleroad1](https://forum.ansible.com/u/Alan_Harkleroad1)\
**Post date:** [October 12, 2016, 7:36pm UTC](https://forum.ansible.com/t/updateing-a-password-in-grub-conf-file-using-ansible-and-replace/22780/1 "2016-10-12T19:36:40Z")

</div>

So I wrote a short playbook to update our VMs to update the /boot/grub/grub.conf file to use a new hashed password but the playbook comes back green with no changes. Not sure what I am doing wrong, any help is appreciated.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 12, 2016, 7:58pm UTC](https://forum.ansible.com/t/updateing-a-password-in-grub-conf-file-using-ansible-and-replace/22780/2 "2016-10-12T19:58:10Z")

</div>

Hard to say without knowing how the current hash looks like, but if the hash contain any regexp special character they need to be escaped.  
List of them you'll find here  
[https://docs.python.org/2/library/re.html#regular-expression-syntax](https://docs.python.org/2/library/re.html#regular-expression-syntax)

---

<div class="post-metadata">

**Author:** ![Alan\_Harkleroad1](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@Alan\_Harkleroad1](https://forum.ansible.com/u/Alan_Harkleroad1)\
**Post date:** [October 13, 2016, 12:04pm UTC](https://forum.ansible.com/t/updateing-a-password-in-grub-conf-file-using-ansible-and-replace/22780/3 "2016-10-13T12:04:34Z")

</div>

Yes the hash starts with a $ and includes / as well. I dont follow what you mean by escaping them.

Here is an example hash. So how would I have it read that as one character string and swap it with the new hash

$1$adjkielw$B./Hu9VCs96Zxc3mkVQ35.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 13, 2016, 2:48pm UTC](https://forum.ansible.com/t/updateing-a-password-in-grub-conf-file-using-ansible-and-replace/22780/4 "2016-10-13T14:48:43Z")

</div>

> Yes the hash starts with a $ and includes / as well. I dont follow what you  
> mean by escaping them.

Escaping is also documented here  
[https://docs.python.org/2/library/re.html#regular-expression-syntax](https://docs.python.org/2/library/re.html#regular-expression-syntax)

But it's a back slash (\) in front of a regexp special character so you can match on them.

> Here is an example hash. So how would I have it read that as one character  
> string and swap it with the new hash
> 
> $1$adjkielw$B./Hu9VCs96Zxc3mkVQ35.

Here you should escape $ and . like so.

\$1\$adjkielw\$B\./Hu9VCs96Zxc3mkVQ35\.
