<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto"><code class="notranslate">route53</code></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.0 (devel f5f7a8c681) last updated 2017/03/30 15:20:41 (GMT -400)
  config file = /Users/user/.ansible.cfg
  configured module search path = [u'/Users/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  python version = 2.7.13 (default, Dec 18 2016, 07:03:39) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]"><pre class="notranslate"><code class="notranslate">ansible 2.4.0 (devel f5f7a8c681) last updated 2017/03/30 15:20:41 (GMT -400)
  config file = /Users/user/.ansible.cfg
  configured module search path = [u'/Users/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  python version = 2.7.13 (default, Dec 18 2016, 07:03:39) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">N/A</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">macOS 10.12.4</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">The current route53 module should accept a <code class="notranslate">list</code> or <code class="notranslate">string</code> in the <code class="notranslate">value</code> parameter. Lists are used to have multiple values for a resource record in route53. (i.e. an NS or A record with multiple values). However, if an actual list is passed to the <code class="notranslate">value</code> parameter the module interprets it as a string split on the commas. This has the consequence of inserting a bunch of invalid data into a resource record.<br>
i.e: <code class="notranslate">value: ['ns-862.awsdns-43.net.', 'ns-449.awsdns-56.com.']</code> results in a resource record with the following data:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="['ns-862.awsdns-43.net.'
'ns-449.awsdns-56.com.']"><pre class="notranslate"><code class="notranslate">['ns-862.awsdns-43.net.'
'ns-449.awsdns-56.com.']
</code></pre></div>
<p dir="auto">The ONLY way the module works with a multi-valued resource record is by specifying it as a comma separated string.<br>
i.e: <code class="notranslate">value: ns-862.awsdns-43.net., ns-449.awsdns-56.com.</code> results in a resource record with the following data:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ns-449.awsdns-56.com.
ns-862.awsdns-43.net."><pre class="notranslate"><code class="notranslate">ns-449.awsdns-56.com.
ns-862.awsdns-43.net.
</code></pre></div>
<p dir="auto">Also, while this format works it does not always honor the order of the values because of the <code class="notranslate">route53</code> module sorts the values. i.e.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    value_list = ()

    if isinstance(value_in, str):
        if value_in:
            value_list = sorted([s.strip() for s in value_in.split(',')])
    elif isinstance(value_in, list):
        value_list = sorted(value_in)"><pre class="notranslate"><code class="notranslate">    value_list = ()

    if isinstance(value_in, str):
        if value_in:
            value_list = sorted([s.strip() for s in value_in.split(',')])
    elif isinstance(value_in, list):
        value_list = sorted(value_in)
</code></pre></div>
<p dir="auto">Also in the code above the route53 module code attempts to detect whether a string, comma-separated string, or a list was passed to the <code class="notranslate">value</code> parameter but this code seems to have no effect and is now duplicative of functions in the <code class="notranslate">AnsibleModule</code> class. i.e. The <code class="notranslate">_check_type_list</code> function.</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="- name: AWS | Create required records on Route53 zone
  route53:
    zone: zone.example.com
    command: create
    hosted_zone_id: Z21234567890
    type: NS
    ttl: 172800
    record: zone.example.com
    value: ['ns-862.awsdns-43.net.', 'ns-449.awsdns-56.com.', 'ns-1514.awsdns-61.org.', 'ns-1730.awsdns-24.co.uk.']
    overwrite: true"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">AWS | Create required records on Route53 zone</span>
  <span class="pl-ent">route53</span>:
    <span class="pl-ent">zone</span>: <span class="pl-s">zone.example.com</span>
    <span class="pl-ent">command</span>: <span class="pl-s">create</span>
    <span class="pl-ent">hosted_zone_id</span>: <span class="pl-c1">Z21234567890</span>
    <span class="pl-ent">type</span>: <span class="pl-s">NS</span>
    <span class="pl-ent">ttl</span>: <span class="pl-c1">172800</span>
    <span class="pl-ent">record</span>: <span class="pl-s">zone.example.com</span>
    <span class="pl-ent">value</span>: <span class="pl-s">['ns-862.awsdns-43.net.', 'ns-449.awsdns-56.com.', 'ns-1514.awsdns-61.org.', 'ns-1730.awsdns-24.co.uk.']</span>
    <span class="pl-ent">overwrite</span>: <span class="pl-c1">true</span></pre></div>
