Git Product home page Git Product logo

puppet-lldpd's Introduction

puppet-lldpd

Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores puppetmodule.info docs AGPL v3 License

Table of Contents


Overview

LLDP stands for Link Layer Discovery Protocol. This module manages the LLDP implementation from Vincent Bernat. puppet-strings docs are available in /docs. They are generated before each release. This module configures the upstream repo if necessary. The LLDP requires a daemon, which will be started. the command line client has support for json output. This is used to create a structured fact. It is updated automatically with a systemd timer (or a cronjob on legacy systems).

The REFERENCE.md contains puppet-strings generated docs.

Setup

This is very easy:

include lldpd

You can disable the repo management:

class{'lldpd':
  manage_repo => false,
}

Support

This module supports the installation on:

  • Archlinux
  • CentOS 7
  • Fedora 32
  • Debian 9
  • Debian 10
  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • VirtuozzoLinux 7
  • FreeBSD 11
  • FreeBSD 12

The fact is present on all Operating Systems except for FreeBSD. Docker acceptance tests work for CentOS 6 and 7. Vagrant acceptance tests work for Fedora 25. Other nodesets are currently not present. The module requires at least Puppet 4.9.4 (this is the first version with proper data-in-modules support).

Development

This project contains tests for rspec-puppet.

Quickstart to run all linter and unit tests:

bundle install --path .vendor/ --without system_tests --without development --without release
bundle exec rake test

For acceptance tests:

bundle install --path .vendor/ --with system_tests --without development --without release
BEAKER_debug=true PUPPET_INSTALL_TYPE=agent bundle exec rake beaker:fedora-25-x64
BEAKER_debug=true PUPPET_INSTALL_TYPE=agent bundle exec rake acceptance BEAKER_set=docker/centos-7

Authors

puppet-lldpd is maintained by Vox Pupuli, it was written by Tim 'bastelfreak' Meusel.

puppet-lldpd's People

Contributors

alexjfisher avatar b4ldr avatar bastelfreak avatar dhollinger avatar dhoppe avatar ekohl avatar foxxx0 avatar jchonig avatar jhoblitt avatar juniorsysadmin avatar kbite avatar kengelhardt-godaddy avatar llowder avatar sebastianrakel avatar smortex avatar themeier avatar tragiccode avatar yakatz avatar zilchms avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-lldpd's Issues

Publish 3.0.1 as 3.0.2

the 3.0.1 release wasn't successful because the CI pipeline failed. 3.0.2 contains the same Puppet code + a fixed Gemfile

Debian Repo key has changed, fingerprint needs to be updated

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet:
  • Ruby:
  • Distribution:
  • Module version:

How to reproduce (e.g Puppet code you use)

Use the module with default parameters on Debian or Ubuntu.

Run apt update or similar

What are you seeing

Failure to update from the configured repo

What behaviour did you expect instead

Output log

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://download.opensuse.org/repositories/home:/vbernat/xUbuntu_16.04  InRelease: The following signatures were invalid: KEYEXPIRED 1593100053
W: Failed to fetch http://download.opensuse.org/repositories/home:/vbernat/xUbuntu_16.04/InRelease  The following signatures were invalid: KEYEXPIRED 1593100053

Any additional information you'd like to impart

If it can't connect to `lldpd` daemon custom fact `lldp` should not return MalformedDataError

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.x, 8.x
  • Ruby: 2.7.x, 3.2.x
  • Distribution: AlmaLinux 8, AlmaLinux 9
  • Module version: every version since v3.3.0-2-g14a43

How to reproduce ( including debug output)

