<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/westfood/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/westfood">@westfood</a> on 2016-06-05T18:53:40Z</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">django_manage</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.0.0.2"><pre class="notranslate"><code class="notranslate">ansible 2.0.0.2
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">OSX El Captain / 10.11.5, managing CentOS 7.1</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Issuing command createsuperuser ends up in error after second invocation.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Using this task, hard coding username/mail does not yeald in better effect</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Django add superusers
  django_manage:
    app_path: &quot;{{ seeder_home }}/Seeder&quot;
    virtualenv: &quot;{{ seeder_virtualenv }}&quot;
    command: &quot;createsuperuser --noinput --username={{ item.name }} --email={{ item.mail }}&quot; # Not idempotent, probably bug in django_manage module
  with_items: &quot;{{ seeder_admins }}&quot;
  tags: django
  ignore_errors: yes"><pre class="notranslate"><code class="notranslate">- name: Django add superusers
  django_manage:
    app_path: "{{ seeder_home }}/Seeder"
    virtualenv: "{{ seeder_virtualenv }}"
    command: "createsuperuser --noinput --username={{ item.name }} --email={{ item.mail }}" # Not idempotent, probably bug in django_manage module
  with_items: "{{ seeder_admins }}"
  tags: django
  ignore_errors: yes
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">It should not try to create user again</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="stderr: Traceback (most recent call last):\n  File \&quot;/opt/virtualenv/seeder/lib/python3.4/site-packages/django/db/backends/utils.py\&quot;, line 64, in execute\n    return self.cursor.execute(sql, params)\npsycopg2.IntegrityError: duplicate key value violates unique constraint \&quot;auth_user_username_key\&quot;\nDETAIL:       
Key (username)=(rudolf) already exists."><pre class="notranslate"><code class="notranslate">stderr: Traceback (most recent call last):\n  File \"/opt/virtualenv/seeder/lib/python3.4/site-packages/django/db/backends/utils.py\", line 64, in execute\n    return self.cursor.execute(sql, params)\npsycopg2.IntegrityError: duplicate key value violates unique constraint \"auth_user_username_key\"\nDETAIL:       
Key (username)=(rudolf) already exists.
</code></pre></div>
<p dir="auto">Copied from original issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="158568404" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/3871" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/3871/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/3871">ansible/ansible-modules-core#3871</a></p>
<p dir="auto">Issue Type: Bug introduced by commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/8d53ef2f6055e174a10795bc5a084c3a36389678/hovercard" href="https://github.com/ansible/ansible/commit/8d53ef2f6055e174a10795bc5a084c3a36389678"><tt>8d53ef2</tt></a></p>
<p dir="auto">Ansible Version: stable-1.9 branch is affected, version 1.8.4 works ok</p>
<p dir="auto">Environment: Ubuntu-14.04 LTS with php5-fpm 5.5.9+dfsg-1ubuntu4.7 and upstart 1.12.1</p>
<p dir="auto">Steps To Reproduce:</p>
<ul dir="auto">
<li>Install Ubuntu-14.04 LTS with the php5-fpm package</li>
<li>Get ansible to do a restart of the php5-fpm service<br>
MODULE_ARGS = 'name=php5-fpm state=restarted'</li>
</ul>
<p dir="auto">Expected Results:<br>
Ansible should be able to restart the service (assuming the config is ok) using upstart</p>
<p dir="auto">Actual Results:<br>
Ansible uses /etc/init.d/php5-fpm to perform the restart and it fails</p>
<p dir="auto">Comments:<br>
We are using ansible from a git clone, not from the apt package. I found this problem was introduced by commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/8d53ef2f6055e174a10795bc5a084c3a36389678/hovercard" href="https://github.com/ansible/ansible/commit/8d53ef2f6055e174a10795bc5a084c3a36389678"><tt>8d53ef2</tt></a> in service.py. Reverting this small changed makes it work for me. I tested by making the change in the temporary file on the target server in ~/.ansible/tmp/</p>