diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | docs/Sources.md | 25 | ||||
-rw-r--r-- | lib/oxidized/source/csv.rb | 4 |
3 files changed, 27 insertions, 5 deletions
@@ -246,15 +246,12 @@ oxidized Now tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CSV source add the following snippet: -Note: If gpg is set to anything other than false it will attempt to decrypt the file contents ``` source: default: csv csv: file: ~/.config/oxidized/router.db delimiter: !ruby/regexp /:/ - gpg: false - gpg_password: 'password' map: name: 0 model: 1 diff --git a/docs/Sources.md b/docs/Sources.md index b04261c..7029b72 100644 --- a/docs/Sources.md +++ b/docs/Sources.md @@ -26,6 +26,31 @@ Example csv `/var/lib/oxidized/router.db`: rtr01.local:192.168.1.1:ios:oxidized:5uP3R53cR3T:T0p53cR3t ``` +If you would like to use a GPG encrypted file as the source then you can use the following example: + +```yaml +source: + default: csv + csv: + file: ~/.config/oxidized/router.db + delimiter: !ruby/regexp /:/ + gpg: true + gpg_password: 'password' + map: + name: 0 + model: 1 +``` + +> Please note, if you are running GPG v2 then you will be prompted for your gpg password on start up, if you use GPG >= 2.1 then you can add the following config to stop that behaviour: + +> Within `~/.gnupg/gpg-agent.conf` + +> `allow-loopback-pinentry` + +> and within: `~/.gnupg/gpg.conf` + +> `pinentry-mode loopback` + ### Source: SQL Oxidized uses the `sequel` ruby gem. You can use a variety of databases that aren't explicitly listed. For more information visit https://github.com/jeremyevans/sequel Make sure you have the correct adapter! ### Source: MYSQL diff --git a/lib/oxidized/source/csv.rb b/lib/oxidized/source/csv.rb index c1e310a..27cb49e 100644 --- a/lib/oxidized/source/csv.rb +++ b/lib/oxidized/source/csv.rb @@ -21,9 +21,9 @@ class CSV < Source def load nodes = [] file = File.expand_path(@cfg.file) - file = if @cfg.gpg? + if @cfg.gpg? crypto = GPGME::Crypto.new password: @cfg.gpg_password - crypto.decrypt(file).to_s + file = crypto.decrypt(File.open(file)).to_s else open(file) end |