Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output Git - how its working? #3275

Open
Aanistratenko1984 opened this issue Sep 19, 2024 · 1 comment
Open

Output Git - how its working? #3275

Aanistratenko1984 opened this issue Sep 19, 2024 · 1 comment

Comments

@Aanistratenko1984
Copy link

Aanistratenko1984 commented Sep 19, 2024

Hi community.

Please help me understand how the Output Git method works. I've read the manual, but couldn't find information about git push, commits, and other related operations.

It doesn't work automatically.

  • In the config:
output:
  default: git
  debug: true
  git:
    user: oxidized
    email: oxi@kinetiksoft.com 
    repo: "/root/.config/oxidized/git-repos/default.git"
  • We have 2 groups:
groups:
  dc:
    username: oxidized
    password: 
    vars:
      enable: true
  studios:
    username: oxidized
    password: 
    vars:
      enable: true
  • Oxi automatically created local directories with files:
/var/docker/oxidized/git-repos # ls
dc.git  studios.git
/var/docker/oxidized/git-repos/dc.git # ls
config  description  HEAD  hooks  index  info  objects  refs  test.txt
  • After reading configs from devices, Oxi updates files in the objects directory with names in hexadecimal:
/var/docker/oxidized/git-repos/dc.git/objects # ls
00  08  1f  2b  31  3e  43  46  53  5c  6f  7a  82  98  a4  aa  b1  b8  bf  c5  d6  d9  e5  ef  info
02  09  24  30  3a  3f  44  4d  5b  63  74  7d  96  99  a6  ac  b4  b9  c4  ce  d8  df  e9  fd  pack
  • I did a manual Git init and added a remote:
    git remote add origin git@gitlab.kinetiksoft.com:tech/oxidized-dc.git
  • Checked Git status with default branch "main":
# git status
On branch main
  • did manual push
 # git push origin main
  • see all files in remote repository
    image

Why doesn't Oxi automatically push files with the normal names of devices?
What branch Oxi use for automatically push configs ?
How does the rugged/libgit2 interface from the output section work?

@skiera6
Copy link

skiera6 commented Sep 19, 2024

I'm not directly associated with Oxidized, but I can help clarify based on what I understand:

Why doesn't Oxi automatically push files with the normal names of devices?

Oxidized uses the rugged/libgit2 interface for interacting with Git repositories, which differs from the standard Git CLI behavior. It's important to note that normal Git hooks are not executed when using this interface. If you're expecting automatic pushes to a remote repository, you'll need to set up specific hooks within Oxidized's configuration.

Here’s an example configuration that uses a hook to push changes to a remote repository:

hooks:
  push_to_remote:
    type: githubrepo
    events:
      - post_store
    remote_repo: git@example.com:User/routers.git
    publickey: "~/.ssh/oxidized-key.pub"
    privatekey: "~/.ssh/oxidized-key"

In this setup, the post_store event triggers after a device configuration is stored, pushing the changes to the specified remote repository. Make sure to add your SSH keys (oxidized-key) to your remote Git repository to allow for authentication.

What branch does Oxi use for automatically pushing configs?

By default, Oxidized uses the master or main branch, depending on the repository setup. However, this can be configured in your Git settings if needed. You can manually specify the branch you want Oxidized to use by setting up your repository and remote accordingly.

How does the rugged/libgit2 interface from the output section work?

The rugged/libgit2 interface is a library-based approach to Git, used for handling commits, branches, and pushes in Oxidized. It works at a lower level compared to the standard Git command-line interface, which is why the behavior is a bit different. For example:

File changes are automatically committed locally in the .git/objects directory.
You must configure hooks within Oxidized to push changes to a remote repo, as the traditional Git hooks don't work with rugged/libgit2.

If you're seeing device configurations stored in the objects directory but not pushed automatically, this is due to the lack of Git hooks in the rugged/libgit2 setup, which needs to be configured manually as described above.

If anything i wrote is wrong feel free to correct me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants