Alexandre Macabies avatar Alexandre Macabies committed 9a90034 Merge

Merge branch 'master' of bitbucket.org:Zopieux/sadm

Comments (0)

Files changed (6)

docs/source/setup.rst

 udbsync
 ~~~~~~~
 
-TODO
+Again, use the ``install.py`` recipe::
+
+  python install.py udbsync
+  systemctl enable udbsync && systemctl start udbsync
+  systemctl reload nginx
+
+We can then configure udbsync clients::
+
+  python install.py udbsync_django udbsync_rootssh
+  systemctl enable udbsync_django@mdb && systemctl start udbsync_django@mdb
+  systemctl enable udbsync_django@udb && systemctl start udbsync_django@udb
+  systemctl enable udbsync_rootssh && systemctl start udbsync_rootssh
+
+presencesync
+~~~~~~~~~~~~
+
+And once again::
+
+  python install.py presencesync
+  systemctl enable presencesync && systemctl start presencesync
 
 Step 2: file storage
 --------------------
 # It's better to have a consistent user<->uid mapping. We keep it here.
 USERS = {
     'mdb': { 'uid': 20000, 'groups': ('mdb', 'mdb_public', 'mdbsync',
-                                      'mdbsync_public') },
+                                      'mdbsync_public', 'udbsync_public') },
     'mdbsync': { 'uid': 20010, 'groups': ('mdbsync', 'mdbsync_public',
                                           'mdb_public') },
     'netboot': { 'uid': 20020, 'groups': ('netboot', 'mdb_public') },
     install_systemd_unit('mdb')
 
     install_cfg_profile('mdb-server', group='mdb')
+    install_cfg_profile('mdb-udbsync', group='mdb')
 
     if first_time:
         django_syncdb('mdb')
     install_systemd_unit('udb')
 
     install_cfg_profile('udb-server', group='udb')
+    install_cfg_profile('udb-udbsync', group='udb')
 
     if first_time:
         django_syncdb('udb')
     install_systemd_unit('udbsync')
 
 
+def install_udbsync_django():
+    requires('libprologin')
+
+    install_service_dir('udbsync_django', owner='root:root', mode=0o755)
+    install_systemd_unit('udbsync_django@')
+
+
 def install_udbsync_passwd():
     requires('libprologin')
+
     mkdir('/var/prologin/udbsync_passwd', mode=0o700, owner='root:root')
     copy(
         'udbsync_passwd/udbsync_passwd.py',
     install_systemd_unit('udbsync_passwd')
 
 
+def install_udbsync_rootssh():
+    requires('libprologin')
+
+    install_service_dir('ssh', owner='root:root', mode=0o700)
+    install_systemd_unit('udbsync_rootssh')
+
+
 def install_presencesync():
     requires('libprologin')
     requires('nginxcfg')
     'mdbdhcp',
     'udb',
     'udbsync',
+    'udbsync_django',
     'udbsync_passwd',
+    'udbsync_rootssh',
     'webservices',
     'netboot',
     'presencesync',

ssh/udbsync_rootssh.py

 def callback(users, updates_metadata):
     os.makedirs('/root/.ssh/', mode=0o700, exist_ok=True)
     with open('/root/.ssh/authorized_keys', 'w') as f:
-        l = [u['ssh_key'] for u in users.values() if u['utype'] == 'root']
+        l = [u['ssh_key'] for u in users.values() if u['group'] == 'root']
+        l = [k for k in l if k] + ['']
         f.write('\n'.join(l))
 
 c = prologin.udbsync.connect()

systemd/udbsync_django@.service

 Type=simple
 User=%i
 WorkingDirectory=/var/prologin/%i
-ExecStart=/var/prologin/venv/bin/python /var/prologin/udbsync_django/udbsync_django.py
+ExecStart=/var/prologin/venv/bin/python /var/prologin/udbsync_django/udbsync_django.py %i
 
 [Install]
 WantedBy=multi-user.target

systemd/udbsync_passwd.service

 [Unit]
 Description = /etc/{passwd,shadow,group} synchronisation daemon
-After = udbsync.service
+After = network.service
 
 [Service]
 Type=simple

systemd/udbsync_rootssh.service

+[Unit]
+Description = .ssh/authorized_keys synchronisation daemon
+After = network.service
+
+[Service]
+Type=simple
+User=root
+WorkingDirectory=/var/prologin/ssh
+ExecStart=/var/prologin/venv/bin/python udbsync_rootssh.py
+
+[Install]
+WantedBy=multi-user.target
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.