# facter -p lldp
[2023-05-03 18:29:28.181294 ] WARN Facter - invalid or malformed lldp data: MalformedDataError: no lldp interface data found
# facter --debug -p lldp
...
[2023-05-03 18:27:41.184214 ] DEBUG Facter::FactLoader - Loading external facts
[2023-05-03 18:27:41.185501 ] DEBUG Facter::QueryParser - List of resolvable facts: [#<Facter::SearchedFact:0x00007fc09c46b950 @name="lldp", @fact_class=nil, @user_query="lldp", @type=:custom, @file=nil>]
[2023-05-03 18:27:41.185733 ] DEBUG Facter::Core::Execution::Posix - Executing command: /sbin/lldpctl -f json
[2023-05-03 18:27:41.191637 ] DEBUG lldpctl -f json - Command /sbin/lldpctl -f json completed with the following stderr message: 2023-05-03T18:27:41 [WARN/control] unable to connect to socket /run/lldpd/lldpd.socket: No such fil
e or directory
2023-05-03T18:27:41 [WARN/lldpctl] not able to get the list of interfaces. Unable to connect to lldpd daemon
[2023-05-03 18:27:41.191765 ] WARN Facter - invalid or malformed lldp data: MalformedDataError: no lldp interface data found
[2023-05-03 18:27:41.191822 ] DEBUG Facter - /opt/puppetlabs/puppet/cache/lib/facter/lldp.rb:18:in `block (2 levels) in <top (required)>'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/resolution.rb:196:in `resolve_value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:78:in `block (2 levels) in value'
        /opt/puppetlabs/puppet/lib/ruby/3.2.0/timeout.rb:173:in `timeout'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:77:in `block in value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:102:in `with_timing'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/resolvable.rb:76:in `value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:211:in `block in find_first_real_value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:209:in `each'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:209:in `find_first_real_value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:131:in `block (2 levels) in value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/benchmarking/timer.rb:18:in `measure'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:130:in `block in value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:177:in `searching'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/util/fact.rb:127:in `value'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:21:in `block in external_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:19:in `each'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:19:in `external_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact/external/external_fact_manager.rb:7:in `resolve_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/core/fact_manager.rb:24:in `resolve_facts'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:530:in `resolve_facts_for_user_query'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:461:in `to_user_output'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli.rb:124:in `query'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
        /opt/puppetlabs/puppet/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
        /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli_launcher.rb:23:in `start'
        /opt/puppetlabs/puppet/bin/facter:10:in `<main>'
...

What do you expect?

If I understand https://www.puppet.com/docs/puppet/8/custom_facts.html correctly failing to resolve lldp shouldn't return warning, but nil in case lldpd daemon is not running.

If the fact fails to resolve or is not present, Facter returns nil.

If it should keep returning warning (e.g. for compatibility) it should return (a substring of) lldpctl's actual warnings :

# /sbin/lldpctl -f json
2023-05-03T18:28:31 [WARN/control] unable to connect to socket /run/lldpd/lldpd.socket: No such file or directory
2023-05-03T18:28:31 [WARN/lldpctl] not able to get the list of interfaces. Unable to connect to lldpd daemon
{
  "lldp": {

  }
}

Broken repo management

if $manage_repo is true, the module uses base::yumrepo to manage the actual repository files. This isn't a public resource and should be replaced with yumrepo. Otherwise it isn't possible to use the module.

Default apt key checksum mismatch

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet:
  • Ruby:
  • Distribution: Debian 11
  • Module version: 4.0.2

What are you seeing

Failure when trying to do a puppet run using this module:
[exec] Error: File written to disk did not match desired checksum; discarding changes ({sha256}4f9e668fbdaaedf4fc8d83f4eb98db33553d7f4e1f0bca212d0a7ccc9f1a6adf vs {sha256}2e532e3f800b788b0248da86b1cd722e58e9c99413912fd029c20d88d55ebadc)
[exec] Error: /Stage[main]/Lldpd/File[/usr/share/keyrings/lldpd.asc]/ensure: change from 'absent' to 'file' failed: File written to disk did not match desired checksum; discarding changes ({sha256}4f9e668fbdaaedf4fc8d83f4eb98db33553d7f4e1f0bca212d0a7ccc9f1a6adf vs {sha256}2e532e3f800b788b0248da86b1cd722e58e9c99413912fd029c20d88d55ebadc)

Any additional information you'd like to impart

Minor problem since it's easy to work around in hiera.

Interestingly:

$ curl -s https://download.opensuse.org/repositories/home:/vbernat/Debian_11/Release.key | sha256sum
4f9e668fbdaaedf4fc8d83f4eb98db33553d7f4e1f0bca212d0a7ccc9f1a6adf  -
$ curl -s https://download.opensuse.org/repositories/home:/vbernat/xUbuntu_22.04/Release.key | sha256sum
2e532e3f800b788b0248da86b1cd722e58e9c99413912fd029c20d88d55ebadc  -

So (at least right now) different keys are used to sign the packages for different distributions.

Error handling in `lldp2facts`

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.4
  • Ruby:
  • Distribution: Redhat 7
  • Module version: master

What are you seeing

Sometimes lldpctl or jq fail several times. We have not been able to determine exactly what causes this to happen, but it causes random unhandled errors in the bash script which are then sent to us by email. I know we could stop getting email, but it would be better if the script could handle errors.

We usually get either mv: cannot stat ‘/tmp/lldp.json’: No such file or directory or rm: cannot remove ‘/tmp/lldp.json’: No such file or directory. There is no pattern to when the errors come and there usually isn't more than one or two a day from our several hundred machines.

What behaviour did you expect instead

lldp2facts should handle errors

Any additional information you'd like to impart

Happy to help debug if I know what to look for.

new fact doesn't work on servers with a single interface

Error during puppet run:

Warning: Facter: Failed to parse lldpctl -f json: NoMethodError: undefined method `keys' for ["enp3s0", {"via"=>"LLDP", "rid"=>"1", "age"=>"0 day, 00:05:55", "chassis"=>{"id"=>{"type"=>"mac", "value"=>"44:94:fc:9d:55:0a"}, "mgmt-ip"=>"192.168.178.21", "mgmt-iface"=>"51"}, "port"=>{"id"=>{"type"=>"local", "value"=>"g17"}, "ttl"=>"120"}}]:Array
Warning: Facter: Failed to parse lldpctl -f json: NoMethodError: undefined method `keys' for ["enp3s0", {"via"=>"LLDP", "rid"=>"1", "age"=>"0 day, 00:05:55", "chassis"=>{"id"=>{"type"=>"mac", "value"=>"44:94:fc:9d:55:0a"}, "mgmt-ip"=>"192.168.178.21", "mgmt-iface"=>"51"}, "port"=>{"id"=>{"type"=>"local", "value"=>"g17"}, "ttl"=>"120"}}]:Array

lldpctl output:

{
  "lldp": {
    "interface": {
      "enp3s0": {
        "via": "LLDP",
        "rid": "1",
        "age": "0 day, 00:02:12",
        "chassis": {
          "id": {
            "type": "mac",
            "value": "44:94:fc:9d:55:0a"
          },
          "mgmt-ip": "192.168.178.21",
          "mgmt-iface": "51"
        },
        "port": {
          "id": {
            "type": "local",
            "value": "g17"
          },
          "ttl": "120"
        }
      }
    }
  }
}

package version:

# pacman -Qi lldpd
Name            : lldpd
Version         : 1.0.14-1
Description     : 802.1ab implementation (LLDP) to help you locate neighbors
Architecture    : x86_64
URL             : https://vincentbernat.github.io/lldpd/
Licenses        : custom:ISC  GPL
Groups          : None
Provides        : None
Depends On      : glibc  libevent  libbsd  zlib  openssl  pciutils  perl  libxml2  net-snmp  jansson
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 743.22 KiB
Packager        : Christian Hesse <[email protected]>
Build Date      : Sun 22 May 2022 07:38:12 PM UTC
Install Date    : Tue 12 Jul 2022 08:46:16 AM UTC
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

This happens with commit 7c0e770. @foxxx0 do you have some time to look into this?

Apt::Source[lldpd]: has no parameter named 'keyring'

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet:
  • Ruby:
  • Distribution: Debian 11
  • Module version: 4.0.2

How to reproduce (e.g Puppet code you use)

Combine puppet-lldpd with older puppetlabs-apt (7.4.2 in our case)

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Apt::Source[lldpd]: has no parameter named 'keyring' (file: /etc/puppetlabs/code/environments/production/modules/lldpd/manifests/init.pp, line: 53) on node <node>

Any additional information you'd like to impart

On puppetlabs-apt 7.4.2 apt::source indeed doesn't have the keyring parameter. It was introduced in 8.1.0 (puppetlabs/puppetlabs-apt#991). Probably the dependency should be bumped?

Add official ubuntu 18.04 support

Ubuntu 18.04 is already supported by the module, but it isn't mentioned in the metadata.json and it isn't tested. We need to update our tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.