Skip to content

Commit

Permalink
Install custom 'snmpd.service' unit file
Browse files Browse the repository at this point in the history
This file fixes issues with snmpd on hosts with LXC containers. It will
be activated automatically by systemd.
  • Loading branch information
drybjed committed Jun 20, 2015
1 parent f160d8f commit 0e99dd4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ v0.1.0

- Fix wrongly named variable in ``/etc/default/snmpd``. [drybjed]

- Install a custom ``snmpd.service`` unit file to replace Debian provided init
script, which causes issues with ``snmpd`` daemon on hosts with LXC
containers. This unit file will be automatically activated on hosts with
``systemd`` enabled. [drybjed]

25 changes: 25 additions & 0 deletions files/etc/systemd/system/snmpd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# snmpd.service unit file
# Copyright (C) Maciej Delmanowski <[email protected]>
# Homepage: http://debops.org/

# This unit file fixes issues with snmpd service running inside LXC containers
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=727105
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718702

[Unit]
Description=Simple Network Management Protocol (SNMP) Daemon
Documentation=man:snmpd(8)
Documentation=man:snmpcmd(1)
After=network.target

[Service]
Environment="MIBDIRS=/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf"
EnvironmentFile=-/etc/default/snmpd
PIDFile=/run/snmpd.pid
TimeoutStartSec=0
ExecStart=/usr/sbin/snmpd $SNMPDOPTS -f

[Install]
WantedBy=multi-user.target
WantedBy=lldpd.service

1 change: 1 addition & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- name: Restart snmpd
service:
name: 'snmpd'
enabled: True
state: 'restarted'

- name: Restart lldpd
Expand Down
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
with_flattened:
- [ '{{ "lldpd" if not snmpd_lldpd else [] }}' ]

- name: Install custom snmpd.service unit file
copy:
src: 'etc/systemd/system/snmpd.service'
dest: '/etc/systemd/system/snmpd.service'
owner: 'root'
group: 'root'
mode: '0644'
notify: [ 'Restart snmpd' ]

- name: Enable MIBs support
lineinfile:
dest: '/etc/snmp/snmp.conf'
Expand Down

0 comments on commit 0e99dd4

Please sign in to comment.