Table des matières
4 billet(s) pour janvier 2026
| AWX sur K8S Kind - partage de fichier pour les blob - Execution pods | 2026/01/26 10:15 | Jean-Baptiste |
| Notes rsh rcp | 2026/01/21 18:08 | Jean-Baptiste |
| Git - Duplication d'un dépôt | 2026/01/19 10:22 | Jean-Baptiste |
| Exemple simple de conf Nagios | 2026/01/14 10:07 | Jean-Baptiste |
Notes GNU Linux compte utilisateurs - users accounts
Sous RedHat la liste des comptes et des UID utilisés par la distrib est là : /usr/share/doc/setup/uidgid
Notes gnome gconf gsettings
Voir :
- M(community.general.dconf)
- M(community.general.gconftool2)
Exemple
gsettings get org.gnome.desktop.a11y.keyboard stickykeys-enable gsettings set org.gnome.desktop.a11y.keyboard stickykeys-enable false
Autre solution
/usr/share/gdm/dconf/99-local-settings
[org/gnome/settings-daemon/plugins/power] sleep-inactive-ac-timeout=0
Pb - La commande gsettings ne fonctionne pas en en console SSH.
Voir http://askubuntu.com/questions/323776/gsettings-not-working-over-ssh
La commande gsettings ne fonctionne pas en SSH. Mais fonctionne en local dans un terminal graphique.
gsettings set org.gnome.desktop.lockdown disable-lock-screen true
Vérif
gsettings get org.gnome.desktop.lockdown disable-lock-screen
false
Cela n'a pas fonctionné. Cela est dû au fait que dbus n'est pas démarré dans le session SSH.
Solution
Préfixer votre commande par dbus-launch
dbus-launch gsettings set org.gnome.desktop.lockdown disable-lock-screen true
Notes
Dump conf
Dump
dconf dump /
Ou
gsettings list-recursively
Notes 1
Éditeur en mode texte :
- gsettings (libglib2.0-bin)
- dconf (dconf-cli)
- gconftool-2 (gconf2)
Éditeur en mode graphique :
- dconf-editor (dconf-editor)
Une partie de la conf est enregistrée ici :
~/.config/dconf/user
La preuve :
$ gsettings get org.gnome.desktop.lockdown disable-lock-screen true $ rm .config/dconf/user $ gsettings get org.gnome.desktop.lockdown disable-lock-screen false
Voir le schéma ici :
/usr/share/glib-2.0/schemas/org.gnome.desktop.lockdown.gschema.xml
Autre : dconf update
Conf
Désactiver le montage automatique des clefs USB
gsettings set org.gnome.desktop.media-handling automount false
Autres
paquet dell-super-key Disables the super key by default
/usr/share/glib-2.0/schemas/41_dell-super-key.gschema.override /usr/share/doc/dell-super-key/copyright /usr/share/doc/dell-super-key/changelog.gz
/usr/share/glib-2.0/schemas/41_dell-super-key.gschema.override
[org.compiz.unityshell] show-launcher = "" lock-screen = "<Control><Alt>l" show-desktop-key = "<Control><Alt>d" launcher-switcher-forward = "" launcher-switcher-prev = "" [org.compiz.core] maximize-window-key = "<Control><Alt>Up" unmaximize-or-minimize-window-key = "<Control><Alt>Down" [org.compiz.put] put-center-key = "<Control><Alt>KP_Begin" put-left-key = "<Control><Alt>KP_Left" put-right-key = "<Control><Alt>KP_Right" put-top-key = "<Control><Alt>KP_Up" put-bottom-key = "<Control><Alt>KP_Down" put-bottom-button = "<Control><Alt>KP_Down" put-topright-key = "<Control><Alt>KP_Prior" put-bottomleft-key = "<Control><Alt>KP_End" put-bottomright-key = "<Control><Alt>KP_Next" put-restore-key = "<Control><Alt>KP_Insert" put-pointer-key = "<Control><Alt>z" [org.compiz.expo] expo-key = "<Control><Alt>s" [org.compiz.grid] put-maximize-key = "<Control><Alt>Up" put-restore-key = "<Control><Alt>Down" left-maximize = "<Control><Alt>Left" right-maximize = "<Control><Alt>Right"
Notes Gitlab
Install via Docker
Docker
Docker-compose avec Gitlab runner :
Configuration du runner
docker run --rm -ti --name gitlab-runner --add-host gitlab.local:172.17.0.1 \ -v /srv/gitlab-runner/config:/etc/gitlab-runner \ -v /var/run/docker.sock:/var/run/docker.sock \ gitlab/gitlab-runner:alpine register
/srv/gitlab-runner/config/config.toml
concurrent = 1 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "89fa5654f698" url = "http://gitlab.local:8081/" token = "FKXKQ5Zg1KmwB9ssNVU9" executor = "docker" [runners.custom_build_dir] [runners.cache] [runners.cache.s3] [runners.cache.gcs] [runners.cache.azure] [runners.docker] tls_verify = false image = "alpine" privileged = false disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0
Gitlab créera de nouveau containers. Ils devrons etre capable de faire un git clone
Pour configurer les flux réseaux, ajoutez clone_url =
Dans notre exemple 172.18.0.1 est la passerelle par défaut des nouveaux containers crées.
/gitlab-runner/config/config.toml
[[runners]] #url = "http://gitlab.local:8081/" url = "http://gitlab.local/" clone_url = "http://172.18.0.1:8081"
docker-compose.yml
version: '3.7' services: gitlab: image: 'gitlab/gitlab-ce:latest' restart: unless-stopped hostname: 'gitlab.local' environment: GITLAB_OMNIBUS_CONFIG: | #external_url 'http://gitlab.local' # Add any other gitlab.rb configuration here, each on its own line ports: - '127.0.0.1:8081:80' - '127.0.0.1:4443:443' - '127.0.0.1:2222:22' volumes: - "/srv/gitlab/config:/etc/gitlab" - "/srv/gitlab/logs:/var/log/gitlab" - "/srv/gitlab/data:/var/opt/gitlab" networks: - gitlab-net gitlab-runner: image: gitlab/gitlab-runner:alpine restart: unless-stopped depends_on: - gitlab volumes: - /srv/gitlab-runner/config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock networks: - gitlab-net networks: gitlab-net: name: gitlab-net
srv/gitlab/config/gitlab.rb
gitlab_rails['env'] = { 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000' } gitaly['env'] = { 'LD_PRELOAD' => '/opt/gitlab/embedded/lib/libjemalloc.so', 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000', 'GITALY_COMMAND_SPAWN_MAX_PARALLEL' => '2' } gitlab_rails['gitlab_username_changing_enabled'] = true gitlab_rails['trusted_proxies'] = ["172.16.0.0/12"] gitlab_rails['omniauth_enabled'] = false puma['worker_processes'] = 0 puma['exporter_enabled'] = false sidekiq['max_concurrency'] = 10 sidekiq['metrics_enabled'] = false postgresql['shared_buffers'] = "1024MB" nginx['redirect_http_to_https'] = true nginx['listen_port'] = 80 nginx['listen_https'] = false prometheus['enable'] = false alertmanager['enable'] = false node_exporter['enable'] = false redis_exporter['enable'] = false postgres_exporter['enable'] = false pgbouncer_exporter['enable'] = false gitlab_exporter['enable'] = false grafana['enable'] = false grafana['metrics_enabled'] = false #gitaly['enable'] = false gitaly['ruby_max_rss'] = 200_000_000 # RSS threshold in bytes for triggering a gitaly-ruby restart gitaly['concurrency'] = [ { 'rpc' => "/gitaly.SmartHTTPService/PostReceivePack", 'max_per_repo' => 3 }, { 'rpc' => "/gitaly.SSHService/SSHUploadPack", 'max_per_repo' => 3 } ] gitaly['cgroups_count'] = 2 gitaly['cgroups_hierarchy_root'] = 'gitaly' gitaly['cgroups_memory_enabled'] = true gitaly['cgroups_memory_limit'] = 500000 gitaly['cgroups_cpu_enabled'] = true gitaly['cgroups_cpu_shares'] = 512
Lancement de Gitlab et de Gitlab-Runner
docker-compose -d up
docker exec -ti gitlab gitlab-ctl reconfigure docker restart gitlab
Config WebUI
User : root
Password
docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
Open registration is enabled on your instance.
Admin Area - Settings - General - Sign-up restrictions
Sign-up enabled Require admin approval for new sign-ups
Le compte admin par defaut est “root”
Edit Profile - Account
Change username ———-
admin/application_settings/general Account and limit Gravatar enabled Disable
admin/application_settings/general User OAuth applications Allow users to register any application to use GitLab as an OAuth provider Disable
admin/application_settings/general Third-party offers Do not display offers from third parties Checked
admin/application_settings/metrics_and_profiling Metrics - Prometheus Enable health and performance metrics endpoint Disable
profile Private profile Don't display activity-related personal information on your profile
Admin Area - Overview - Users
Config Runners avec Docker
Admin Area - Overview - Runners
docker-compose exec gitlab-runner gitlab-runner register
Enter the GitLab instance URL (for example, https://gitlab.com/): http://gitlab/
Enter the registration token: 2_xtsj1yw4sacbWwG46y
Enter an executor: docker, docker-ssh, ssh, docker+machine, kubernetes, custom, parallels, shell, virtualbox, docker-ssh+machine: docker Enter the default Docker image (for example, ruby:2.6): alpine
Reconfig
docker-compose exec gitlab gitlab-ctl reconfigure docker-compose exec gitlab gitlab-ctl restart
Pb
Erreur dans Gitlab Settings CI/DI - There was an error fetching the environments information.
Solution :
Settings, General, Visibility, project features, permissions in Pipelines (Build, test, and deploy your changes) select Only Project Members
Autres
Installation sur Ubuntu 16.04
https://packages.gitlab.com/gitlab/gitlab-ce/install
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash apt-get install gitlab-ce
-------------- GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url` configuration in /etc/gitlab/gitlab.rb file. Then, you can start your GitLab instance by running the following command: sudo gitlab-ctl reconfigure For a comprehensive list of configuration options please see the Omnibus GitLab readme https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md ---------------
sudo gitlab-ctl reconfigure
Optimisation
/etc/gitlab/gitlab.rb
##! **recommend value is 1/4 of total RAM, up to 14GB.** # postgresql['shared_buffers'] = "256MB" postgresql['shared_buffers'] = "4096MB"
gitlab-ctl restart postgresql
Les composants suivants seront automatiquement installés :
- nginx
- postgres
- redis
A présent connectez vous sur le port 80 et définissez un mot de passe
Notes gitlab-ci pipeline
Voir :
Voir aussi:
- Drone CI
- Woodpecker CI (fork of Drone)
- tea-runner
- Travis CI
- Abstruse CI
- Gitea Action
- Agola: CI/CD
- Metroline
- mvoCI
- Jaypore CI
- Tekton
- Argo CD (CD for Kubernetes)
Exemples
configure: stage: configure image: $BUILDER needs: - build script: - echo Starting - plop.sh when: manual
Test CI/DI
Créons un projet avec à la racine un fichier .gitlab-ci.yml
.gitlab-ci.yml
job1: stage: test script: echo 'my first job'
NOTE : stages available are :
- .pre
- build
- test
- deploy
- .post
Voir : https://docs.gitlab.com/ee/ci/yaml/README.html
Ou nous pouvons le redéfinir :
stages: build test deploy
Pour tester en local
gitlab-runner exec shell job1
Secure file
# CI_API_V4_URL='https://gitlab.acme.fr/api/v4' # CI_PROJECT_ID=58 # TOKEN_PLOP=plop curl --request GET --header "PRIVATE-TOKEN: ${TOKEN_PLOP}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/secure_files/1/download" --output key'
Skip CI
Commit message :
[ci skip] or [skip ci]
Alternatively, one can pass the ci.skip Git push option if using Git 2.10 or newer:
git push -o ci.skip
Autres
Voir
requirements.txt
Jinja2==2.11.2 j2cli-3==0.0.1 anybadge==1.7.0
Notes GIT
Voir :
Voir aussi :
Clients graphiques :
- gitg
- gitk
- qgit
- tig (console)
- git-cola
Basic
Voir :
- Oh My Git!
Git
Undo uncommited
git checkout -f
will remove any non-committed changes.
Par exemple pour annuler un pb de merge
Undo commit
IF you have NOT pushed your changes to remote
git reset HEAD~1
Check if the working copy is clean by git status
ELSE you have pushed your changes to remote
git revert --no-commit HEAD
This command will revert/remove the local commits/change and then you can push
Revert multiple commits
git log --oneline
A <-- B <-- C <-- D <-- master <-- HEAD
git revert --no-commit D git revert --no-commit C git revert --no-commit B git commit -m "the commit message for all of them"
ou
git reset --hard A git reset --soft D # (or ORIG_HEAD or @{1} [previous location of HEAD]), all of which are D git commit
ou
git revert --no-commit HEAD~3.. git revert master~3..master # Revert all commits from and including B to HEAD, inclusively git revert --no-commit B^..HEAD git commit -m 'message'
ou
git reset --hard <hash> git push -f
check before git push
#git diff --stat --cached [remote/branch] git diff --stat --cached origin/master
or
git push --dry-run
For the code diff of the files to be pushed, run:
git diff [remote repo/branch]
To see full file paths of the files that will change, run:
git diff --name-only [remote repo/branch] # Ou encore git diff --name-status [remote repo/branch] git diff --numstat [remote repo/branch]
Git workflow
Voir :
- Git-flow
Configurer son environnement
~/.bashrc
export PS1='\u@\h:\w$(__git_ps1) \$ ' export GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWSTASHSTATE=1 GIT_PS1_SHOWUNTRACKEDFILES=1 export GIT_PS1_SHOWUPSTREAM=verbose GIT_PS1_DESCRIBE_STYLE=branch
git config --global status.submoduleSummary true
Create a new repository on the command line
touch README.md git init git add README.md git commit -m "first commit" git remote add origin git@git.acme.fr:jean/docker-dokuwiki.git git push -u origin master
Push an existing repository from the command line
git remote add origin git@git.acme.fr:jean/docker-dokuwiki.git git push -u origin master
Change remote location
git remote set-url ssh://gogs@new.acme.fr/user/projet git remote set-url origin ssh://git@new.acme.fr/user/projet ssh://git@old.acme.fr/user/projet git remote set-url --push origin ssh://git@new.acme.fr/user/projet
Git grep
Search the working directory for foo()
git grep "foo()"
Branches et merge
Créer une nouvelle branche locale
# Créer la branch git branch bugfix1 # Travailler dans la branch spécifiée git checkout bugfix1
ou
git checkout -b bugfix1
Checkout a remote Git branch
$ git fetch $ git branch -v -a ... remotes/origin/dev $ git checkout dev
By using the --track parameter, you can use a remote branch as the basis for a new local branch; this will also set up a “tracking relationship” between the two:
git checkout -b new-branch --track origin/develop
git add plop git commit -m “+ plop”
Commiter la nouvelle branche / créer une branche distante
git push --set-upstream origin bugfix1
Revenir à la branche master
git checkout master
Clonner une branche spécifique
git clone -b bugfix1 https://gogs.belaris.fr/BELARIS/test01
git reflog avec date
git reflog --date=iso git reflog --pretty=short --date=iso
Merge without autocommit
git merge mabranch --no-commit --no-ff #ou git merge mabranch --squash
Merge - rebase
Voir
Merge vs Merge : https://git-flow.readthedocs.io/fr/latest/presentation.html
git pull --rebase
Ou pour configurer le rebase par défaut après un pull
git config --global pull.rebase true
Si conflits
git add plop git rebase --continue
Si trop compliqué annuler :
git rebase --abort
Annuler un merge
Jetez un oeil
git reflog --date=iso # ou git log -g
Puis
git reset --hard <commit_before_merge> # Retour au commit précedent git reset --hard HEAD~1 #Ou pour une branche git reset --hard origin/mabranch
Autre
Connaître la version du dépôt - Current version
git describe --tags
Log history
git log --oneline --graph --color --all --decorate
Autres
git push warning: push.default n'est pas défini ; sa valeur implicite a changé dans Git 2.0 de 'matching' vers 'simple'. Pour supprimer ce message et maintenir le comportement actuel après la modification de la valeur de défaut, utilisez : git config --global push.default matching Pour supprimer ce message et adopter le nouveau comportement maintenant, utilisez : git config --global push.default simple Quand push.default vaudra 'matching', git poussera les branches locales sur les branches distantes qui existent déjà avec le même nom. Depuis Git 2.0, Git utilise par défaut le comportement plus conservatif 'simple' qui ne pousse la branche courante que vers la branche distante correspondante que 'git pull' utilise pour mettre à jour la branche courante. Voir 'git help config' et chercher 'push.default' pour plus d'information. (le mode 'simple' a été introduit dans Git 1.7.11. Utilisez le mode similaire 'current' au lieu de 'simple' si vous utilisez de temps en temps d'anciennes versions de Git)
warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull: git config pull.rebase false # merge (the default strategy) git config pull.rebase true # rebase git config pull.ff only # fast-forward only You can replace "git config" with "git config --global" to set a default preference for all repositories. You can also pass --rebase, --no-rebase, or --ff-only on the command line to override the configured default per invocation.
https://www.grafikart.fr/tutoriels/checkout-revert-reset-586 https://www.youtube.com/watch?v=rP3T0Ee6pLU&feature=emb_rel_end
https://www.youtube.com/watch?v=2zAtE4hnBao&list=PLtAnN3kwIVucWlr1pyfnmw8qCNaq0tusi&index=2
https://ohshitgit.com/ https://perso.liris.cnrs.fr/pierre-antoine.champin/enseignement/intro-git/ https://rogerdudler.github.io/git-guide/index.fr.html
https://delicious-insights.com/fr/articles/bien-utiliser-git-merge-et-rebase/ git pull --rebase git rebase origin/master
postconf -e smtpd_client_restrictions='permit_mynetworks, check_client_access hash:/etc/postfix/client_checks, check_sender_access hash:/etc/postfix/sender_checks'
dontreply@mass.datingfactory.com
https://www.miximum.fr/blog/enfin-comprendre-git/ https://www.miximum.fr/blog/git-rebase/
Les branches https://git-scm.com/book/fr/v2/Les-branches-avec-Git-Les-branches-en-bref https://git-scm.com/book/fr/v2/Les-branches-avec-Git-Branches-et-fusions%C2%A0%3A-les-bases
RESET https://www.atlassian.com/fr/git/tutorials/undoing-changes https://makina-corpus.com/blog/metier/archives/git-annuler-proprement-un-commit-apres-un-push https://alexgirard.com/git-book/intermediaire/repair-reset-checkout-revert/ https://opensource.com/article/18/6/git-reset-revert-rebase-commands https://docs.gitlab.com/ee/university/training/topics/rollback_commits.html
STASH https://git-scm.com/book/fr/v2/Utilitaires-Git-Remisage-et-nettoyage
REBASE https://openclassrooms.com/fr/courses/5641721-utilisez-git-et-github-pour-vos-projets-de-developpement/6113081-modifiez-vos-branches-avec-rebase https://riptutorial.com/fr/git/example/3282/rebase-interactif https://delicious-insights.com/fr/articles/bien-utiliser-git-merge-et-rebase/
Un git pull revient à
git fetchgit merge
git add . # Idem mais en plus inclus des supression git add --all
undo git add
git reset HEAD -- plop # ou git reset -- plop # ou git rm --cached plop #Suprimer le stagging git reset
Status
git status -s
Git log pour toutes les branches locales
git reflog git log --all
Historique des modifications pour un fichier précis.
git log --oneline -p README.md
Information sur un commit précis
git show 3717
Modifier le dernier message du commit
git commit --amend
Diff de la branche avec master
git diff origin/master
Annuler proprement un commit sans altérer l'historique des commits
git revert --no-commit 55dbdf
Une alternative
git checkout <commit hash> git checkout -b new_branch_name
Autre une alternative Normalement ne marche que dans une branche. Permet de changer l'history, de squash, effacer…
git rebase -i HEAD~3
Rejouer un commit spécifique / undo git revert
git cherry-pick 55dbdf
Effacer une branche distante
git push origin --delete branchy
Plop
git checkout master git pull origin master git checkout my-branch git merge master
submodule
Voir
git clone git@acme.fr:toto/plop.git cd plop git submodule update --init --recursive # Ou git clone --recurse-submodules git@acme.fr:toto/plop.git
Mise à jour submodule
git submodule update module/ cd module git pull origin master
Si commit par erreur d'un submodule
git submodule update --force
Affichage plus explicite de la commande git status
git config --global status.submoduleSummary true
Mise à jour - faire pointer le submodule sur la branche master
git submodule foreach git pull origin master
Avec Gitlab CI Voir : https://docs.gitlab.com/ee/ci/git_submodules.html
.gitlab-ci.yml
variables: GIT_SUBMODULE_STRATEGY: recursive
Diagnostique
export GIT_TRACE=2 export GIT_CURL_VERBOSE=2 export GIT_TRACE_PERFORMANCE=2 export GIT_TRACE_PACK_ACCESS=2 export GIT_TRACE_PACKET=2 export GIT_TRACE_PACKFILE=2 export GIT_TRACE_SETUP=2 export GIT_TRACE_SHALLOW=2
Autres
Lol / Lola
git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit" git config --global alias.lola "log --graph --decorate --pretty=oneline --abbrev-commit --all"
clone --depth 1 $URL fetch --unshallow $URL
Python
Voir aussi :
- pygit2
reuirements.txt
GitPython
#! /usr/bin/python3 import os import urllib.parse from git import Repo mdp=urllib.parse.quote('P@ssw0rd!', safe='') if os.path.isdir('/tmp/clone'): repo = Repo('/tmp/clone') repo.remotes.origin.pull() else: repo = Repo.clone_from(f'https://user1:{mdp}@git.acme.local/user1/test01.git', '/tmp/clone', depth=1) repo.index.add('plop.txt') repo.index.commit('commit msg') #origin = repo.remotes[0] #origin = repo.remotes['origin'] origin = repo.remotes.origin origin.push()
Pb
pb git reset --hard ne fonctionne pas
Solution
Utiliser git checkout HEAD
#git reset --hard vars/phy-deb9-fr.var git checkout HEAD vars/phy-deb9-fr.var
Err: unknown revision or path not in the working tree.
$ git reset preseed/kvm-deb10.cfg vars/netinst-deb8-11.var fatal: ambiguous argument 'preseed/kvm-deb10.cfg': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<yourcode>...]'
Solution
git checkout HEAD -- vars/kvm-deb10.var preseed/kvm-deb10.cfg
Pb git diff et git difftool ne fonctionne pas
Solution
Utiliser l'option --cached
git difftool --cached
Ou encore
git difftool HEAD
