User story #3152
closedCreate a migration script to change the stored internal Rudder variables from ${xxx.yyy} to ${rudder.xxxx.yyyy}
Description
We are changing the format of our internal Rudder variables that designates others "object" in Rudder (nodes, group, policyserver) from ${xxx.yyy} to ${rudder.xxx.yyy}
Some values already exists in the LDAP tree, and need to be migrated :
- in the user defined directive, some may exists if an exerienced user used them
- in the System directive (they are mandatory there, and always exists)
- check in the system directives DN: directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration if there are values that starts with ${rudder.*}. If so, exit
- update the variables ${X} where X doesn't starts by rudder to ${rudder.X} in the DN: techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration subtree, EXCEPT in techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration
- update the variables ${X} where X doesn't starts by rudder to ${rudder.X} in the techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration
This script should hence be reentrant.
The script will actually be implemented as a Rudder web application boot-time check, i.e. a Scala function executed each time Rudder webapp is started.
Files
Updated by Matthieu CERDA almost 12 years ago
- Status changed from 8 to In progress
- % Done changed from 0 to 10
I will begin with this command, inspired by the existing cpuSpeed conversion rudder-upgrade part:
/opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL
To see if interesting variables are usable
Updated by Matthieu CERDA almost 12 years ago
Here is a usable condition test before migrating (for reentrance):
/opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL|grep '${rudder.'|wc -l
Updated by Matthieu CERDA almost 12 years ago
- % Done changed from 10 to 30
Script snippet beeing worked on right now:
# Convert old style variable format to the new one LDAP_SYSVAR_NOT_PREFIXED=$(/opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL|grep '${rudder.'|wc -l) if [ ${LDAP_SYSVAR_NOT_PREFIXED} -eq 0 ]; then VARUPDATE_TMPFILE=$(mktemp) /opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL directiveVariable > ${VARUPDATE_TMPFILE} # Here, a sed snippet to add: # changetype: modify # replace: directiveVariable # Before the big directiveVariable pack of lines sed -i 's%${%${rudder.%' ${VARUPDATE_TMPFILE} rm ${VARUPDATE_TMPFILE} echo "Some old format variables were updated"
Updated by Matthieu CERDA almost 12 years ago
- % Done changed from 30 to 50
Update:
LDAP_SYSVAR_NOT_PREFIXED=$(/opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL|grep '${rudder.'|wc -l) if [ ${LDAP_SYSVAR_NOT_PREFIXED} -eq 0 ]; then VARUPDATE_TMPFILE=$(mktemp) # sed "s%cpuSpeed: \(.*\)\..*%cpuSpeed: \1%g"| \ # Build LDIF with interesting values /opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "directiveId=common-root,activeTechniqueId=common,techniqueCategoryId=Rudder Internal,techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL directiveVariable|sed '0,/directiveVariable:/s//change type: modify\nreplace: directiveVariable\ndirectiveVariable:/' > ${VARUPDATE_TMPFILE} /opt/rudder/bin/ldapsearch -H ldap://localhost -x -w ${LDAP_PASSWORD} -D "${LDAP_USER}" -b "techniqueCategoryId=Active Techniques,ou=Rudder,cn=rudder-configuration" -LLL "(&(directiveVariable=*)(!(techniqueCategoryId=Rudder Internal)))" directiveVariable|sed '0,/directiveVariable:/s//changetype: modify\nrepl ace: directiveVariable\ndirectiveVariable:/' >> ${VARUPDATE_TMPFILE} # Edit it to match the wanted ones, and insert the whole LDIF sed -i 's/${/${rudder./' ${VARUPDATE_TMPFILE} # /opt/rudder/bin/ldapmodify -H ldap://localhost -x -w ${LDAP_PASSWORD} -D ${LDAP_USER} -f ${VARUPDATE_TMPFILE} >/dev/null 2>&1 # Clean the mess and exit the if rm ${VARUPDATE_TMPFILE} echo "Some old format variables were updated" fi
Still not functionnal, the sed is not editing all the blocks and the subtree exclusion is not working.
Updated by Matthieu CERDA almost 12 years ago
- Status changed from In progress to Discussion
- Assignee changed from Matthieu CERDA to Jonathan CLARKE
I need a another LDAP expert help here !
Updated by Matthieu CERDA almost 12 years ago
- File migration_test.sh migration_test.sh added
- Assignee changed from Jonathan CLARKE to Nicolas CHARLES
After some more thinking, it has been suggested that it might be more smart to do this in scala (in the webapp). I'll attach the current work to this ticket, and reassign it to someone more competent in this domain ! :)
Updated by François ARMAND almost 12 years ago
- Assignee changed from Nicolas CHARLES to François ARMAND
Updated by François ARMAND almost 12 years ago
- Status changed from Discussion to Pending technical review
Done, Pull Request here: https://github.com/Normation/rudder/pull/93
Updated by François ARMAND almost 12 years ago
- Tracker changed from 6 to Enhancement
- Description updated (diff)
Updated by François ARMAND almost 12 years ago
- Assignee changed from François ARMAND to Nicolas CHARLES
Updated by François ARMAND almost 12 years ago
- Status changed from Pending technical review to Pending release
- % Done changed from 50 to 100
Applied in changeset dd013bbe1384a13e3d1e0070553e2272e64f96c8.
Updated by Nicolas CHARLES almost 12 years ago
Applied in changeset 509aded5305d2a2e6a33600be3fb3a22ffc54db5.
Updated by Jonathan CLARKE almost 12 years ago
- Project changed from Rudder to 34
- Category deleted (
11) - Parent task deleted (
#3137)
Updated by François ARMAND over 11 years ago
- Status changed from Pending release to Released
Updated by Benoît PECCATTE almost 10 years ago
- Project changed from 34 to Rudder
- Category set to Packaging
Updated by Benoît PECCATTE over 9 years ago
- Tracker changed from Enhancement to User story