La idea es crear un usuario en el master y luego ejecutar un script que propague la misma configuracion a traves de los demas nodos,
import sys import subprocess # yep, this is user admin import re import os # nodes list nodes = ('brick01', 'brick02') # First get the user cuser = str(sys.argv[1]) # Get user data udata = re.search(r'(\w+):\w:(\d+):(\d+):.*:([a-z,\/]*):([a-z,\/]*)', subprocess.getoutput('grep '+cuser+' /etc/passwd')) gdata = re.search(r'(\w+):\w:(\d+):.*', subprocess.getoutput('grep \'^'+cuser+'\' /etc/group')) shadowdata = re.search(r'(\w+):(.*?):', subprocess.getoutput('grep \'^'+cuser+'\' /etc/shadow')) # añade el usuario en cada nodo for node in nodes: order = 'ssh '+node+' groupadd -g '+gdata.group(2)+' '+gdata.group(1) os.system(order) order = 'ssh '+node+' useradd -u '+udata.group(2)+' -g '+udata.group(3)+' -d '+udata.group(4)+' '+cuser os.system(order) order = 'ssh '+node+' \'echo "'+shadowdata.group(1)+':'+shadowdata.group(2)+'" | chpasswd -e\'' os.system(order)
La idea general es,
Nota: Los nodos estan harcoded en el script pero claramente pueden leerse de un archivo de sistema o asi.