GIT to Configuration Item Sync Part 1
Over at BigBank my team uses many configuration items to perform various tasks on different systems. These configuration items go through many iterations during the QA/Lab phase. The problem is that our team might make a pull request to pull some new code into the QA branch to have it approved to go into CM. But then we might forget to place the code into CM. Or worse someone might place code into CM without it being reviewed and approved via a Pull Request. I created a script that goes and compares the scripts in GIT vs the scripts in CM. If a change was discovered it makes a new version of the script and then it goes and creates a new version of the script and replaces it with the version of the script that is in GIT.
Over the next few days I will be posting a new post about each function.
At a high level here’s what the code does.
- Pull down the latest code of the branch that you specify.
- Get all of the CI’s from ConfigMgr
- Check every Folder from GIT for CI info. For each folder:
- Get that specific CI from all of the Cis pulled in step 2.
- Remove script signing, and white space from discover and remediation scripts.
- Compare discovery and remediation scripts from GIT to CM.
- If any differences then update the discovery and remediation scripts in the CI’s SDMPackageXML.
- Push the code into CM.
The code is currently up on github at https://github.com/crisweber2600/ConfigMgrTools
I will be adding more comments to each function and I welcome pull requests.
Some things to note. In your configuration items repository make sure that your folder names match the names of your configuration items. Also ensure that the name of your CI Setting is Script. In a future blog post I will talk about why I did that and how you can remove that.
Last but not least. TEST THIS IN A LAB! And if/when you test this outside of a lab test it on only one CI. I have seen this script act strangely in a CAS. But if you don’t have a CAS you should be fine.
Feel free to follow me on twitter at @crisweber2600 and I look forward to your feedback.
- Created on .