ytti / oxidized

Oxidized is a network device configuration backup tool. It's a RANCID replacement!
Apache License 2.0
2.76k stars 917 forks source link

Trying to create group-based repos when not configured to? #3172

Closed ianbarrere closed 3 months ago

ianbarrere commented 4 months ago

Hello,

First of all, great software, thank you for maintaining it.

It appears that my install is trying to use group based repos though and I can't figure out why.

My config file looks like this:

---
username: <snip>
password: <snip>
resolve_dns: true
interval: 3600
use_syslog: false
debug: true
log: /home/oxidized/.config/oxidized/logs/debug
threads: 30
timeout: 20
retries: 3
prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
rest: 0.0.0.0:8888
next_adds_job: false
vars:
  auth_methods: [ "password", "keyboard-interactive" ]
  enable: <snip>
groups: {}
models: {}
pid: "/home/oxidized/.config/oxidized/pid"
crash:
  directory: "/home/oxidized/.config/oxidized/crashes"
  hostnames: false
stats:
  history_size: 10
input:
  default: ssh, telnet
  debug: true
  ssh:
    secure: false
  ftp:
    passive: true
  utf8_encoded: true
output:
  default: git
  git:
    user: oxidized
    email: oxidized@me.com
    repo: "/var/lib/oxidized/devices.git"
source:
  default: http
  debug: true
  http:
    url: https://netbox.my.env/api/dcim/devices/?format=json&limit=1000&tag=oxidized
    hosts_location: results
    scheme: https
    secure: false
    delimiter: !ruby/regexp /:/
    map:
      name: name
      model: platform.slug
      group: device_type.manufacturer.slug
    vars_map:
      enable: enable
    headers:
      Authorization: 'Token foo'
      Accept: 'application/json; indent=4'
model_map:
  f5-big-ip: tmos
  cisco-nxos: nxos
  cisco-ios-xr: iosxr
  cisco: ios

I then run oxidized using podman like podman run -v /etc/oxidized:/home/oxidized/.config/oxidized -v /var/lib/oxidized:/var/lib/oxidized -p 8888:8888/tcp -t oxidized/oxidized:latest. It seems to do things for a long time, and then eventually spits out errors like this:

/var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/output/git.rb:169:in `rescue in rescue in update': first 'failed to resolve path '/var/lib/oxidized/f5.git': No such file or directory' was raised while opening git repo, then 'failed to make directory '/var/lib/oxidized/f5.git': Permission denied' was while trying to create git repo (Oxidized::Git::GitError)
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/output/git.rb:166:in `rescue in update'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/output/git.rb:162:in `update'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/output/git.rb:60:in `store'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/worker.rb:72:in `process_success'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/worker.rb:50:in `process'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/worker.rb:16:in `block in work'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/worker.rb:16:in `each'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/worker.rb:16:in `work'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/core.rb:53:in `block in run'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/core.rb:51:in `loop'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/core.rb:51:in `run'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/core.rb:37:in `initialize'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/core.rb:4:in `new'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/core.rb:4:in `new'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/lib/oxidized/cli.rb:13:in `run'
        from /var/lib/gems/3.0.0/gems/oxidized-0.30.1/bin/oxidized:5:in `<top (required)>'
        from /usr/local/bin/oxidized:25:in `load'
        from /usr/local/bin/oxidized:25:in `<main>'

There is indeed a group called "f5", but as I understood it my config is set to use one single git repo.

Fwiw, the directory /var/lib/oxidized is mounted into the container, and already exists on the host with a repo called devices.git (I am migrating to the container-based approach and hoping to reuse the existing repo).

ianbarrere commented 3 months ago

Giving it permission to write to the directory fixed the problem, but it's indeed creating group-based repos instead of one unified one. Not as pressing an issue for me at this point since it's working, but not sure why it behaves like this.

ianbarrere commented 3 months ago

Turns out I was missing single_repo: true in the config, adding that fixed it. Still not sure why it was working before, but we can consider this closed.