# mysql\_secret

**URL:** <https://forum.ansible.com/t/mysql-secret/13160>\
**Category:** Ansible Project\
**Created:** [July 19, 2013, 12:09am UTC](https://forum.ansible.com/t/mysql-secret/13160 "2013-07-19T00:09:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Ni](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Michael\_Ni](https://forum.ansible.com/u/Michael_Ni)\
**Post date:** [July 19, 2013, 12:09am UTC](https://forum.ansible.com/t/mysql-secret/13160/1 "2013-07-19T00:09:33Z")

</div>

According to

> **[MySQL :: MySQL 8.4 Reference Manual :: 2.5.4 Installing MySQL on Linux Using...](https://dev.mysql.com/doc/refman/8.4/en/linux-installation-rpm.html)**

As of MySQL 5.6.8, if using rpm installation, mysql is automatically setup with a random password stored in  
$HOME/.mysql\_secret

the file contains text like the following

# The random password set for the root user at Thu Jul 18 10:29:03 2013 (local time): dWtTd33T

I want to keep my ansible scripts idempotent.

How can I grab the value of the password and use that with “mysql\_user” ?  
Is there something like “lineinfile” but instead of managing lines that match, it takes the regex match and saves to an ansible variable?  
Then using that variable, I can set it to the password of mysql\_user

Mike

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [July 19, 2013, 1:40am UTC](https://forum.ansible.com/t/mysql-secret/13160/2 "2013-07-19T01:40:22Z")

</div>

so aside from a shell command + register var, it looks like if you want it to not returned ‘changed’ you need a custom fact that does same.
