forge
parent
c3c3907b5b
commit
c6f68a5d3f
@ -0,0 +1 @@
|
||||
ansible-playbook -i hosts --private-key myprivatekey.key playbook.yml
|
||||
@ -0,0 +1,4 @@
|
||||
[defaults]
|
||||
host_key_checking = false
|
||||
inventory = hosts
|
||||
|
||||
@ -0,0 +1 @@
|
||||
gitserver ansible_host="{{ domain }}" ansible_ssh_user="{{ git_user }}" ansible_python_interpreter="/usr/bin/python3"
|
||||
@ -0,0 +1,25 @@
|
||||
- hosts: gitserver
|
||||
vars:
|
||||
domain: "forge.myforge.fr"
|
||||
git_repos: /home/git
|
||||
git_user: git
|
||||
vars_prompt:
|
||||
- name: repo_name
|
||||
prompt: "What is the name of the new repository's you need to create?"
|
||||
private: false
|
||||
|
||||
tasks:
|
||||
- name: make a bare repo named "{{ repo_name }}"
|
||||
ansible.builtin.shell: "git init --bare --shared {{ repo_name }}.git"
|
||||
args:
|
||||
chdir: "{{ git_repos }}"
|
||||
creates: "{{ repo_name }}.git"
|
||||
become_user: "{{ git_user }}"
|
||||
|
||||
- name: Change repo's group and permissions
|
||||
ansible.builtin.file:
|
||||
path: "{{ git_repos }}/{{ repo_name }}.git"
|
||||
state: directory
|
||||
group: git
|
||||
mode: '0770'
|
||||
recurse: yes
|
||||
@ -0,0 +1,30 @@
|
||||
Defder.fr git repository server
|
||||
=================================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The repo is just a bare git shared over ssh.
|
||||
|
||||
Usage
|
||||
-------
|
||||
|
||||
`git clone`
|
||||
|
||||
If you need to clone a repo::
|
||||
|
||||
git clone git@myforge.fr:{{repo_name}}.git
|
||||
|
||||
New repo
|
||||
-----------
|
||||
|
||||
If you need to make a new repository,
|
||||
|
||||
1. Install ansible (`apt install ansible-core` on ubuntu, or simply `pip install ansible`).
|
||||
|
||||
.. attention:: Ansible does not work on a windows system.
|
||||
|
||||
2. Launch the `run_playbook.sh` script::
|
||||
|
||||
gitrepo (main =) $ ./run_playbook.sh
|
||||
What is the new repository's name?: myrepo
|
||||
@ -0,0 +1,4 @@
|
||||
[defaults]
|
||||
host_key_checking = false
|
||||
inventory = hosts
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
- hosts: gitserver
|
||||
become: true
|
||||
become_method: sudo
|
||||
|
||||
roles:
|
||||
- common
|
||||
- git
|
||||
@ -0,0 +1 @@
|
||||
gitserver ansible_host=forge.myforge.fr ansible_ssh_user=root ansible_python_interpreter="/usr/bin/python3"
|
||||
@ -0,0 +1,2 @@
|
||||
#ansible-playbook gitrepo.yml
|
||||
ansible-playbook --private-key mykey.key gitrepo.yml
|
||||
@ -0,0 +1,13 @@
|
||||
git ssh repo
|
||||
==================
|
||||
|
||||
Clone a repository
|
||||
-----------------------
|
||||
|
||||
To clone a repo, do::
|
||||
|
||||
git clone git@myaddress.site:myproject.git
|
||||
|
||||
this is a shorthand for::
|
||||
|
||||
git clone ssh://git@myaddress/home/git/myproject.git
|
||||
@ -0,0 +1,2 @@
|
||||
install_date: "dim. 02 f\xE9vr. 2025 11:21:06"
|
||||
version: 1.0.0
|
||||
@ -0,0 +1,12 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: Gwen
|
||||
description: Ansible role to update, upgrade and add somme paquets
|
||||
company: defder
|
||||
license: MIT
|
||||
platforms:
|
||||
- name: Ubuntu
|
||||
galaxy_tags:
|
||||
- apt
|
||||
dependencies: []
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: Update & upgrade system
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: dist
|
||||
tags:
|
||||
- update
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name:
|
||||
- htop
|
||||
- vim
|
||||
- locales
|
||||
- python-is-python3
|
||||
- python3-pip
|
||||
- wget
|
||||
- zip
|
||||
- bzip2
|
||||
- vim-common
|
||||
- screen
|
||||
- curl
|
||||
- git
|
||||
- unzip
|
||||
state: present
|
||||
|
||||
@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2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F14UlppJlgFg3ED97Vf1AvdnYECC7V7zrwZwtQQ== selcukcemoglu@gmail.com
|
||||
@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Ensure that the git group exists
|
||||
ansible.builtin.group:
|
||||
name: "{{ git_group }}"
|
||||
state: present
|
||||
|
||||
- name: add git user
|
||||
ansible.builtin.user:
|
||||
name: "{{ git_user }}"
|
||||
home: "{{ git_homedir }}"
|
||||
create_home: yes
|
||||
shell: "/bin/bash"
|
||||
groups: "{{ git_group }}"
|
||||
append: true
|
||||
state: present
|
||||
|
||||
#- name: add authorized_key to user
|
||||
# ansible.posix.authorized_key:
|
||||
# user: git
|
||||
# state: present
|
||||
# key: "{{ lookup('file', 'files/XXX.pub') }}"
|
||||
|
||||
- name: Add authorized_key for users
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ item.user }}"
|
||||
state: present
|
||||
key: "{{ lookup('file', 'files/' + item.key) }}"
|
||||
loop: "{{ users }}"
|
||||
|
||||
#- name: create repositories directory
|
||||
# ansible.builtin.file:
|
||||
# path: "{{ git_repos }}"
|
||||
# owner: "{{ git_user }}"
|
||||
# group: "{{ git_group }}"
|
||||
# state: directory
|
||||
# mode: u=rwx,g=rwx,o=r
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
git_user: git
|
||||
git_homedir: /home/git
|
||||
git_group: git
|
||||
git_repos: /home/git
|
||||
users:
|
||||
- user: "git"
|
||||
key: "gwen.pub"
|
||||
- user: "git"
|
||||
key: "selcuk.pub"
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
TODO
|
||||
========
|
||||
|
||||
- mettre la ssh-key dans un inventory en yaml et pas dans la ligne de commande
|
||||
- sécurisation du serveur (interdire ssh root, creer un compte admin de ssh,
|
||||
ufw, port ssh 2222, ...)
|
||||
|
||||
Loading…
Reference in New Issue