Skip to content

Instantly share code, notes, and snippets.

View flaf's full-sized avatar

François Lafont flaf

View GitHub Profile
@flaf
flaf / NextCloud-LDAP-requests.md
Last active November 21, 2018 13:11
uid is not used during the LDAP search to set/update the avatar via LDAP

Here is an example of user in database:

MariaDB [owncloud]> select * from oc_ldap_user_mapping where ldap_dn like 'uid=cle-jehan,%' limit 10\G
*************************** 1. row ***************************
       ldap_dn: uid=cle-jehan,ou=personnels en,ou=ac-versailles,ou=education,o=gouv,c=fr
 owncloud_name: 8891ce57-1dd211b2-80000000-00000000
directory_uuid: 8891ce57-1dd211b2-80000000-00000000
1 row in set (0.00 sec)
@flaf
flaf / ceph-via-docker.md
Last active November 22, 2018 01:04
Problem to start OSD via the docker image ceph/daemon

To start the OSD docker:

~$ docker run -d --name=osd1 --restart unless-stopped --net=host --privileged=true \
       -v /etc/ceph:/etc/ceph -v /var/lib/ceph/:/var/lib/ceph -v /dev/:/dev/       \
       -e OSD_DEVICE=/dev/sdb ceph/daemon osd_ceph_disk 

But the start fails:

@flaf
flaf / sgdisk-error.md
Created November 22, 2018 13:28
sgdisk fails

Pourquoi le sgdisk plante en me disant que le fichier /dev/sdb n'existe pas alors que c'est pourtant le cas ?

~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.6 (stretch)
Release:	9.6
Codename:	stretch
@flaf
flaf / nfs-noboby-stored.md
Last active November 27, 2018 15:07
NFS and nobody sur la baie SAN

Le gid 551 est mappé en nobody sur les NFS :

root@stored-m:~> mount | grep ' nfs '
compellent-nas-sma.in.ac-versailles.fr:/bkp_stored on /stored2/SAUVEGARDE_IMAP type nfs (rw,user=root,noexec,nosuid,nodev,vers=4,addr=172.31.136.251,clientaddr=172.31.131.59)

root@stored-m:~> touch /tmp/foo /stored2/SAUVEGARDE_IMAP/foo
root@stored-m:~> stat --format '%n => %U(%u):%G(%g)' /tmp/foo /stored2/SAUVEGARDE_IMAP/foo | column -t
/tmp/foo                      =>  root(0):root(0)
/stored2/SAUVEGARDE_IMAP/foo  =>  root(0):root(0)
@flaf
flaf / ceph-ansible-test-with-docker.md
Created November 30, 2018 11:07
Problem with ceph-ansible => KeyError: 'mon_group_name'

I'm testing ceph-ansible to install a little Ceph cluster in a VM and I have this error:

root@bionic-vbox:~/ceph-ansible# cat /etc/ansible/hosts 
[mons]
mon

[osds]
mon
@flaf
flaf / ceph-ansible-basic-test.md
Last active December 4, 2018 11:16
Ceph-ansible basic test
~$ git branch 
  master
* origin/stable-3.2

~$ cat ../hosts 
[mons]
mon

[osds]
@flaf
flaf / rundeck-get-all-jobs.sh
Created December 7, 2018 13:02
Get all jobs in Rundeck
#!/bin/sh
URL='http://localhost:4440'
login='admin'
password='password...'
curl --cookie-jar ~/mycookie --data "j_username=$login" --data "j_password=$password" "$URL/j_security_check"
projects=$(curl --silent --cookie ~/mycookie "$URL/api/1/projects" | sed -nr 's|<name>(.*)</name>|\1|p')
@flaf
flaf / ansible-manage-or-remove-file.md
Created December 20, 2018 16:41
Ansible: good syntax to manage or remove file in function of a variable

Is there a ad hoc idiomatic syntax to do that in Ansible, ie manage the content of a file if a variable is defined or remove the file if the same variable is not defined?

Or maybe this is the good way to do that?

- name: manage the content of /tmp/foo.txt
  template:
 src: foo.txt.j2
@flaf
flaf / filter-tags.md
Last active January 10, 2019 15:58
Help me to find the pythonic way to do that...

J'ai une liste de dictionnaires l1 et chaque élément possède la clé tags dont la valeur est une liste de strings. Je cherche à filtrer ma liste via une fonction pour ne garder que les éléments qui possèdent tels ou tels tags.

Voici mon code naïf mais qui marche :

#!/usr/bin/python

def my_filter(array, tags):
@flaf
flaf / fubar-spip-cache.txt
Created January 14, 2019 14:13
fubar-spip-cache
# lsof -u www-data | grep -v '/usr/lib/' | grep -v '/lib/x86' | grep svt
php-fpm7. 4525 www-data 5r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4526 www-data 6r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4528 www-data 6r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4529 www-data 5r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versailles.fr/tmp/cache/aa/3e.cache (tete-nas-vl105-smb-vip.in.ac-versailles.fr:/spip-mutu-discip)
php-fpm7. 4535 www-data 5r REG 0,40 1288 1610902823 /web/web/shared/sites/svt.ac-versaille