<p dir="auto">Currently with the mysql_db module state=import tries to import the database again, thus making it non-idempotent. This is the error i'm getting; msg: ERROR 1062 (23000) at line 30: Duplicate entry '1' for key 'PRIMARY'</p>
<p dir="auto">With this playbook:</p>
<ul dir="auto">
<li>name: create website database<br>
mysql_db: name=dbname<br>
login_user={{ mysql_root_user }}<br>
login_password={{ mysql_root_password }}<br>
state=present</li>
<li>name: copy website database<br>
copy: src=database.sql<br>
dest=/home/user/database.sql</li>
<li>name: import website database<br>
mysql_db: name=dbname<br>
login_user={{ mysql_root_user }}<br>
login_password={{ mysql_root_password }}<br>
target=/home/user/database.sql<br>
state=import</li>
</ul>
<p dir="auto">Just a heads up for a potential improvement, currently I'm commenting the last task everytime I run the playbook again for idempotency.</p>
<p dir="auto">This happened in my last run, I can't get it to happen again. But it asked to be reported so here it is.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" [WARNING]: Calculating checksum failed unusually, please report this to the list so it can be fixed command: rc=flag; [ -r /usr/share/nginx/html/global_error_pages/416.html ] ||
rc=2; [ -f /usr/share/nginx/html/global_error_pages/416.html ] || rc=1; [ -d /usr/share/nginx/html/global_error_pages/416.html ] &amp;&amp; rc=3; python -V 2&gt;/dev/null || rc=4; [ x&quot;$rc&quot; !=
&quot;xflag&quot; ] &amp;&amp; echo &quot;${rc}  &quot;/usr/share/nginx/html/global_error_pages/416.html &amp;&amp; exit 0; (python -c 'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile =
open(&quot;'/usr/share/nginx/html/global_error_pages/416.html'&quot;, &quot;rb&quot;) buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0:         hasher.update(buf)         buf = afile.read(BLOCKSIZE)
afile.close() print(hasher.hexdigest())' 2&gt;/dev/null) || (python -c 'import sha; BLOCKSIZE = 65536; hasher = sha.sha(); afile =
open(&quot;'/usr/share/nginx/html/global_error_pages/416.html'&quot;, &quot;rb&quot;) buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0:         hasher.update(buf)         buf = afile.read(BLOCKSIZE)
afile.close() print(hasher.hexdigest())' 2&gt;/dev/null) || (echo '0  '/usr/share/nginx/html/global_error_pages/416.html) ---- output: {'stdout_lines': [u''], 'stdout': u'\r\n',
'stderr': u'', 'rc': 0} ----
"><pre class="notranslate"><code class="notranslate"> [WARNING]: Calculating checksum failed unusually, please report this to the list so it can be fixed command: rc=flag; [ -r /usr/share/nginx/html/global_error_pages/416.html ] ||
rc=2; [ -f /usr/share/nginx/html/global_error_pages/416.html ] || rc=1; [ -d /usr/share/nginx/html/global_error_pages/416.html ] &amp;&amp; rc=3; python -V 2&gt;/dev/null || rc=4; [ x"$rc" !=
"xflag" ] &amp;&amp; echo "${rc}  "/usr/share/nginx/html/global_error_pages/416.html &amp;&amp; exit 0; (python -c 'import hashlib; BLOCKSIZE = 65536; hasher = hashlib.sha1(); afile =
open("'/usr/share/nginx/html/global_error_pages/416.html'", "rb") buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0:         hasher.update(buf)         buf = afile.read(BLOCKSIZE)
afile.close() print(hasher.hexdigest())' 2&gt;/dev/null) || (python -c 'import sha; BLOCKSIZE = 65536; hasher = sha.sha(); afile =
open("'/usr/share/nginx/html/global_error_pages/416.html'", "rb") buf = afile.read(BLOCKSIZE) while len(buf) &gt; 0:         hasher.update(buf)         buf = afile.read(BLOCKSIZE)
afile.close() print(hasher.hexdigest())' 2&gt;/dev/null) || (echo '0  '/usr/share/nginx/html/global_error_pages/416.html) ---- output: {'stdout_lines': [u''], 'stdout': u'\r\n',
'stderr': u'', 'rc': 0} ----

</code></pre></div>