title: Change several files with specific file extension to another extension in a folder
body: <p>In a folder containing files with different extensions (<code>*.rules</code> and <code>*.rules.yml</code>), I need to change the file extension based on certain condition:</p>
  
  <ol>
  <li><code>*.rules</code> => <code>*.rules.yml</code>, or</li>
  <li><code>*.rules.yml</code> => <code>*.rules</code></li>
  </ol>
  
  <p>In shell, I can do it as:</p>
  
  <pre><code>Case # 1
  for file in ./*.rules; do mv "$file" "${file%.*}.rules.yml" ; done 
  # from *.rules to *.rules.yml
  
  
  Case # 2
  for file in ./*.rules.yml ; do mv "$file" "${file%.*.*}.rules" ; done 
  # from *.rules.yml to *.rules
  </code></pre>
  
  <p>Any idea in ansible to do the same thing? </p>
  
  <p>Any help will be appreciated :)</p>