<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">azure_rm_common.py</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">The current definition of the azure_rm common module utils doesn't allow overriding the various built-in endpoints (auth, table/blob storage, service bus, etc). This will be necessary to allow connection to other Azure instances (eg, AzureChinaCloud, private Azure Stack instances).</p>
<p dir="auto">The new Python SDK seems to support overriding the endpoints via host_base, so we should add the override capability to the env credential mapping and common module utility code.</p>
<p dir="auto">List of AzureChinaCloud endpoint URLs is at: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="57563350" data-permission-text="Title is private" data-url="https://github.com/Azure/azure-sdk-for-python/issues/284" data-hovercard-type="issue" data-hovercard-url="/Azure/azure-sdk-for-python/issues/284/hovercard" href="https://github.com/Azure/azure-sdk-for-python/issues/284">Azure/azure-sdk-for-python#284</a></p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">lineinfile in combination with_items</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.3.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]"><pre class="notranslate"><code class="notranslate">ansible 2.3.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">Ansible does not insert line if the identical value has been used before in loop, but only if the value of line is different.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: localhost
    
  tasks:
    - name: create test file
      copy:
        dest: /tmp/example.txt
        content: |
          1
          
          2
          
          3
          
          4
          

    - name: broken lineinfile
      lineinfile:
        path: /tmp/example.txt
        insertafter: &quot;{{ item.regex }}&quot;
        line: &quot;{{ item.replace }}&quot;
        unsafe_writes: yes
      with_items:
        - { regex: '1', replace: 'bar' }
        - { regex: '2', replace: 'bar' }
        - { regex: '3', replace: 'br' }
        - { regex: '4', replace: 'bar' }
"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
    
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">create test file</span>
      <span class="pl-ent">copy</span>:
        <span class="pl-ent">dest</span>: <span class="pl-s">/tmp/example.txt</span>
        <span class="pl-ent">content</span>: <span class="pl-s">|</span>
<span class="pl-s">          1</span>
<span class="pl-s">          </span>
<span class="pl-s">          2</span>
<span class="pl-s">          </span>
<span class="pl-s">          3</span>
<span class="pl-s">          </span>
<span class="pl-s">          4</span>
<span class="pl-s">          </span>
<span class="pl-s"></span>
<span class="pl-s"></span>    - <span class="pl-ent">name</span>: <span class="pl-s">broken lineinfile</span>
      <span class="pl-ent">lineinfile</span>:
        <span class="pl-ent">path</span>: <span class="pl-s">/tmp/example.txt</span>
        <span class="pl-ent">insertafter</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ item.regex }}<span class="pl-pds">"</span></span>
        <span class="pl-ent">line</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ item.replace }}<span class="pl-pds">"</span></span>
        <span class="pl-ent">unsafe_writes</span>: <span class="pl-s">yes</span>
      <span class="pl-ent">with_items</span>:
        - <span class="pl-s">{ regex: '1', replace: 'bar' }</span>
        - <span class="pl-s">{ regex: '2', replace: 'bar' }</span>
        - <span class="pl-s">{ regex: '3', replace: 'br' }</span>
        - <span class="pl-s">{ regex: '4', replace: 'bar' }</span>
</pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1
bar

2
bar

3
br

4
bar"><pre class="notranslate"><code class="notranslate">1
bar

2
bar

3
br

4
bar
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1
bar

2

3
br

4"><pre class="notranslate"><code class="notranslate">1
bar

2

3
br

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