<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">include_role</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  9 2016, 05:27:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
"><pre class="notranslate"><code class="notranslate">ansible 2.4.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  9 2016, 05:27:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">ansible-config dump --only-changed<br>
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/share/ansible/roles']</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">"allow_duplicates: no" not work, same role will be executed again.<br>
tasks:<br>
- include_role:<br>
name: bb<br>
allow_duplicates: no<br>
- include_role:<br>
name: bb<br>
allow_duplicates: no</p>
<p dir="auto">Maybe following code causes this issue:<br>
if block._eor and host.name in block._role._had_task_run and not in_child:<br>
block._role._completed[host.name] = True<br>
BTW, I wonder why put "not in_child" here. Does it mean include_role/import_role is limited than roles?</p>
<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/dekimsey/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/dekimsey">@dekimsey</a> on 2016-08-12T19:42:12Z</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">ini_file</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.1.0
  config file = /Users/dkimsey/.ansible.cfg
  configured module search path = ['library/']"><pre class="notranslate"><code class="notranslate">ansible 2.1.1.0
  config file = /Users/dkimsey/.ansible.cfg
  configured module search path = ['library/']
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Using a multiline string as a value in pre-existing ini_file results in duplicate entries.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">It appears the ini_file was changed from a configparser to a by-line reader. However it does not maintain compatibility correctly as configparser handles mulitline values correctly.</p>
<p dir="auto">Also, documentation still suggests configparser is in use. It's imported, but unused. It might be appropriate to use configparser to validate the ini file before emitting it to disk. The fact that it didn't surprised us as I wasn't expecting ini_file to produce an invalid ini file. Also, it will happily parse non-ini files into psuedo ini files which break when read with ini_file.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Set multiline.ini.inline
  ini_file:
    dest: multiline.ini.inline
    section: foo
    option: bar
    value: |
        line 1
        line 2
        line 3"><pre class="notranslate"><code class="notranslate">- name: Set multiline.ini.inline
  ini_file:
    dest: multiline.ini.inline
    section: foo
    option: bar
    value: |
        line 1
        line 2
        line 3
</code></pre></div>
<p dir="auto">See a complete test: <a href="https://gist.github.com/dekimsey/45aeb95814b4aa878ab3f0e5d2d3cb8f">https://gist.github.com/dekimsey/45aeb95814b4aa878ab3f0e5d2d3cb8f</a></p>
<p dir="auto">Test with</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i localhost, example.yml -v"><pre class="notranslate"><code class="notranslate">ansible-playbook -i localhost, example.yml -v
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[foo]
baz = simple value
bar = line 1
      line 2
      line 3"><pre class="notranslate"><code class="notranslate">[foo]
baz = simple value
bar = line 1
      line 2
      line 3
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[foo]
baz = simple value
bar = line 1
line 2
line 3

      line 2
      line 3"><pre class="notranslate"><code class="notranslate">[foo]
baz = simple value
bar = line 1
line 2
line 3

      line 2
      line 3
</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="170944674" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-core/issues/4413" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-core/issues/4413/hovercard" href="https://github.com/ansible/ansible-modules-core/issues/4413">ansible/ansible-modules-core#4413</a></p>