Skip to content
Snippets Groups Projects
Select Git revision
  • e096a4ef509aa2641660b16a7bda714b70c56e3c
  • master default
  • clement
  • fix_requirements
  • new_signup
  • interface_admin
  • hamza
  • dev
  • test
  • melissa
  • context_sheet
  • sorties_new
  • Seon82-patch-2
  • export_bdd
  • refactor/participation-user-link
15 results

admin.py

Blame
  • cloudinit.py 626 B
    """
    Generate cloud-init configuration for the VMs.
    """
    import crypt
    cloudinit="""
    #cloud-config
    apt_upgrade: true
    ssh_pwauth: 1
    users:
    """
    with open("paps.csv", encoding="utf-8") as file:
        for line in file.readlines()[1:]:
            login = line.split(";")[0][4:]
            password = crypt.crypt(login, crypt.mksalt(crypt.METHOD_SHA256))
            cloudinit += f"""
      - name: {login}
        primary_group: {login}
        groups: users
        lock_passwd: false
        shell: /bin/bash
        sudo: ALL=(ALL) NOPASSWD:ALL
        passwd: {password}
    
            """
    with open("cloudinit.yaml", "w", encoding="utf-8") as file:
        file.write(cloudinit)