# Any ideas of how to work around the lack of force=yes option in the file module?

**URL:** <https://forum.ansible.com/t/any-ideas-of-how-to-work-around-the-lack-of-force-yes-option-in-the-file-module/12515>\
**Category:** Ansible Project\
**Created:** [March 17, 2013, 12:41pm UTC](https://forum.ansible.com/t/any-ideas-of-how-to-work-around-the-lack-of-force-yes-option-in-the-file-module/12515 "2013-03-17T12:41:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crucialfelix](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@crucialfelix](https://forum.ansible.com/u/crucialfelix)\
**Post date:** [March 17, 2013, 12:41pm UTC](https://forum.ansible.com/t/any-ideas-of-how-to-work-around-the-lack-of-force-yes-option-in-the-file-module/12515/1 "2013-03-17T12:41:58Z")

</div>

in this particular case you might add a

- name: Install mysql server  
apt: pkg=mysql-server state=installed

notify: remove default my.conf

and change the remove default to a handler.  
it should only fire when installing the package.

however that seems to have a lot of assumptions.

run a shell script that checks if its a file and moves it away if so

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 17, 2013, 1:20pm UTC](https://forum.ansible.com/t/any-ideas-of-how-to-work-around-the-lack-of-force-yes-option-in-the-file-module/12515/2 "2013-03-17T13:20:19Z")

</div>

I would likely modify your example do something like this:

&nbsp;&nbsp;&nbsp;&nbsp;- name: Install mysql server  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;apt: pkg=mysql-server state=installed  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: $installed\_mss

&nbsp;&nbsp;&nbsp;&nbsp;- name: Remove mysql config file  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file: path=/etc/mysql/my.cnf state=absent  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_changed: $installed\_mss

&nbsp;&nbsp;&nbsp;&nbsp;- name: Symlink mysql conf  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file: src=/srv/degen/misc/deploy/my.cnf  
dest=/etc/mysql/my.cnf state=link  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;notify: Restart mysql  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_changed: $installed\_mss

The reason we don't have file forcing between link and file states (or  
file and link) for the most part is that could mean too many different  
things about how to resolve that particular confusion, and I'd prefer  
if things be explicit.

If done with changed variables (above), it still only runs when needed  
and that should be fine.