<p dir="auto">OR</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: AWS | Create required records on Route53 zone
  route53:
    zone: zone.example.com
    command: create
    hosted_zone_id: Z21234567890
    type: NS
    ttl: 172800
    record: zone.example.com
    value:
      - ns-862.awsdns-43.net.
      - ns-449.awsdns-56.com.
      - ns-1514.awsdns-61.org.
      - ns-1730.awsdns-24.co.uk.
    overwrite: true"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">AWS | Create required records on Route53 zone</span>
  <span class="pl-ent">route53</span>:
    <span class="pl-ent">zone</span>: <span class="pl-s">zone.example.com</span>
    <span class="pl-ent">command</span>: <span class="pl-s">create</span>
    <span class="pl-ent">hosted_zone_id</span>: <span class="pl-c1">Z21234567890</span>
    <span class="pl-ent">type</span>: <span class="pl-s">NS</span>
    <span class="pl-ent">ttl</span>: <span class="pl-c1">172800</span>
    <span class="pl-ent">record</span>: <span class="pl-s">zone.example.com</span>
    <span class="pl-ent">value</span>:
      - <span class="pl-s">ns-862.awsdns-43.net.</span>
      - <span class="pl-s">ns-449.awsdns-56.com.</span>
      - <span class="pl-s">ns-1514.awsdns-61.org.</span>
      - <span class="pl-s">ns-1730.awsdns-24.co.uk.</span>
    <span class="pl-ent">overwrite</span>: <span class="pl-c1">true</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ns-862.awsdns-43.net.
ns-449.awsdns-56.com.
ns-1514.awsdns-61.org.
ns-1730.awsdns-24.co.uk."><pre class="notranslate"><code class="notranslate">ns-862.awsdns-43.net.
ns-449.awsdns-56.com.
ns-1514.awsdns-61.org.
ns-1730.awsdns-24.co.uk.
</code></pre></div>
<h5 dir="auto">ACTUAL RESULTS</h5>


<p dir="auto">Command is successful but results in a resource record with the following out of order AND invalid data:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="'ns-1514.awsdns-61.org.'
'ns-1730.awsdns-24.co.uk.']
'ns-449.awsdns-56.com.'
['ns-862.awsdns-43.net.'"><pre class="notranslate"><code class="notranslate">'ns-1514.awsdns-61.org.'
'ns-1730.awsdns-24.co.uk.']
'ns-449.awsdns-56.com.'
['ns-862.awsdns-43.net.'
</code></pre></div>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug  Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.5.2</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">OSX 10.9.1</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Playbook errors out on this simple implicit localhost example.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Create a playbook called <code class="notranslate">test.yml</code> with these contents:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- name: implicit localhost test...
  hosts: localhost
  tasks:
  - debug: msg=&quot;hello world&quot;"><pre class="notranslate"><code class="notranslate">
---
- name: implicit localhost test...
  hosts: localhost
  tasks:
  - debug: msg="hello world"
</code></pre></div>
<p dir="auto">Then run the file like so:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook test.yml"><pre class="notranslate"><code class="notranslate">ansible-playbook test.yml
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [debug msg=&quot;hello world&quot;] ***********************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;hello world&quot;
}"><pre class="notranslate"><code class="notranslate">TASK: [debug msg="hello world"] ***********************************************
ok: [localhost] =&gt; {
    "msg": "hello world"
}
</code></pre></div>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR: provided hosts list is empty"><pre class="notranslate"><code class="notranslate">ERROR: provided hosts list is empty
</code></pre></div>