<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mwarkentin/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mwarkentin">@mwarkentin</a> on 2016-03-28T13:51:44Z</p>

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

<ul dir="auto">
<li>Feature Idea</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">homebrew</p>
<h5 dir="auto">DESCRIPTION</h5>
<p dir="auto">It'd be nice if we could use the <code class="notranslate">brew bundle</code> command with ansible. Thoughts on if this should be a new module or included with the existing homebrew module?</p>
<p dir="auto"><code class="notranslate">brew bundle</code> options:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ brew bundle --help
brew bundle [-v|--verbose] [--file=&lt;path&gt;|--global]
brew bundle dump [--force] [--file=&lt;path&gt;|--global]
brew bundle cleanup [--force] [--file=&lt;path&gt;|--global]
brew bundle check [--file=&lt;path&gt;|--global]
brew bundle [--version]
brew bundle [-h|--help]

Usage:
Bundler for non-Ruby dependencies from Homebrew

brew bundle            install or upgrade all dependencies in a Brewfile
brew bundle dump       write all installed casks/formulae/taps into a Brewfile
brew bundle cleanup    uninstall all dependencies not listed in a Brewfile
brew bundle check      check if all dependencies are installed in a Brewfile

Options:
-v, --verbose          print verbose output
--force                uninstall dependencies or overwrite existing Brewfile
--file=&lt;path&gt;          set Brewfile path
--global               set Brewfile path to $HOME/.Brewfile
-h, --help             show this help message and exit
--version              show the version of homebrew-bundle"><pre class="notranslate"><code class="notranslate">$ brew bundle --help
brew bundle [-v|--verbose] [--file=&lt;path&gt;|--global]
brew bundle dump [--force] [--file=&lt;path&gt;|--global]
brew bundle cleanup [--force] [--file=&lt;path&gt;|--global]
brew bundle check [--file=&lt;path&gt;|--global]
brew bundle [--version]
brew bundle [-h|--help]

Usage:
Bundler for non-Ruby dependencies from Homebrew

brew bundle            install or upgrade all dependencies in a Brewfile
brew bundle dump       write all installed casks/formulae/taps into a Brewfile
brew bundle cleanup    uninstall all dependencies not listed in a Brewfile
brew bundle check      check if all dependencies are installed in a Brewfile

Options:
-v, --verbose          print verbose output
--force                uninstall dependencies or overwrite existing Brewfile
--file=&lt;path&gt;          set Brewfile path
--global               set Brewfile path to $HOME/.Brewfile
-h, --help             show this help message and exit
--version              show the version of homebrew-bundle
</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="143982474" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible-modules-extras/issues/1921" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible-modules-extras/issues/1921/hovercard" href="https://github.com/ansible/ansible-modules-extras/issues/1921">ansible/ansible-modules-extras#1921</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">network/lldp.py</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.2.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.2.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<h5 dir="auto">SUMMARY</h5>

<p dir="auto">LLDP module fails with a 'str' object does not support item assignment in some cases.  Occasionally when looping through the lldpctl output, it runs across duplicate variables.  When it tries to assign the new variable a previously assigned name, it throws an exception.  I was able to get around this by using a try except.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Full command output here for debugging:</p>
<p dir="auto"><a href="https://gist.github.com/antonym/01e1663c8790c65063ba2d3177fd9457">https://gist.github.com/antonym/01e1663c8790c65063ba2d3177fd9457</a></p>
<p dir="auto">Should be able to put that into a file, change up the module to cat that file out and you'll see the failure.</p>

<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: Ensure LLDP started
  service:
    name: lldpd
    state: started

- name: Gather LLDP facts about server
  lldp:"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">Ensure LLDP started</span>
  <span class="pl-ent">service</span>:
    <span class="pl-ent">name</span>: <span class="pl-s">lldpd</span>
    <span class="pl-ent">state</span>: <span class="pl-s">started</span>

- <span class="pl-ent">name</span>: <span class="pl-s">Gather LLDP facts about server</span>
  <span class="pl-ent">lldp</span>:</pre></div>

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

<p dir="auto">Expected LLDP info to be captured.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: 'str' object does not support item assignment<br>
fatal: [localhost]: FAILED! =&gt; {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File "/tmp/ansible_9j3yPm/ansible_module_lldp.py", line 94, in \n    main()\n  File "/tmp/ansible_9j3yPm/ansible_module_lldp.py", line 83, in main\n    lldp_output = gather_lldp()\n  File "/tmp/ansible_9j3yPm/ansible_module_lldp.py", line 76, in gather_lldp\n    current_dict[final] = value\nTypeError: 'str' object does not support item assignment\n", "module_stdout": "", "msg": "MODULE FAILURE"}</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="root@localhost:~# lldpctl -f keyvalue
lldp.eno1.via=LLDP
lldp.eno1.rid=2
lldp.eno1.age=0 day, 03:33:53
lldp.eno1.chassis.mac=54:7f:ee:a5:79:6c
lldp.eno1.chassis.name=servers-lab-1.sat6
lldp.eno1.chassis.descr=Cisco Nexus Operating System (NX-OS) Software 6.0(2)U5(1)
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved.
lldp.eno1.chassis.mgmt-ip=10.127.5.250
lldp.eno1.chassis.Bridge.enabled=on
lldp.eno1.chassis.Router.enabled=on
lldp.eno1.port.ifname=Ethernet1/5
lldp.eno1.port.descr=Ethernet1/5
lldp.eno1.vlan.vlan-id=906
lldp.eno1.vlan.pvid=yes
lldp.eno1.unknown-tlvs.unknown-tlv.oui=00,01,42
lldp.eno1.unknown-tlvs.unknown-tlv.subtype=1
lldp.eno1.unknown-tlvs.unknown-tlv.len=1
lldp.eno1.unknown-tlvs.unknown-tlv=01
lldp.eno1.unknown-tlvs.unknown-tlv.oui=00,01,42   &lt;- fails parsing this line because four lines up, same variable
"><pre class="notranslate"><code class="notranslate">root@localhost:~# lldpctl -f keyvalue
lldp.eno1.via=LLDP
lldp.eno1.rid=2
lldp.eno1.age=0 day, 03:33:53
lldp.eno1.chassis.mac=54:7f:ee:a5:79:6c
lldp.eno1.chassis.name=servers-lab-1.sat6
lldp.eno1.chassis.descr=Cisco Nexus Operating System (NX-OS) Software 6.0(2)U5(1)
TAC support: http://www.cisco.com/tac
Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved.
lldp.eno1.chassis.mgmt-ip=10.127.5.250
lldp.eno1.chassis.Bridge.enabled=on
lldp.eno1.chassis.Router.enabled=on
lldp.eno1.port.ifname=Ethernet1/5
lldp.eno1.port.descr=Ethernet1/5
lldp.eno1.vlan.vlan-id=906
lldp.eno1.vlan.pvid=yes
lldp.eno1.unknown-tlvs.unknown-tlv.oui=00,01,42
lldp.eno1.unknown-tlvs.unknown-tlv.subtype=1
lldp.eno1.unknown-tlvs.unknown-tlv.len=1
lldp.eno1.unknown-tlvs.unknown-tlv=01
lldp.eno1.unknown-tlvs.unknown-tlv.oui=00,01,42   &lt;- fails parsing this line because four lines up, same variable

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