GIT

From www.deloptes.org
Jump to navigation Jump to search

GIT

Create Master GIT Repository

On the GIT master repository:

1. Create directory

  mkdir -p /opt/gitbase

2. Initialize (--bare means ignore it is empty/initial)

  git init --bare

Get GIT Repository

3. Clone the repository 3.1 GIT master is on the same host

  git clone /opt/gitbase

3.2 if on remote host via SSH

  git clone hostname01:/opt/gitbase

4. Make changes to the local copy

  cd gitbase
  vi SomeFile.txt (change save and close or copy some files here)

5. Add the new or modified file to the git tree

  git add *

6. Commit the changes

  git commit -m 'first commit'

7. Push the changes upstream

  git push -u origin master

HINT: Step 5 and 6 can be combined in one step by exec

  git commit -a

Update the local repository (example SK SALT master)

8. Pull the latest version

  git pull

9. make some changes and commit (Steps 4-7)

That's it

REVERT BACK CHANGES

git reset 4579a7fd4e

The 4579a7fd4e are the first 10digits of the commit you want to revert to

Now update your local file

git checkout -- hello.sh
git push -f -u origin master

SALT + GIT

1. create master repository somewhere

2. checkout the repository and create a directory structure

  sk/salt
  pl/salt
  ie/salt
  at/salt

etc

3. Put in the structure the salt configuration for the affiliate

 sk/salt/srv/pillar/
 sk/salt/srv/salt/

4. Commit and push the changes to the master

5. on the Salt servers checkout the branch you need

  cd /
  git clone hostname01:/opt/gitbase/sk/salt/srv

FILESRV BACKEND GIT

The fileserver backend makes the local copy (configuration obsolate)

fileserver_backend:
  - git

gitfs_provider: pygit2

gitfs_remotes:
  - file:///opt/gitbase

gitfs_root: sk/salt

This means the SALT master will look for the files in the git repository (in the above example on local fs) You can however point to the GIT master you use.

gitfs_remotes:
 - https://github.com/saltstack-formulas/salt-formula.git
gitfs_remotes:
 - git@github.com:user/repo.git
 - ssh://user@domain.tld/path/to/repo.git

https://docs.saltstack.com/en/latest/topics/tutorials/gitfs.html

You can add local repository via

fileserver_backend:
 - git
 - root