As a Sales Engineer, I hear about large scale Microsoft Windows-centric environments all the time. Many of these teams use Microsoft Team Foundation Server (TFS) for their source control. There is a hosted version of TFS called Microsoft Visual Studio Team Services (VSTS) that is a great alternative to Github or Gitlab. Luckily, Puppet Enterprise (PE) will work with either.
While these tools operate just like Github & Gitlab, their user interface can seem a little unfamiliar. The following is a guide for setting VSTS with an existing Puppet Control repo, and then connecting it to freshly installed Puppet Enterprise that doesn't have Code Manager configured. While the guide is explictly for VSTS the steps should be very similar in TFS.
- Create a free account on visualstudio.com.
- Create a New project.
- For Version Control choose 'git'.
- Select "Import a repository" on the dashboard.
- Enter
https://github.com/puppetlabs/control-repo
. Leave "Requires Authorization" turned off.
- (Optional) Click Clone in the upper right corner and select "Create Git Credentials". Create an username and password. These credentials will be used if you choose HTTPS authentication in PE below.
The easiest way to set up Code Manager is via the verbosely named "pe_code_manager_easy_setup" task. It automates all the steps required to connect your VSTS repo with PE.
-
From the command line, run the following command as a root user:
https://gist.github.com/7f5dfd537dcc54331b2bc482180c786b -
Open the Tasks view and select the 'pe_code_manager_easy_setup'task. The task has 1 parameter: "r10k_remote_url". You have 2 options for this parameter. 2a. If you specify the HTTPS url you will need to put the username and password in the URL from step 6 above (ex. https://username:password@abirpuppet.visualstudio.com/MyFirstProject/_git/control-repo). 2b. Alternatively, you can use the ssh url (ssh://abirpuppet@vs-ssh.visualstudio.com:22/MyFirstProject/_ssh/control-repo).
-
Run the task on the master node. It can take 3-5 minutes to complete. If the task is successful, you will see output like the following:
-
If you chose 2b. above, there's one last step. In VSTS, click Clone in the upper right corner and select the SSH tab.
Then click on the "Manage SSH keys". Click Add, and then put "code manager" for Description, and copy and past the Public SSH Key shown in the above output (ssh-rsa...
) to the Key Data.
You should all set up now!
Finally to test if things work you need to do a manual code deploy. Before doing the code deploy you will need to log into the PE master as the root user and create an "access token". To do so, you must execute the following from the command line:
puppet access login --lifetime <timeframe>
<timeframe> is the length of time you want the token to last. For example "1y" would make the token valid for a year. It will then ask you for your PE console username and password.
Now you're ready! You can this one of 2 ways: from the terminal or the PE console...
Execute the following from the command line:
puppet code deploy <environment> --wait
<environment> is the Puppet environment you want to deploy. The --wait parameter tells the command to return after the deploy has completed (instead of right away).
Execute the following from the command line:
puppet module install tspy-code_deploy
Then open the Tasks view in the PE Console and select the 'code_deploy'task. The task has 1 parameter: "production". Run the task on the master node. It can take a minute to complete. If the task is successful, you will see output like the following:
Congratulations! You've set up your PE instance. If you're having issues, check out [Troubleshooting Code Manager] in the Puppet Documentation.(https://puppet.com/docs/pe/2017.3/code_management/code_mgr_troubleshoot.html).