sed not finding file when using a pattern through ansible
<p>I have the following role:</p>

<pre><code>---
- name: Replaces a string in a file
  command: sed 's/'"{{ target_string }}"'/'"{{ new_string }}"'/g' -i {{ target_file_name }}
           chdir="{{ target_file_location }}"
</code></pre>

<p>Which is called as follows:</p>

<pre><code>- { role: string_replace_in_file, target_string: "localhost", new_string: "{{ myValue }}", target_file_name: "*.scripts.js", target_file_location: "/path/to/folder" }
</code></pre>

<p>The file i want to modify is aea342.scripts.js</p>

<p>I get the following output:</p>

<pre><code>failed: [myMachine] =&gt; {"changed": true, "cmd": ["sed", "s/localhost/myValue/g", "-i", ".*.scripts.js"], "delta": "0:00:00.031107", "end": "2016-02-02 14:26:21.715652", "rc": 2, "start": "2016-02-02 14:26:21.684545", "warnings": ["Consider using template or lineinfile module rather than running sed"]}
stderr: sed: can't read .*.scripts.js: No such file or directory
</code></pre>

<p>When I run  <code>sed 's/localhost/myValue/g' -i *.scripts.js</code> manually on my machine however it works.</p>