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

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">docker_container</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible --version
ansible 2.2.1.0
  config file = /Users/alebedev/projects/ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible --version
ansible 2.2.1.0
  config file = /Users/alebedev/projects/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">N/A</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">port_published fails when uses a port range as an argument</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: Starting container
  docker_container:
    name: pool
    image: pool
    privileged: true
    network_mode: bridge
    exposed_ports:
      - 8080:8080
      - 5000-5040:5000-5040
    published_ports:
      - 8080:8080
      - 5000-5040:5000-5040
    detach: true
    restart_policy: on-failure
    interactive: true
    state: started"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Starting container</span>
  <span class="pl-ent">docker_container</span>:
    <span class="pl-ent">name</span>: <span class="pl-s">pool</span>
    <span class="pl-ent">image</span>: <span class="pl-s">pool</span>
    <span class="pl-ent">privileged</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">network_mode</span>: <span class="pl-s">bridge</span>
    <span class="pl-ent">exposed_ports</span>:
      - <span class="pl-c1">8080:8080</span>
      - <span class="pl-s">5000-5040:5000-5040</span>
    <span class="pl-ent">published_ports</span>:
      - <span class="pl-c1">8080:8080</span>
      - <span class="pl-s">5000-5040:5000-5040</span>
    <span class="pl-ent">detach</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">restart_policy</span>: <span class="pl-s">on-failure</span>
    <span class="pl-ent">interactive</span>: <span class="pl-c1">true</span>
    <span class="pl-ent">state</span>: <span class="pl-s">started</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Expecting that container will be up and running with a published port range accordingly to official documentation from docker:<br>
<a href="https://docs.docker.com/engine/reference/run/#/expose-incoming-ports" rel="nofollow">https://docs.docker.com/engine/reference/run/#/expose-incoming-ports</a></p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [pool]: FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;failed&quot;: true,
    &quot;invocation&quot;: {
        &quot;module_name&quot;: &quot;docker_container&quot;
    },
    &quot;module_stderr&quot;: &quot;OpenSSH_7.3p1, LibreSSL 2.4.1\r\ndebug1: Reading configuration data /Users/alebedev/.ssh/config\r\ndebug1: /Users/alebedev/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 20: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 33959\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 127.0.0.1 closed.\r\n&quot;,
    &quot;module_stdout&quot;: &quot;\r\nTraceback (most recent call last):\r\n  File \&quot;/tmp/ansible_oqSXjO/ansible_module_docker_container.py\&quot;, line 2007, in &lt;module&gt;\r\n    main()\r\n  File \&quot;/tmp/ansible_oqSXjO/ansible_module_docker_container.py\&quot;, line 2000, in main\r\n    cm = ContainerManager(client)\r\n  File \&quot;/tmp/ansible_oqSXjO/ansible_module_docker_container.py\&quot;, line 1644, in __init__\r\n    self.parameters = TaskParameters(client)\r\n  File \&quot;/tmp/ansible_oqSXjO/ansible_module_docker_container.py\&quot;, line 759, in __init__\r\n    self.published_ports = self._parse_publish_ports()\r\n  File \&quot;/tmp/ansible_oqSXjO/ansible_module_docker_container.py\&quot;, line 968, in _parse_publish_ports\r\n    container_port = int(parts[-1])\r\nValueError: invalid literal for int() with base 10: '5000-5040'\r\n&quot;
}

MSG:

MODULE FAILURE"><pre class="notranslate"><code class="notranslate">fatal: [pool]: FAILED! =&gt; {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_name": "docker_container"
    },
    "module_stderr": "OpenSSH_7.3p1, LibreSSL 2.4.1\r\ndebug1: Reading configuration data /Users/alebedev/.ssh/config\r\ndebug1: /Users/alebedev/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 20: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 33959\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 127.0.0.1 closed.\r\n",
    "module_stdout": "\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_oqSXjO/ansible_module_docker_container.py\", line 2007, in &lt;module&gt;\r\n    main()\r\n  File \"/tmp/ansible_oqSXjO/ansible_module_docker_container.py\", line 2000, in main\r\n    cm = ContainerManager(client)\r\n  File \"/tmp/ansible_oqSXjO/ansible_module_docker_container.py\", line 1644, in __init__\r\n    self.parameters = TaskParameters(client)\r\n  File \"/tmp/ansible_oqSXjO/ansible_module_docker_container.py\", line 759, in __init__\r\n    self.published_ports = self._parse_publish_ports()\r\n  File \"/tmp/ansible_oqSXjO/ansible_module_docker_container.py\", line 968, in _parse_publish_ports\r\n    container_port = int(parts[-1])\r\nValueError: invalid literal for int() with base 10: '5000-5040'\r\n"
}

MSG:

MODULE FAILURE
</code></pre></div>
<h5 dir="auto">Issue Type:</h5>

<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">Ansible Version:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2.0.0.1"><pre class="notranslate"><code class="notranslate">2.0.0.1
</code></pre></div>
<h5 dir="auto">Summary:</h5>
<p dir="auto">This isn't an issue for sure, maybe a feature idea. I want to lint a playbook to detect following few among many other possibilities:</p>
<ol dir="auto">
<li>Undefined variable</li>
<li>Unused variable</li>
<li>See if vars defined, when case-ignored, are same( <em>conflicting vars</em> hereafter)</li>
</ol>
<p dir="auto">I'm not able to figure out what is the good way to do this? I don't want to re-invent the wheel, in the sense that:</p>
<ol dir="auto">
<li>I don't want to do text processing. Ansible does this to accomplish its task.</li>
<li>Hooks or callbacks if I'm not wrong are couple of levels higher than where I think my solution should hop in.</li>
</ol>
<p dir="auto">My intention is to write a tool that seamlessly, and optionally, works with ansible. I would like not to modify ansible's code if I can do without.</p>
<p dir="auto">Any help or hack or suggestion is appreciated. TIA.</p>