Managing Changes to PDQ Deploy or Inventory with Git

Write-Host “Hello world!”

Hi there. I’m Colby Bouma, a shiny new employee at PDQ.com on the QA team. I used PDQ extensively at my previous job and I did some crazy things with it. Today I would like to share one of those crazy things with you. It’s important to know I tend to go a little over the top occasionally 😀

Have you ever wanted a detailed history of the changes you’ve made to PDQ Deploy and Inventory? You can accomplish this with the built in Export feature and your own git repository. The Export feature creates XML files which are fairly readable and work very well with git. If you follow my workflow of exporting and committing after every change you get some handy benefits:

  • Quickly find when a change was made
  • See exactly what changed
  • Keep notes on why you made a change
  • Create a sort of undo button by importing a snippet of XML

Setting Up Gitlab and Preparing Your Workstation

  1. Install and configure Gitlab.
    1. Create a virtual machine with at least 2GB RAM, 20GB HDD, and 1 CPU core. You can use your favorite Linux distro, but I chose Ubuntu 16.04 for this demo. I followed these instructions to install Gitlab.
      sudo apt-get install curl openssh-server ca-certificates postfix
      curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
      sudo apt-get install gitlab-ce
    2. Follow this guide to configure email. This is required for creating accounts in Gitlab. Once you are done, run:
      sudo gitlab-ctl reconfigure
    3. You should now be able to log into your Gitlab webpage and change the root password.
    4. Create a user account for yourself. It’s never a good idea to run as root.
      gitlab admin area
      gitlab new user
  2. Create a repository.
    gitlab new project
  3. Install Git on your workstation. The defaults are fine.
  4. Clone the repository to your workstation.
    git clone http://lnxDEMO/colby/PDQ_Settings.git

    clone git repository
    clone repository black

  5. Create the initial export. In PDQ Deploy, go to File > Preferences > Export All.
    preferences export all
    xml preferences export
  6. Commit the initial export with the comment “Initial commit”.
    git add .\Deploy_Settings.xml
    git commit -m “Initial commit”

    initial commit

  7. Push the initial commit to Gitlab.
    git push -u origin master

    git credentials
    git push black
    repository pdq settings git

Workflow for Managing Changes to PDQ Deploy or Inventory

Perform an export after making any change. If you need to make multiple changes, do them one at a time and export after each change. This makes it much easier to look through and encourages detailed notes instead of “Huh, looks like I changed some stuff”.

  1. Perform an export and save over the previous file.
    export deploy settings
    confirm replace file git
  2. Commit all changed files:
    git commit -a

    git commit
    git commit 2

  3. Press “i” to enter INSERT mode.
    git editor press i
  4. Write a comment such as “Increase ‘Backups to Keep’ to 200”. I also like to make a note of the path to the item I have changed, such as “Database –> Backups to Keep”. The first line is a brief note to summarize the commit; everything below that can be as detailed as you want. Make sure to put a blank line after the first line if you are going to write detailed notes.
    Keep 200
  5. To save and close the comment hit the ESC key, type “:x”, and hit ENTER.
    Keep 200 x
    gitcommit-a
  6. Synchronize with Gitlab:
    git push origin master

    (If you make multiple changes you can wait to do this step until you’re done.)
    git push origin
    backups to keep changes to pdq deploy

Undo Button

  1. Find the snippet of code you want to restore.
    restore code pdq deploy
  2. Copy and paste it into a text editor. In this example I had to rearrange it a little bit due to how the diff was formatted. For packages you want everything between <Package> and </Package>.
    Package code snip
  3. Save it as an XML file.
    activation status save
  4. Import it.
    import to pdq deploy
    import rebuilt package
    rebuilt package was successfully imported

4 responses

    • That is currently available. If you export a folder such as the default Packages it will create 1 XML file that contains all of the packages in that folder. That is how I manage my packages with this workflow.

  • Great! I’d love to keep track of that. No way I can remember to export the settings after each change though..
    A setting to automatically export settings every x hours together with a powershell script that commits to git would be awesome. PDQ is all about automation, not more manual work. 🙂

    • Yeah, having to do this after each change is the hardest part. I got pretty good at remembering to do it for packages, but I was terrible with collections 🙂

      I’m going to open a feature request for a CLI export command. That would open up the possibility of scheduled commits and more.

Your email address will not be published.

Your Name