RESOLVED: Oxidized and a device git repo, do I need to manually git init?

RESOLVED: short answer is ‘no. it’s all automagical’.

Pardon the simple question. I am trying to get oxidized to output to a local git repo.

 output:
    default: git
    git:
       user: oxidized
       email: [email protected]
       repo: "/home/oxidized/devices.git"

Do I need to manually do a git init and initial git commit -m ‘blahblah’ first before starting oxidized? Or does oxidized take care of this itself?

thanks,

Easiest would be to clone your repo to a local folder, and then point your oxidized config to that local folder. All the commits etc will be automated. You don’t have to worry about initial commits etc.

ok. that’s what I was hoping and expecting. Unfortunately that means I have a more involved misunderstanding.

Just for a clean slate, I deleted /home/oxidized/devices.git. Upon restarting oxidized (I’m doing it manually until everything is working) it creates the devices.git (yay!):

 [oxidized@librenms01 ~]$ cd devices.git/
 [oxidized@librenms01 devices.git]$ ls     
 config  description  HEAD  hooks  index  info  objects  refs
 [oxidized@librenms01 devices.git]$ ls -la
 total 20
 drwxrwxr-x.  6 oxidized oxidized  116 Mar 11 08:23 .
 drwx------.  7 oxidized oxidized 4096 Mar 11 09:05 ..
 -rw-rw-r--.  1 oxidized oxidized  122 Mar 11 08:22 config
 -rw-rw-r--.  1 oxidized oxidized   73 Mar 11 08:22 description
 -rw-rw-r--.  1 oxidized oxidized   23 Mar 11 08:22 HEAD
 drwxrwxr-x.  2 oxidized oxidized   27 Mar 11 08:22 hooks
 -rw-rw-r--.  1 oxidized oxidized  225 Mar 11 08:23 index
 drwxrwxr-x.  2 oxidized oxidized   21 Mar 11 08:22 info
 drwxrwxr-x. 10 oxidized oxidized   90 Mar 11 08:23 objects
 drwxrwxr-x.  4 oxidized oxidized   31 Mar 11 08:22 refs

oxidized runs. according to the logs it fetches the cisco configs (only doing two for right now). But they aren’t showing up in the devices.git

and I also get the dreaded:
[oxidized@librenms01 devices.git]$ git status
fatal: This operation must be run in a work tree

oxidized.log:

 [oxidized@librenms01 ~]$ grep git oxidized.log
 D, [2021-03-10T15:34:28.475826 #27838] DEBUG -- : node.rb: resolving node key 
 'output', with passed global value of 'git' and node value ''
 D, [2021-03-10T15:34:28.475946 #27838] DEBUG -- : node.rb: returning node key 
 'output' with value 'git'
 D, [2021-03-10T15:34:28.507443 #27838] DEBUG -- : node.rb: resolving node key 
 'output', with passed global value of 'git' and node value ''   
 D, [2021-03-10T15:34:28.507487 #27838] DEBUG -- : node.rb: returning node key 
 'output' with value 'git'
 <truncated>

I guess for good measure here’s the config:

 [oxidized@librenms01 ~]$ cat config
 ---
 username: oxidized
 model: cisco
 resolve_dns: false
 interval: 3600
 log: /home/oxidized/oxidized.log
 use_syslog: false
 debug: true
 threads: 30
 timeout: 20
 retries: 3
 prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
 rest: 0.0.0.0:8888
 next_adds_job: false
 vars:
    auth_methods: ["publickey"]
 groups:
    ciscos:
      username: oxidized
      ssh_keys: "/home/oxidized/.ssh/id_rsa"
 models: {}
 pid: "/home/oxidized/.config/oxidized/pid"
 crash:
    directory: "/home/oxidized/.config/oxidized/crashes"
    hostnames: false
 stats:
   history_size: 10
 input:
   default: ssh
   debug: false
   ssh:
     secure: false
   ftp:
     passive: true
   utf8_encoded: true
 output:
   default: git
   git:
     user: oxidized
     email: oxidized@cea_ems.local
     repo: "/home/oxidized/devices.git"
   file:
     directory: "/home/oxidized/cisco_configs"
 source:
   default: csv
   csv:
     file: "/home/oxidized/.config/oxidized/router.db"
     delimiter: !ruby/regexp /:/
     map:
       name: 0
       ip: 1
       model: 2
       group: 3
      gpg: false
 model_map:
   cisco: ios
    asa: asa

I confirmed that configs are being fetched by changing output to file, and configs show up there.

I’m sure this is something glaringly obvious, but I can’t see it. Thanks!

ah, ok. I think I see it now. The ‘ciscos.git’ (for example) is not the git repo itself. ciscos.git has the info but it actually has to be pushed to an upstream ‘real’ repo (in my case I’m using a local gitlab). Once in the gitlab project -then- I can see the configs.

Is this correct?

Thanks,

If you have them in git repo, it will not be blatantly obvious where they are, because they are stored in objects. You would need something like git ls-files (if I remember correctly) to show you the files. So let it pull the files, then issue that command and see what happens.

A local git repo is still a repo. So it will contain files like HEAD, refs etc. As I said, use git ls-files in the root of the directory to see all the files contained within the directory.

Got it. Thank you. Also I have it uploading to gitlab using the ‘hooks’ in config as described in the docs.

Much appreciated.

No worries! Glad it is sorted!