mirror of
				https://github.com/newtype256/esgi-devops.git
				synced 2025-11-04 08:20:48 +01:00 
			
		
		
		
	illustrations: mise à jour
This commit is contained in:
		
							parent
							
								
									7cbe49d362
								
							
						
					
					
						commit
						d9f313da55
					
				
					 4 changed files with 35 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -8,7 +8,7 @@ class UnixFS:
 | 
			
		|||
 | 
			
		||||
# Sans intégration
 | 
			
		||||
def test_monkeypatche(mocker):
 | 
			
		||||
    mocker.patch('os.remove')
 | 
			
		||||
    mocker.patch('os.remove') # Se renseigner sur les mocks dans les tests
 | 
			
		||||
    UnixFS.rm('contrôle complet')
 | 
			
		||||
    os.remove.assert_called_once_with('contrôle complet')
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -22,4 +22,5 @@ def test_db_with_db():
 | 
			
		|||
        UnixFS.rm(fp.name)
 | 
			
		||||
        # Exercice: assert que le fichier a été supprimé.
 | 
			
		||||
        # assert not os.access(fp.name)?
 | 
			
		||||
        # Regarder os.path aussi.
 | 
			
		||||
        # https://docs.python.org/fr/3/library/os.html
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@ def encode(input_string):
 | 
			
		|||
    count = 1
 | 
			
		||||
    prev = ''
 | 
			
		||||
    lst = []
 | 
			
		||||
 | 
			
		||||
    if not input_string:
 | 
			
		||||
        return ([], 0)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ from hypothesis import given, assume
 | 
			
		|||
from hypothesis.strategies import lists, permutations
 | 
			
		||||
from collections import Counter, defaultdict
 | 
			
		||||
 | 
			
		||||
# Wikipedia: Paradoxe de Condorcet / Scrutin de Condorcet.
 | 
			
		||||
# Ici, on va observer un paradoxe classique en théorie des votes juste en utilisant Hypothesis.
 | 
			
		||||
# Imaginez, ici que vous fabriquez un algorithme de couplage, type APB/Admissions Parallèles/Parcoursup.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,38 @@ utilisateur = "raito" # À remplacer avec root ou votre nom d'utilisateur.
 | 
			
		|||
 | 
			
		||||
c = Connection(nom_hote, user=utilisateur)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def generer_nix():
 | 
			
		||||
    squelette = """
 | 
			
		||||
    # This file is managed by Fabric, do not edit.
 | 
			
		||||
    { pkgs, ... }:
 | 
			
		||||
    {
 | 
			
		||||
        %s
 | 
			
		||||
    }
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    nix_conf = """
 | 
			
		||||
    # On se lance un petit service de courses à la maison.
 | 
			
		||||
    services.grocy = {
 | 
			
		||||
       enable = true;
 | 
			
		||||
       hostName = "votre.tld"; # Vous pouvez utiliser un DynDNS ! e.g. https://dns.he.net/
 | 
			
		||||
    };
 | 
			
		||||
    security.acme.acceptTerms = true; # On accepte les termes du contrat de Let's Encrypt.
 | 
			
		||||
    security.acme.email = "vous@mail.tld"; # Email pour les alertes de Let's Encrypt.
 | 
			
		||||
    networking.firewall.allowedTCPPorts = [ 80 443 ]; # Ports à ouvrir!
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    return squelette % nix_conf
 | 
			
		||||
 | 
			
		||||
print('[+] Regardons le nom d\'hôte')
 | 
			
		||||
c.run('hostname')
 | 
			
		||||
print('[+] Regardons les informations du noyau et de la machine')
 | 
			
		||||
c.run('uname -a')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
fabric_managed_contents = generer_nix()
 | 
			
		||||
with open("/tmp/fabric.nix", "w") as f:
 | 
			
		||||
    f.write(fabric_managed_contents)
 | 
			
		||||
c.put('/tmp/fabric.nix', '/tmp/fabric.nix')
 | 
			
		||||
c.run('sudo mv /tmp/fabric.nix /etc/nixos/fabric-managed.nix', pty=True)
 | 
			
		||||
c.run('sudo nixos-rebuild switch', pty=True)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue