=head1 NAME App::Netdisco::Manual::Configuration - How to Configure Netdisco =head1 INTRODUCTION The configuration files for Netdisco come with all options set to sensible default values, and just a few that you must initially set yourself. There are two configuration files: C (which lives inside Netdisco) and C (which usually lives in C<${HOME}/environments>). The C file includes defaults for every setting, and should be left alone. Any time you want to set an option, use only the C file. The two are merged when Netdisco starts, with your settings in C overriding the defaults from C. =head2 YAML GUIDANCE The configuration file format for Netdisco is YAML. This is easy for humans to edit, but you should take care with whitespace and avoid TAB characters. YAML supports several data types: =over 4 =item * Boolean - True/False value, using C<1> and C<0> or C and C respectively, e.g.: check_userlog: true =item * List - Set of things using C<[a, b, c]> on one line or C<-> on separate lines, e.g.: community: ['public', 'another'] discover_no: - '192.0.2.0/24' - '2001:db8::/32' =item * Dictionary - Key/Value pairs (like Perl Hash) using C<< {key1: val1, key2: val2} >> on one line or C on separate lines, e.g.: port_control_reasons: address: 'Address Allocation Abuse' copyright: 'Copyright Violation' =item * String - Quoted, just like in Perl (and essential if the item contains the colon character). =back =head2 ACCESS CONTROL LISTS Access Control Lists (ACLs) appear in many places in the configuration file, used to select or exclude devices or hosts for certain settings. ACLs are a single item or YAML list of items, which can contain: =over 4 =item * Hostname, IP address, IP prefix (i.e. subnet), such as: - hostname.example.com - 192.0.2.1 - '2001:db8::/32' =item * IP address range, using a hyphen on the last octet/hextet, and no whitespace: - 192.0.2.1-10 =item * Regular expression in YAML format (no enforced anchors) which will match the device DNS name (using a fresh DNS lookup, so works on new discovery), e.g.: - !!perl/regexp ^sep0.*$ =item * "C" - matched against a device property, such as C or C (with enforced begin/end regexp anchors). - vendor:cisco =item * "C" to reference the "C" group within the C setting. This is a way to either include ACLs in other ACLs, or re-use ACLs. =item * "C" to require all items to match (or not match) the provided IP or device. Note that this includes IP address version mismatches (v4-v6). =back To negate any item in an ACL (except YAML regexp), prefix with "C", for example "C". In that case the test will be that the ACL entry does I match the device or IP being assessed. Note, however, that the first match in an ACL wins (because the default mode is "OR"), so take care over the order of items, or include "C" in the ACL if appropriate. To match any device, use "C". To match no devices use "C". Configuration settings in Netdisco that take an Access Control List (most of the "C<*_no>" and "C<*_only>" settings, and "C" settings) can accept either a YAML list of the above items, or merely a single item. This is useful if you create a C entry and wish to reference that as the ACL. =head1 SUPPORTED SETTINGS =head2 Essential Settings If you followed the installation instructions, then you should have set the database connection parameters to match those of your local system. That is, the database C, C, C and C. =head2 General Settings =head3 C Value: C. Default: C. The log level used by Netdisco. It's useful to see warning messages from the backend poller, as this can highlight broken topology. =head3 C Value: Format String. Default: C<< '[%P] %U %L %m' >>. Structure of the log messages. See L for details. =head3 C Value: List. Default: Empty List. Additional library paths for the application (both web frontend and backend poller daemons). You can also use a colon-separated list in the "C" environment variable which makes code available even earlier in the app startup sequence. =head3 C Value: List. Default: Empty List. Additional paths for L templates. Files in these paths will be loaded before (and hence override) any templates built in to Netdisco. If you want to copy and override a built in web template, then create the directories necessary (such as "ajax" or "sidebar") in this path. Note that templates may need to have a further "C" subdirectory created. =head3 C Value: Boolean. Default: false. A shortcut for using C and C. Setting this to true will push C<< $ENV{NETDISCO_HOME}/nd-site-local/{lib,share} >> into those settings, respectively. You can then put Perl code in C and templates in C within the C directory. Note that you still need to create the directories yourself, and templates may need to have a further "C" subdirectory created within "C". =head3 C Value: List of Database Configuration Hashes. Default: None. The Plugins and User Reports features of Netdisco can gather data from external databases. You need to install the Perl database driver for the target database platform, and configure this setting appropriately. For example: external_databases: - tag: externaldb dsn: 'dbi:Pg:dbname=myexternaldb;host=192.0.2.1' user: oliver password: letmein options: pg_enable_utf8: true Note that C is I and maps to the C key if you use the Generic Reports feature (see "L", below), or becomes the Dancer database schema name if you program the Plugin directly. =head2 Web Frontend =head3 C Value: String. Default: None. Set this to your local site's domain name. This is usually removed from node names in the web interface to make things more readable. Make sure to include the leading dot character. =head3 C Value: Boolean. Default: C. Enable this to disable login authentication in the web frontend. The username will be set to C so if you want to allow extended permissions (C or C), create a dummy user with the appropriate flag in the database: netdisco=> insert into users (username) values ('guest'); netdisco=> update users set port_control = true where username = 'guest'; netdisco=> update users set admin = true where username = 'guest'; =head3 C Value: Boolean. Default: C. Set this to C to disable the device autocomplete in the main navbar. =head3 C Value: Boolean. Default: C. Enable this to display a banner suggesting to log in with a guest account. The username and password of this account must both be "guest". =head3 C Value: Boolean. Default: C. Enable this if Netdisco is running within another web server such as Apache, and you want that server to handle user authentication. Normally the authenticated username will automatically be set in the C environment variable. See L for further details. =head3 C Value: Boolean. Default: C. Enable this if you proxy requests to Netdisco via another web server such as Apache, and you want that server to handle user authentication. You need to configure the authorized username to be passed from the frontend environment to Netdisco in the C HTTP Header. For example with Apache: RequestHeader unset X-REMOTE_USER RequestHeader set X-REMOTE_USER "%{REMOTE_USER}e" env=REMOTE_USER When running securely (https), replace C<< "%{REMOTE_USER}e" >> with C<< "%{REMOTE_USER}s" >>. =head3 C Value: Boolean. Default: C. Enable this to check that remote users (usernames that come from a frontend proxy server) also exist in the Netdisco Users database. No password check is made. This can be useful when you have web login or single sign-on on the frontend web server, but also want to limit to a set of known users in Netdisco. You can still load those users into the database in Netdisco and enable this setting to check any proxied access can be mapped to a known user. =head3 C Value: Settings Tree. Default: None. If set, and a user has the C flag also set on their account, then LDAP authentication will be used for their login. ldap: servers: - 'ad.example.com' user_string: 'MYDOMAIN\%USER%' opts: debug: 0 There are several options within this setting: =head4 C This must be a list of one or more LDAP servers. If using Active Directory these would be your Domain Controllers. =head4 C String to construct the user portion of the DN. C<%USER%> is a variable which will be replaced at runtime with the logon name entered on the logon page of the application. Active Directory users may simply use C and skip all other options except C, as this notation eliminates the need to construct the full distinguished name. Examples: C or C. =head4 C Indicates where in the hierarchy to begin searches. If a proxy user is not defined and anonymous binds are not enabled this value will be appended to the C to construct the distinguished name for authentication. =head4 C User to bind with to perform searches. If defined as C, then anonymous binds will be performed and C will be ignored. For organizations with users in multiple OUs this option can be used to search for the user and construct the DN based upon the result. =head4 C Proxy user password. Ignored if proxy user defined as anonymous. =head4 C Hash of options to add to the connect string. Normally only needed if server does not support LDAPv3, or to enable debugging as in the example above. =head4 C A hash which, when defined, causes the connection tol use Transport Layer Security (TLS) which provides an encrypted connection. TLS is the preferred method of encryption, ldaps (port 636) is not supported. This is only possible if using LDAPv3 and the server supports it. These are the options for the TLS connection. See the L documentation under start_tls for options, but the defaults should work in most cases. =head3 C Value: String. Default: None. Mount point for the Netdisco web frontend. This is usually the root of the web server. Set this to the path under which all pages live, e.g. C. As an alternative you can use the C<--path> option to C. =head3 C Value: List of Modules. Default: List of bundled L names. Netdisco's plugin system allows the user more control over the user interface. Plugins can be distributed independently from Netdisco and are a better alternative to source code patches. This setting is the list of Plugins which are used in the default Netdisco distribution. You can override this to set your own list. If you only want to add to the default list then use C, which allows the Netdisco developers to update default C in a future release. Entries in the list will by default omit the leading C from the name. To override this for one entry, prefix it with a C<+> sign. You can also prefix with C to signify the alternate C namepsace. =head3 C Value: List of Modules. Default: Empty List. List of additional L names to load. See also the C setting. =head3 C Value: List of Reports Hashes. Default: None. Use this configuration to add reports to Netdisco without writing any Perl code or HTML templates. For example: reports: - tag: power_inventory label: 'Power Supply Inventory' category: Device columns: - {name: 'Name'} - {ps1_type: 'PS1 Type'} - {ps1_status: 'PS1 Status'} query: | SELECT d.name, d.ps1_type, d.ps1_status FROM device d ORDER BY name The C of each item in the C configuration is an alias for the report, and becomes part of the web path. You can munge the data retrieved from the database by placing a Perl script with the same name as the C key into the "C" directory of Netdisco's home area. The script can access C<$config> for its configuration and C<@data> for the retrieved data. It should return a list of munged data. Within the tree you can provide each of the keys below: =head4 C Alias for the Report, which must be usable in a web path. =head4 C