<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>InfrastructureAsCode Archives - VirtJunkie</title>
	<atom:link href="/category/automation/infrastructureascode/feed/" rel="self" type="application/rss+xml" />
	<link>/category/automation/infrastructureascode/</link>
	<description>Virtualization, Automation, and anything else that might be on my mind</description>
	<lastBuildDate>Tue, 27 Jul 2021 12:53:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.5</generator>

<image>
	<url>/wp-content/uploads/2020/04/cropped-vj4-150x150.png</url>
	<title>InfrastructureAsCode Archives - VirtJunkie</title>
	<link>/category/automation/infrastructureascode/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Configure vROps To Send Alerts to OpsGenie and Microsoft Teams</title>
		<link>/2021/07/23/vrops-opsgenie-production-setup/</link>
					<comments>/2021/07/23/vrops-opsgenie-production-setup/#comments</comments>
		
		<dc:creator><![CDATA[Jon]]></dc:creator>
		<pubDate>Fri, 23 Jul 2021 18:35:59 +0000</pubDate>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Hashicorp]]></category>
		<category><![CDATA[InfrastructureAsCode]]></category>
		<category><![CDATA[Packer]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[vExpert]]></category>
		<category><![CDATA[VMware]]></category>
		<guid isPermaLink="false">https://www.virtjunkie.com/?p=1431</guid>

					<description><![CDATA[<p>Packer, Photon, Python, Flask, WSGI, vROps. Holy smokes folks.. I&#8217;m not sure I could make a more click-bait-y post if I tried! I recently took a position at a new company and had the opportunity to stand up a greenfield environment. Part of this environment was obviously configuring monitoring. Since we&#8217;re pretty heavily tied to [&#8230;]</p>
<p>The post <a href="/2021/07/23/vrops-opsgenie-production-setup/">Configure vROps To Send Alerts to OpsGenie and Microsoft Teams</a> appeared first on <a href="/">VirtJunkie</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Packer, Photon, Python, Flask, WSGI, vROps. Holy smokes folks.. I&#8217;m not sure I could make a more click-bait-y post if I tried!</p>



<p>I recently took a position at a new company and had the opportunity to stand up a greenfield environment. Part of this environment was obviously configuring monitoring. Since we&#8217;re pretty heavily tied to VMware here, we&#8217;re using vROps for our monitoring. For escalation of alerts, we&#8217;re using OpsGenie, and for normal collaboration we&#8217;re using Teams. Unfortunately, vROps versions older than 8.4 do not support sending alerts to OpsGenie or Teams out of the box. Fortunately, we can still get this working with a bit of work.</p>



<span id="more-1431"></span>



<h2 class="wp-block-heading">Overview</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="has-black-color has-pale-cyan-blue-background-color has-text-color has-background">Update &#8211; Starting in vROps 8.4 you can use the webhook plugin that is delivered with vROps to accomplish this. <a href="https://docs.vmware.com/en/vRealize-Operations-Manager/8.4/com.vmware.vcom.core.doc/GUID-9314313D-1DE6-4160-AEFD-76B23AB5DAD9.html" target="_blank" rel="noreferrer noopener"><strong>LINK</strong></a></p>



<p>While vROps does have the ability to send outgoing notifications via REST API, it doesn&#8217;t have the ability to let you customize what fields are sent, or how they are formatted. Because of this limitation, <a rel="noreferrer noopener" href="https://github.com/vmw-loginsight/webhook-shims/graphs/contributors" target="_blank">some very thoughtful folks</a> created <a rel="noreferrer noopener" href="https://github.com/vmw-loginsight/webhook-shims" target="_blank">a project called webhook-shims</a>. This is essentially a Python Flask project that accepts web requests, translates them, then forwards the correctly formatted request off to whatever system you want notifications sent to.</p>



<p>This project hasn&#8217;t been updated in over 3 years, has a number of pending PR&#8217;s and Issues, so my spidey sense says it&#8217;s likely dead. So please be smart about how and where you use this, and consider the implications of running this in production. That said, from a functional standpoint, it seems to work well, and in the rest of this post I&#8217;ll go over how to set this up to run in a production fashion.</p>



<p>The list to the right are the applications that the project supports, and the bold items are what I&#8217;ll show example configuration for.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<ul><li>bigpanda</li><li>bugzilla</li><li>groove</li><li>hipchat</li><li>jenkins</li><li>jira</li><li>kafkatopic</li><li><strong>opsgenie</strong></li><li>pagerduty</li><li>pivotaltracker</li><li>pushbullet</li><li>servicenow</li><li>slack</li><li>socialcast</li><li>travisci</li><li>vrealizeorchestrator</li><li>zendesk</li><li>moogsoft</li><li><strong>msteams</strong></li></ul>
</div>
</div>



<h2 class="wp-block-heading">Approach</h2>



<p>We&#8217;ll be running this whole project using Photon OS 4.</p>



<p>While we could simply run the python script in a <a rel="noreferrer noopener" href="https://www.gnu.org/software/screen/" target="_blank">screen</a>, <a rel="noreferrer noopener" href="https://github.com/tmux/tmux/wiki" target="_blank">tmux</a>, or similar session, but there are serious limitations in doing that. Admittedly, my python isn&#8217;t as strong as some of my other scripting languages, but after a bit of digging, it became clear that things like security, performance, and monitoring are either limited or unavailable if we do this. We&#8217;ll use a WSGI server called <a rel="noreferrer noopener" href="https://gunicorn.org/" target="_blank">Gunicorn</a> to run the python script, and use systemd to create a socket and service, and finally, use Nginx to connect directly to the socket. Whew! Even just reading that after completing this entire project feels like a lot, but don&#8217;t worry. As always, I&#8217;ll explain each step in detail and give you code to create this project.</p>



<h2 class="wp-block-heading">Create Photon Packer Template</h2>



<p>If you don&#8217;t know this about me by now, I&#8217;m a huge fan of packer. As such, we&#8217;ll be using it to create a template. You can find the source code for this packer template on <a href="https://github.com/jonhowe/Virtjunkie.com/tree/master/Packer/PhotonOS4" data-type="URL" data-id="https://github.com/jonhowe/Virtjunkie.com/tree/master/Packer/PhotonOS4">my website&#8217;s github repository</a></p>



<p>To get a local copy, run the following command:</p>



<p>
			<span id="urvanov-syntax-highlighter-667f6dd591c84210641541" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-e">git </span><span class="crayon-r">clone</span><span class="crayon-h"> </span><span class="crayon-v">https</span><span class="crayon-o">:</span><span class="crayon-o">/</span><span class="crayon-o">/</span><span class="crayon-v">github</span><span class="crayon-e">.com</span><span class="crayon-o">/</span><span class="crayon-v">jonhowe</span><span class="crayon-o">/</span><span class="crayon-v">Virtjunkie</span><span class="crayon-e">.com</span><span class="crayon-e">.git</span></span></span></p>



<p>You can find all source code in the directory Virtjunkie.com/Packer/PhotonOS4.</p>



<h3 class="wp-block-heading">Create Custom ISO</h3>



<p>Unfortunately, Photon OS, even in v4, doesn&#8217;t support providing the kickstart file via CD-ROM or floppy (see <a rel="noreferrer noopener" href="https://github.com/vmware/photon/issues/1113" target="_blank">Issue#1113</a>, <a rel="noreferrer noopener" href="https://github.com/vmware/photon/issues/798" data-type="URL" data-id="https://github.com/vmware/photon/issues/798" target="_blank">Issue#798)</a>.  Unfortunately, this means that if we want (or need) to use the vsphere-iso builder, we&#8217;ll need to create an ISO with the kickstart file embedded. <a rel="noreferrer noopener" href="https://vmware.github.io/photon/docs/user-guide/working-with-kickstart/#building-an-iso-with-a-kickstart-config-file" target="_blank">I&#8217;m not going to duplicate documentation, so here&#8217;s the official documentation from VMware on how to add a kickstart file.</a></p>



<p>Instead of using the sample my_ks.cfg file provided in the ISO, use the version below.</p>



<p class="has-black-color has-luminous-vivid-amber-background-color has-text-color has-background">IMPORTANT: Ensure that you replace [yourpassword] with your actual password</p>



<script src="https://gist.github.com/jonhowe/7da290c7cfd660ddb220c96349d0f024.js"></script>



<h3 class="wp-block-heading">Use Packer To Create vSphere Template</h3>



<p class="has-luminous-vivid-amber-background-color has-background">IMPORTANT: Ensure that the password assigned to &#8220;root_password&#8221; in Virtjunkie.com/Packer/PhotonOS4/packer-photon.json.pkr.hcl matches what is set in the kickstart file above</p>



<pre class="urvanov-syntax-highlighter-plain-tag">packer build -var-file=nable.auto.pkrvars.hcl -var-file=vars iso-local-4.0GA.json -only=vsphere-iso.vmware-template packer-photon.json.pkr.hcl</pre>



<h2 class="wp-block-heading">Deploy Photon 4 VM</h2>



<p>For production systems, I typically use Terraform to deploy my VMs, and that&#8217;s what I did. I&#8217;m not going to go over that, as I&#8217;ve done it before. If nothing else, just deploy the VM from a template, assign it a static IP in the guest customization specification, and then log in using credentials set in the kickstart file.</p>



<h2 class="wp-block-heading">Configure Server</h2>



<h3 class="wp-block-heading">Install Packages</h3>



<p>Execute the commands below to install required packages, and to clone the repository</p>



<script src="https://gist.github.com/jonhowe/b66c9d6881db4ec00c30852d292f6102.js"></script>



<h3 class="wp-block-heading">Configure Shims</h3>



<p>There&#8217;s a bit of config we&#8217;ll need to do in order to make this production ready.</p>



<h4 class="wp-block-heading">Configure Teams</h4>



<p>A fellow VMware vExpert, Shane Moore has an excellent article. So that I don&#8217;t recreate the wheel, please <a rel="noreferrer noopener" href="https://www.virtuallyshane.com/posts/how-to-send-vrealize-operations-alerts-into-microsoft-teams" target="_blank">see his instructions</a> for how to prep your environment to use Microsoft Teams.</p>



<p>In short, you&#8217;ll create a webhook connector in the Microsoft Teams channel, and plug the URL that you get from Teams into the teams shim file.</p>



<h4 class="wp-block-heading">Configure OpsGenie</h4>



<p>OpsGenie is pretty simple. All we&#8217;ll need to do is create an integration by selecting your team in Opsgenie, navigating to Integrations, then selecting Add Integration.</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-1024x138.png"><img fetchpriority="high" decoding="async" width="1024" height="138" src="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-1024x138.png" alt="" data-id="1447" class="wp-image-1447" srcset="/wp-content/uploads/2021/07/image-1024x138.png 1024w, /wp-content/uploads/2021/07/image-300x40.png 300w, /wp-content/uploads/2021/07/image-768x104.png 768w, /wp-content/uploads/2021/07/image-1536x207.png 1536w, /wp-content/uploads/2021/07/image.png 1660w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure></li></ul></figure>



<p>In the resulting list of available integrations, select API.</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-1.png"><img decoding="async" width="229" height="189" src="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-1.png" alt="" data-id="1448" class="wp-image-1448"/></a></figure></li></ul></figure>



<p>Then note the API key (you can grab it later, it doesn&#8217;t disappear when you navigate away). We&#8217;ll use that when we configure outbound settings in vROps to use OpsGenie.</p>



<h4 class="wp-block-heading">Disable Unused Shims</h4>



<p>In my environment, I&#8217;m only going to be using Teams and OpsGenie alerts. To reduce bloat and access points that could cause me security issues, I&#8217;m disabling all shims not in use.</p>



<p>Edit the file 
			<span id="urvanov-syntax-highlighter-667f6dd591cb6128280170" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-v">loginsightwebhookdemo</span><span class="crayon-o">/</span><span class="crayon-v">webhook</span><span class="crayon-o">-</span><span class="crayon-v">shims</span><span class="crayon-o">/</span><span class="crayon-v">loginsightwebhookdemo</span><span class="crayon-o">/</span><span class="crayon-v">__init__</span><span class="crayon-sy">.</span><span class="crayon-v">py</span></span></span></p>



<script src="https://gist.github.com/jonhowe/1d6fa1a003732c7200ec1ca28e509751.js"></script>



<h4 class="wp-block-heading">Disable Welcome Page</h4>



<p>This could probably be optional, but I appreciate not having a welcome/hello world webpage open for a production service. We&#8217;ll disable it.</p>



<p><meta http-equiv="content-type" content="text/html; charset=utf-8">Edit the file 
			<span id="urvanov-syntax-highlighter-667f6dd591cbc118503325" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-v">loginsightwebhookdemo</span><span class="crayon-o">/</span><span class="crayon-v">webhook</span><span class="crayon-o">-</span><span class="crayon-v">shims</span><span class="crayon-o">/</span><span class="crayon-v">loginsightwebhookdemo</span><span class="crayon-o">/</span><span class="crayon-v">__init__</span><span class="crayon-sy">.</span><span class="crayon-v">py</span></span></span></p>



<script src="https://gist.github.com/jonhowe/872a49c369ee36ff9bee6be431572a49.js"></script>



<h2 class="wp-block-heading">Configure Systemd</h2>



<p>Create two files: 
			<span id="urvanov-syntax-highlighter-667f6dd591cbe900551509" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">systemd</span><span class="crayon-o">/</span><span class="crayon-v">system</span><span class="crayon-o">/</span><span class="crayon-v">gunicorn</span><span class="crayon-sy">.</span><span class="crayon-v">service</span></span></span> and 
			<span id="urvanov-syntax-highlighter-667f6dd591cbf723061916" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">systemd</span><span class="crayon-o">/</span><span class="crayon-v">system</span><span class="crayon-o">/</span><span class="crayon-v">gunicorn</span><span class="crayon-sy">.</span><span class="crayon-v">socket</span></span></span> and populate with the text below. </p>



<p>
			<span id="urvanov-syntax-highlighter-667f6dd591cc0955436530" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">systemd</span><span class="crayon-o">/</span><span class="crayon-v">system</span><span class="crayon-o">/</span><span class="crayon-v">gunicorn</span><span class="crayon-sy">.</span><span class="crayon-v">service</span></span></span></p>



<p>This service file ensures that Gunicorn is started the same way, and is managed by systemd. You&#8217;ll note that it <em>requires</em> gunicorn.socket, which we will create later.</p>



<script src="https://gist.github.com/jonhowe/e6b1d294dca6235f00b80c58a6f31af6.js"></script>



<p>
			<span id="urvanov-syntax-highlighter-667f6dd591cc1922435672" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">systemd</span><span class="crayon-o">/</span><span class="crayon-v">system</span><span class="crayon-o">/</span><span class="crayon-v">gunicorn</span><span class="crayon-sy">.</span><span class="crayon-v">socket</span></span></span></p>



<p>This socket file sets permissions for the socket assigned to gunicorn</p>



<script src="https://gist.github.com/jonhowe/8398a06c4395763a82faa480de19206e.js"></script>



<h2 class="wp-block-heading">Configure Nginx</h2>



<p>Replace the file 
			<span id="urvanov-syntax-highlighter-667f6dd591cc3099705894" class="urvanov-syntax-highlighter-syntax urvanov-syntax-highlighter-syntax-inline  crayon-theme-classic crayon-theme-classic-inline urvanov-syntax-highlighter-font-monaco" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important;"><span class="crayon-pre urvanov-syntax-highlighter-code" style="font-size: 12px !important; line-height: 15px !important;font-size: 12px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">nginx</span><span class="crayon-o">/</span><span class="crayon-v">nginx</span><span class="crayon-sy">.</span><span class="crayon-v">conf</span></span></span> with the contents below</p>



<p>This is telling Nginx to connect directly to the socket we&#8217;re creating with the systemd socket gunicorn.socket we created earlier.</p>



<script src="https://gist.github.com/jonhowe/78964d1cc4a32bf5e13a7369a36eaa13.js"></script>



<h2 class="wp-block-heading">Enable and Start All Services</h2>



<p>Finally, enable, and start both services, and restart Nginx</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl enable gunicorn.socket
systemctl enable gunicorn.service
systemctl restart gunicorn.socket 
systemctl restart gunicorn.service
systemctl restart nginx.service</pre></div>



<h2 class="wp-block-heading">Configure vRealize Operations Manager</h2>



<p>At this point, all we need to do is configure an outbound instance for Microsoft Teams and OpsGenie. </p>



<h3 class="wp-block-heading">Add a New Rest Notification Plugin</h3>



<h4 class="wp-block-heading">OpsGenie</h4>



<p>To do this, sign into vROps, and navigate to Administration -&gt;Management-&gt;Outbound Settings, or https://[Your_vROps_URL]/ui/index.action#/administration/outbound-alert-settings</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-2.png"><img decoding="async" width="636" height="351" src="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-2.png" alt="" data-id="1452" class="wp-image-1452" srcset="/wp-content/uploads/2021/07/image-2.png 636w, /wp-content/uploads/2021/07/image-2-300x166.png 300w" sizes="(max-width: 636px) 100vw, 636px" /></a></figure></li></ul></figure>



<p>After you select the Rest Notification Plugin, there are 3 fields required in the Add/Edit Outbound Instance box</p>



<figure class="wp-block-table"><table><tbody><tr><td>Item</td><td>Description</td><td>Example</td></tr><tr><td>Instance Name</td><td>Name of the rest notification plugin created</td><td>Opsgenie</td></tr><tr><td>URL</td><td>URL to OpsGenie shim endpoint</td><td>http://&lt;IP/ or Hostname of Photon VM&gt;/endpoint/opsgenie/&lt;api key&gt;</td></tr><tr><td>Content Type</td><td>Content Type &#8211; Unless you&#8217;re working with a SOAP API (which we aren&#8217;t), this will always be application/json</td><td></td></tr></tbody></table></figure>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-3.png"><img loading="lazy" decoding="async" width="580" height="479" src="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-3.png" alt="" data-id="1453" class="wp-image-1453" srcset="/wp-content/uploads/2021/07/image-3.png 580w, /wp-content/uploads/2021/07/image-3-300x248.png 300w" sizes="(max-width: 580px) 100vw, 580px" /></a></figure></li></ul></figure>



<p>Finally, navigate to Alerts -&gt; Configuration -&gt; Notification (https://<meta http-equiv="content-type" content="text/html; charset=utf-8">[Your_vROps_URL]/ui/index.action#/alerts/notifications) and add a new rule that targets the adapter you just created.</p>



<figure class="wp-block-gallery columns-1 is-cropped wp-block-gallery-5 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><a href="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-4.png"><img loading="lazy" decoding="async" width="883" height="486" src="https://www.virtjunkie.com/wp-content/uploads/2021/07/image-4.png" alt="" data-id="1454" class="wp-image-1454" srcset="/wp-content/uploads/2021/07/image-4.png 883w, /wp-content/uploads/2021/07/image-4-300x165.png 300w, /wp-content/uploads/2021/07/image-4-768x423.png 768w" sizes="(max-width: 883px) 100vw, 883px" /></a></figure></li></ul></figure>



<h4 class="wp-block-heading">Teams</h4>



<p>Again, I&#8217;m not in the business of recreating the wheel, <a href="https://www.virtuallyshane.com/posts/how-to-send-vrealize-operations-alerts-into-microsoft-teams" target="_blank" rel="noreferrer noopener">so check out Shane&#8217;s blog for info on how to do this</a>.</p>



<h2 class="wp-block-heading">References</h2>



<figure class="wp-block-table"><table><tbody><tr><td><a href="https://www.virtuallyshane.com/posts/how-to-send-vrealize-operations-alerts-into-microsoft-teams" target="_blank" rel="noreferrer noopener">https://www.virtuallyshane.com/posts/how-to-send-vrealize-operations-alerts-into-microsoft-teams</a></td><td>Fellow vExpert Shane Moore&#8217;s article for setting MS Teams forwarding</td></tr><tr><td><a href="https://github.com/vmw-loginsight/webhook-shims" target="_blank" rel="noreferrer noopener">https://github.com/vmw-loginsight/webhook-shims</a></td><td>Official Github site for the webhook-shims project</td></tr><tr><td><a href="https://blogs.vmware.com/management/2017/01/vrealize-webhooks-infinite-integrations.html" target="_blank" rel="noreferrer noopener">https://blogs.vmware.com/management/2017/01/vrealize-webhooks-infinite-integrations.html</a></td><td>VMware Blog article that got me started on this journey</td></tr><tr><td><a href="https://vmware.github.io/photon/docs/user-guide/working-with-kickstart/" target="_blank" rel="noreferrer noopener">https://vmware.github.io/photon/docs/user-guide/working-with-kickstart/</a></td><td>VMware Photon documentation</td></tr><tr><td><a href="https://github.com/vmware/photon/issues/1113" target="_blank" rel="noreferrer noopener">https://github.com/vmware/photon/issues/1113</a></td><td>Github Issue for presenting Kickstart file to Photon over cdrom/floppy</td></tr><tr><td><a href="https://github.com/vmware/photon/issues/798" target="_blank" rel="noreferrer noopener">https://github.com/vmware/photon/issues/798</a></td><td><meta http-equiv="content-type" content="text/html; charset=utf-8">Another Github Issue for presenting Kickstart file to Photon over cdrom/floppy</td></tr></tbody></table></figure>
<p>The post <a href="/2021/07/23/vrops-opsgenie-production-setup/">Configure vROps To Send Alerts to OpsGenie and Microsoft Teams</a> appeared first on <a href="/">VirtJunkie</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>/2021/07/23/vrops-opsgenie-production-setup/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>VMware Provisioning using Hashicorp Terraform  &#8211; Part 2</title>
		<link>/2020/07/06/vmware-provisioning-using-hashicorp-terraform-part-2/</link>
					<comments>/2020/07/06/vmware-provisioning-using-hashicorp-terraform-part-2/#respond</comments>
		
		<dc:creator><![CDATA[Jon]]></dc:creator>
		<pubDate>Mon, 06 Jul 2020 13:00:00 +0000</pubDate>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Hashicorp]]></category>
		<category><![CDATA[InfrastructureAsCode]]></category>
		<category><![CDATA[Terraform]]></category>
		<category><![CDATA[VMware]]></category>
		<guid isPermaLink="false">http://www.virtjunkie.com/?p=1334</guid>

					<description><![CDATA[<p>In the first part of this series we went over Terraform at a very high level and discussed a basic example of using it to provision a single Windows VM or a single Linux VM. While this is a helpful baseline, it doesn&#8217;t realistically help us when defining our application structure in code. For example, [&#8230;]</p>
<p>The post <a href="/2020/07/06/vmware-provisioning-using-hashicorp-terraform-part-2/">VMware Provisioning using Hashicorp Terraform  &#8211; Part 2</a> appeared first on <a href="/">VirtJunkie</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In the <a href="https://www.virtjunkie.com/vmware-provisioning-using-hashicorp-terraform/" target="_blank" rel="noreferrer noopener">first part of this series</a> we went over Terraform at a very high level and discussed a basic example of using it to provision a single Windows VM or a single Linux VM. While this is a helpful baseline, it doesn&#8217;t realistically help us when defining our application structure in code. For example, if you wanted to set up a <a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/Multitier_architecture#Three-tier_architecture" target="_blank">three tier application</a> you&#8217;ll need to have three separate instances of the project we used. At that point we&#8217;re not really gaining much efficiency over deploying a template in vCenter. In this post I&#8217;ll discuss Terraform Modules, give an example of how to store your Terraform Module in GitHub, and provide a real-life example of how to deploy a three tier application using multiple source images.</p>



<span id="more-1334"></span>



<h2 class="wp-block-heading">Introduction to Terraform Modules</h2>



<p>In Part 1 of this series I <a href="https://www.virtjunkie.com/vmware-provisioning-using-hashicorp-terraform/#main_tf" target="_blank" rel="noreferrer noopener">compared traditional programming languages to Terraform</a>. We can do the same thing with Modules. For example, with Powershell or Python, you can download a module that provides functionality and consume that functionality in your code without having to author it. The same thing happens in Terraform, and just like with other languages, you can create your own, or download one from a third party.</p>



<h3 class="wp-block-heading">Terraform Registry</h3>



<p>Thankfully, <a rel="noreferrer noopener" href="https://registry.terraform.io/" target="_blank">Hashicorp provides us with a registry</a> that we can use to find and consume Terraform Modules. At the time this post is published, the Terraform Registry contains support for <a rel="noreferrer noopener" href="https://registry.terraform.io/browse/providers" target="_blank">63 providers</a> and has <a rel="noreferrer noopener" href="https://registry.terraform.io/browse/modules" target="_blank">3454 Modules</a>. So if you are looking for specific functionality, check there first!</p>



<h2 class="wp-block-heading">Roll Your Own Module</h2>



<p>That said, you may have a need to create your own module, or if you&#8217;re like me, want to make sure you understand how modules work before you use one that someone else created.</p>



<h3 class="wp-block-heading">Best Practices</h3>



<p>First and foremost, you&#8217;ll want to take a look at the official documentation from Hashicorp on the standard module structure. It gets pretty in-depth, but I&#8217;ll hit on a few high level important items.</p>



<ul><li>Store your module in github</li><li>At the very least, make sure you split your variables and outputs into different TF files</li><li>Include an examples directory and show every variation of how to call your module. For example, if you can create a linux image or a windows image, but you need to call them differently, show an example for each.</li><li>Include a README.md file that has a description of the module, but also references your examples</li></ul>



<h3 class="wp-block-heading">Why store your module in GitHub?</h3>



<p>Aside from the wide ranging benefits of using version control, using GitHub will allow you to call a specific version of your module.</p>



<h3 class="wp-block-heading">File Structure</h3>



<p>The following files should be in your GitHub reposity. When you run <code>terraform init</code>, it will be downloaded to the .terraform directory on the machine running the project.</p>



<h4 class="wp-block-heading">main.tf</h4>



<script src="https://gist.github.com/jonhowe/7526c2316eda915116ae63248154b4cb.js"></script>



<h4 class="wp-block-heading">variables.tf</h4>



<script src="https://gist.github.com/jonhowe/5d44ecc0680f4c64447f9e7bab7b5150.js"></script>



<h4 class="wp-block-heading">output.tf</h4>



<script src="https://gist.github.com/jonhowe/81b6205c683c0a9273e29b9c62ee8a79.js"></script>



<h2 class="wp-block-heading">How to use this module?</h2>



<p>Now that we&#8217;ve created our module and have it in Github, all we need to do in order to complete our initial goal of having a three tier application is to create a single main.tf file, and call the module 3 times. Below is an example that allows us to set separate information for each of the new VMs.</p>



<script src="https://gist.github.com/jonhowe/f81432f089cb3bbc36113ce29e4f1db4.js"></script>



<h2 class="wp-block-heading">References and what&#8217;s next?</h2>



<h3 class="wp-block-heading">What&#8217;s Next?</h3>



<p>At this point we have shown how to create and <a href="https://www.virtjunkie.com/vmware-template-packer/" target="_blank" rel="noreferrer noopener">manage images using packer</a>, a <a href="https://www.virtjunkie.com/vmware-provisioning-using-hashicorp-terraform/" target="_blank" rel="noreferrer noopener">couple</a> of <a href="https://www.virtjunkie.com/vmware-provisioning-using-hashicorp-terraform-part-2/" target="_blank" rel="noreferrer noopener">parts</a> on how to use Terraform to deploy infrastructure, so all we have left is doing configuration of our newly created VMs.</p>



<ul><li>Use Ansible to configure our newly provisioned VMs</li><li>Wrap the Terraform VM Deployment process, as well as the Ansible VM configuration process together into a single process you execute once</li><li>Use Ansible to do a greenfield deployment of a vSphere environment</li></ul>



<h3 class="wp-block-heading">References</h3>



<ul><li><a rel="noreferrer noopener" href="https://www.virtjunkie.com/vmware-provisioning-using-hashicorp-terraform/" target="_blank">Part 1 &#8211; Provision VMware VMs using Terraform</a></li><li><a href="https://registry.terraform.io/">Terraform Registry</a></li><li><a rel="noreferrer noopener" href="https://www.terraform.io/docs/modules/index.html#standard-module-structure" target="_blank">Module Structure</a></li></ul>
<p>The post <a href="/2020/07/06/vmware-provisioning-using-hashicorp-terraform-part-2/">VMware Provisioning using Hashicorp Terraform  &#8211; Part 2</a> appeared first on <a href="/">VirtJunkie</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>/2020/07/06/vmware-provisioning-using-hashicorp-terraform-part-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Jitsi for Just in Time Conferencing using Terraform on Vultr with Route 53</title>
		<link>/2020/05/04/jitsi-jit-conferencing-tf-vultr-route53/</link>
					<comments>/2020/05/04/jitsi-jit-conferencing-tf-vultr-route53/#respond</comments>
		
		<dc:creator><![CDATA[Jon]]></dc:creator>
		<pubDate>Mon, 04 May 2020 13:00:00 +0000</pubDate>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[BASH]]></category>
		<category><![CDATA[Hashicorp]]></category>
		<category><![CDATA[InfrastructureAsCode]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Terraform]]></category>
		<guid isPermaLink="false">http://www.virtjunkie.com/?p=1304</guid>

					<description><![CDATA[<p>With everything going on in the world with COVID-19 and the social distancing that is happening, people are looking to connect with friends, family and co-workers via Video conferencing more than ever. Recent vulnerabilities in Zoom have made people more cognizant than ever that security needs to be considered when using these platforms no matter [&#8230;]</p>
<p>The post <a href="/2020/05/04/jitsi-jit-conferencing-tf-vultr-route53/">Jitsi for Just in Time Conferencing using Terraform on Vultr with Route 53</a> appeared first on <a href="/">VirtJunkie</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>With everything going on in the world with COVID-19 and the social distancing that is happening, people are looking to connect with friends, family and co-workers via Video conferencing more than ever. Recent vulnerabilities in Zoom have made people more cognizant than ever that security needs to be considered when using these platforms no matter what you are using them for.</p>



<p><a href="https://jitsi.org/" target="_blank" rel="noreferrer noopener">Jitsi is an open source video conferencing platform</a> that I&#8217;ve been hearing about a lot lately, and finally had a chance to look into. In this post I&#8217;ll explain how to use Terraform to provision a Jitsi instance when you need a conference and tear it down when you are done. We&#8217;ll be using Vultr and their Jitsi &#8220;application&#8221; and AWS Route 53 for DNS.</p>



<span id="more-1304"></span>



<h2 class="wp-block-heading">Why Am I Writing This Article, and What Does It Accomplish?</h2>



<p>Why am I writing this article?</p>



<ol><li>We <strong>always</strong> want to have our apps and infrastructure defined in code</li><li>We pay for traditional web conferencing software 24 hours a day, 7 days a week, regardless of if we are are using running a conference or not. Why don&#8217;t we spin up conference infrastructure <strong>when we need it, and tear it down when we don&#8217;t</strong>?</li></ol>



<p>At a high level, this project will accomplish the following:</p>



<ol><li>Provision a Vultr VPS that is pre-configured with Jitsi</li><li>Take the IP Address that Vultr assigns the VPS and use it to create an A Record in Route 53</li><li>Copy a script to your VPS that will be used to finish the Jitsi configuration</li><li>Run the script that we copied and pass a few command line arguments that are specific to our environment</li></ol>



<h2 class="wp-block-heading">Prerequisites</h2>



<p>In addition to having Terraform downloaded and installed, we&#8217;ll need the following items:</p>



<h3 class="wp-block-heading">Vultr Account + API Access</h3>



<p>Vultr is definitely my go-to for VPS&#8217;s these days. Not only because of their price/performance/feature availability ratio, but because they provide a number of pre-configured applications that are ready, or near ready for use. <a rel="noreferrer noopener" href="https://www.vultr.com/docs/one-click-jitsi" target="_blank">Jitsi is one of these applications</a>. If you do use Vultr, please do me a favor and use&nbsp;<a rel="noreferrer noopener" href="https://www.vultr.com/?ref=8531966-6G" target="_blank">this link</a>&nbsp;to sign up. I’ll get a little kickback, but you’ll get $100 USD to use on the site in your first month.</p>



<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile"><figure class="wp-block-media-text__media"><img loading="lazy" decoding="async" width="1024" height="450" src="https://www.virtjunkie.com/wp-content/uploads/2020/05/2020-05-02_19-45-1024x450.png" alt="" class="wp-image-1305" srcset="/wp-content/uploads/2020/05/2020-05-02_19-45-1024x450.png 1024w, /wp-content/uploads/2020/05/2020-05-02_19-45-300x132.png 300w, /wp-content/uploads/2020/05/2020-05-02_19-45-768x338.png 768w, /wp-content/uploads/2020/05/2020-05-02_19-45.png 1273w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><div class="wp-block-media-text__content">
<p class="has-normal-font-size">Once you have a Vultr account, you&#8217;ll need to generate and record an API key to use with Terraform. Use the steps below to generate it.</p>



<ol><li>Log into Vultr</li><li>Navigate to Settings, and then API</li><li>Generate an API key, and copy it somewhere safe, we&#8217;ll be using it later</li></ol>
</div></div>



<h3 class="wp-block-heading">AWS Account + API Access</h3>



<p>We&#8217;ll be using <a rel="noreferrer noopener" href="https://aws.amazon.com/route53/" target="_blank">AWS&#8217;s Route 53 service</a>, which is really just a fancy DNS service that&#8217;s hooked into AWS.  In order to automate Route 53 with Terraform, we&#8217;ll need to enable API access.</p>



<div class="wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile" style="grid-template-columns:auto 70%"><figure class="wp-block-media-text__media"><img loading="lazy" decoding="async" width="1024" height="400" src="https://www.virtjunkie.com/wp-content/uploads/2020/05/2020-05-02_20-13-1024x400.png" alt="" class="wp-image-1307" srcset="/wp-content/uploads/2020/05/2020-05-02_20-13-1024x400.png 1024w, /wp-content/uploads/2020/05/2020-05-02_20-13-300x117.png 300w, /wp-content/uploads/2020/05/2020-05-02_20-13-768x300.png 768w, /wp-content/uploads/2020/05/2020-05-02_20-13-1536x599.png 1536w, /wp-content/uploads/2020/05/2020-05-02_20-13-1568x612.png 1568w, /wp-content/uploads/2020/05/2020-05-02_20-13.png 1607w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><div class="wp-block-media-text__content">
<p><a rel="noreferrer noopener" href="https://console.aws.amazon.com/iam/home?#security_credential" target="_blank">Use this link to access the IAM Management page</a></p>



<ol><li>Expand the &#8220;Access Keys&#8221; blade</li><li>Select &#8220;Create New Access Key</li><li>Save the resulting file, as we&#8217;ll use the contents later</li></ol>
</div></div>



<h3 class="wp-block-heading">Domain Registrar Using Custom Nameservers</h3>



<p>In addition to the above, the domain you want to use will need to be configured to use the Route 53 Name Servers. Route 53 will provide you the nameservers when you create a zone, and you&#8217;ll simply plug those into your registrar DNS settings page. I&#8217;m not going to explain how to create a zone in Route 53, or how to configure your registrar, but if you have questions, throw them in the comments and I&#8217;ll do my best to help.</p>



<h2 class="wp-block-heading">Getting Started</h2>



<h3 class="wp-block-heading">Run This Project</h3>



<ol><li>Grab the files below, or copy them from my <a rel="noreferrer noopener" href="https://github.com/jonhowe/Virtjunkie.com/tree/master/Jitsi-JIT-Conferencing-TF-Vultr-Route53" target="_blank">Github Repository</a></li><li>Enter the directory that contains the files</li><li>At a minimum, modify the fields in the auto.tfvars file<ol><li>vultr_api_key</li></ol><ol><li>aws_access_key</li><li>aws_secret_key</li><li>domain</li><li>email</li></ol></li><li>Initialize Terraform by running <strong><code>terraform init</code></strong></li><li>Create a terraform plan by running <strong><code>terraform plan</code></strong></li><li>Apply the configuration by running <strong><code>terraform apply</code></strong></li><li>Voila! In less than 5 minutes, you&#8217;ve got a functional, secure Jitsi instance, running on a server and domain you control. Upon successful creation, you&#8217;ll see text like what we see below giving you the URL and credentials. When you are done with your conference, just run <code><strong>terraform destroy</strong></code> to stop from receiving charges on a server/service you aren&#8217;t using.</li></ol>



<pre class="urvanov-syntax-highlighter-plain-tag">null_resource.jitsi_config (remote-exec): ------------------------------
null_resource.jitsi_config (remote-exec): |                            |
null_resource.jitsi_config (remote-exec): |   JITSI SETUP COMPLETED!   |
null_resource.jitsi_config (remote-exec): |                            |
null_resource.jitsi_config (remote-exec): ------------------------------
null_resource.jitsi_config (remote-exec): JITSI URL: https://conference.yourdomain.com/

null_resource.jitsi_config (remote-exec): USERNAME: admin
null_resource.jitsi_config (remote-exec): PASSWORD: @#$asdfahgsd34579--23%4asdf</pre>



<h2 class="wp-block-heading">Code</h2>



<h3 class="wp-block-heading">Main.tf</h3>



<p>This file does all of the work.</p>



<pre class="urvanov-syntax-highlighter-plain-tag">#main.tf
#https://www.virtjunkie.com/jitsi-jit-conferencing-tf-vultr-route53/
#https://github.com/jonhowe/Virtjunkie.com/tree/master/Jitsi-JIT-Conferencing-TF-Vultr-Route53

#Conifugre the Vultr provider
provider &quot;vultr&quot; {
  api_key = var.vultr_api_key
  rate_limit = 700
  retry_limit = 3
}

#Configure the AWS Provider
provider &quot;aws&quot; {
  #profile    = &quot;default&quot;
  #shared_credentials_file = &quot;/home/jhowe/storage/btsync/folders/Sync/awscredentials/credentials&quot;
  region     = var.aws_region
  access_key = var.aws_access_key
  secret_key = var.aws_secret_key
}

#https://www.terraform.io/docs/providers/aws/d/route53_zone.html
data &quot;aws_route53_zone&quot; &quot;selected&quot; {
  name         = &quot;${var.domain}.&quot;
  private_zone = false
}

#Provision Vultr Server
resource &quot;vultr_server&quot; &quot;my_server&quot; {
    plan_id = var.vultr_plan_id
    region_id = var.vultr_region
    app_id = var.vultr_app_id
    label = &quot;${var.hostname}.${var.domain}&quot;
    tag = var.vultr_tag
    hostname = &quot;${var.hostname}.${var.domain}&quot;
    enable_ipv6 = false
    auto_backup = false
    ddos_protection = false
    notify_activate = false

    connection {
        type     = &quot;ssh&quot;
        user     = &quot;root&quot;
        
        #https://www.terraform.io/docs/providers/vultr/r/server.html#default_password
        password = self.default_password

        #https://www.terraform.io/docs/provisioners/connection.html#the-self-object
        host     = self.main_ip
    }

    provisioner &quot;local-exec&quot; {
      command = &quot;echo SSH to this server with the command: ssh root@${vultr_server.my_server.main_ip} with the password '${vultr_server.my_server.default_password}'&quot;
    }
}

#Create the Route 53 A Record
#https://www.terraform.io/docs/providers/aws/r/route53_record.html
resource &quot;aws_route53_record&quot; &quot;conference&quot; {
  zone_id = data.aws_route53_zone.selected.zone_id
  name    = &quot;${var.hostname}.${data.aws_route53_zone.selected.name}&quot;
  type    = &quot;A&quot;
  ttl     = &quot;300&quot;
  records = &amp;#91;&quot;${vultr_server.my_server.main_ip}&quot;]
}

#This null resource exists to handle configuration of the Vultr VPS after Route 53
resource &quot;null_resource&quot; &quot;jitsi_config&quot; {
    
    connection {
        type     = &quot;ssh&quot;
        user     = &quot;root&quot;
        
        #https://www.terraform.io/docs/providers/vultr/r/server.html#default_password
        password = vultr_server.my_server.default_password

        #https://www.terraform.io/docs/provisioners/connection.html#the-self-object
        host     = vultr_server.my_server.main_ip
    }

    provisioner &quot;file&quot; {
        source      = &quot;./configure_jitsi_param.sh&quot;
        destination = &quot;/root/configure_jitsi_param.sh&quot;
    }

    provisioner &quot;remote-exec&quot; {
        inline = &amp;#91;
            &quot;chmod +x /root/configure_jitsi_param.sh&quot;,
            &quot;/root/configure_jitsi_param.sh ${var.hostname}.${var.domain} ${var.email} y&quot;
        ]
    }
}</pre>



<h3 class="wp-block-heading">Variables.tf</h3>



<p>This file defines the variables that we will use in main.tf</p>



<pre class="urvanov-syntax-highlighter-plain-tag">#variables.tf
#https://www.virtjunkie.com/jitsi-jit-conferencing-tf-vultr-route53/
#https://github.com/jonhowe/Virtjunkie.com/tree/master/Jitsi-JIT-Conferencing-TF-Vultr-Route53

variable &quot;vultr_api_key&quot; {
    description = &quot;API Key Used by Vultr (https://my.vultr.com/settings/#settingsapi)&quot;
}

variable &quot;vultr_region&quot; {
    description = &quot;Vultr Region Selection (curl https://api.vultr.com/v1/regions/availability?DCID=1)&quot;
    default = 1
}

variable &quot;vultr_plan_id&quot; {
    description = &quot;Vultr Plan for the VPS to use (curl https://api.vultr.com/v1/plans/list)&quot;
    default = 202
}

variable &quot;vultr_tag&quot; {
    description = &quot;Vultr Tag to apply to the new VPS&quot;
    default = &quot;jitsi-conference&quot;
}

variable &quot;vultr_app_id&quot; {
    description = &quot;Vultr App to pre-install. This should always be '47', if jitsi is being provisioned (curl https://api.vultr.com/v1/app/list)&quot;
    default = 47
}

variable &quot;hostname&quot; {
    description = &quot;Hostname to be used&quot;
    default = &quot;conferences&quot;
}

variable &quot;email&quot; {
    description = &quot;email to be used for let's encrypt acme config&quot;
    default = &quot;john.doe@email.com&quot;
}

variable &quot;domain&quot; {
    description = &quot;domain to be used&quot;
    default = &quot;aremyj.am&quot;
}

variable &quot;aws_access_key&quot; {
    description = &quot;AWS Access Key - get it here: (https://console.aws.amazon.com/iam/home?#security_credential)&quot;
}

variable &quot;aws_secret_key&quot; {
    description = &quot;AWS Secret Key - get it here: (https://console.aws.amazon.com/iam/home?#security_credential)&quot;
}

variable &quot;aws_region&quot; {
    description = &quot;AWS Region&quot;
    default = &quot;us-east-1&quot;
}</pre>



<h3 class="wp-block-heading">[yourdomain].auto.tfvars</h3>



<p>The auto.tfvars file provides values to the variables defined in the variables.tf file. You&#8217;ll have to create this file from scratch, and terraform best practices dictate that you exclude this file from source control. Here&#8217;s an example you can use. Modify this for your environment. The name doesn&#8217;t matter, as long as it ends with auto.tfvars.</p>



<pre class="urvanov-syntax-highlighter-plain-tag">vultr_api_key = &quot;&amp;#91;fill this in]&quot;
vultr_region = 1
vultr_plan_id = 202
vultr_app_id = 47
vultr_tag = &quot;jitsi-conference&quot;
hostname = &quot;conference&quot;
email = &quot;your.email@address.org&quot;
domain = &quot;your-domain.com&quot;
aws_region = &quot;us-east-1&quot;
aws_access_key = &quot;&amp;#91;fill this in]&quot;
aws_secret_key = &quot;&amp;#91;fill this in]&quot;</pre>



<h3 class="wp-block-heading">configure_jitsi_param.sh</h3>



<p>Full disclosure, I did not create this script. Vultr created it, and provides it on your Jitsi VPS when you request it. Unfortunately, the version they provide is intended to be executed interactively, so I made a few very minor modifications to allow for us to run it with parameters.</p>



<pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
#This script was copied from /opt/vultr/configure_jitsi.sh on a Vultr VPS that has the one-click Jitsi App
#I added lines 7-9 to allow for adding parameters on the CLI and commented lines 11-13 to force the variables to be provided on the CLI
#https://www.vultr.com/docs/one-click-jitsi
#https://www.virtjunkie.com/jitsi-jit-conferencing-tf-vultr-route53/
#https://github.com/jonhowe/Virtjunkie.com/tree/master/Jitsi-JIT-Conferencing-TF-Vultr-Route53
HOSTNAME=$1
EMAIL=$2
response=$3
# User choices
#read -ep &quot;Please specify which domain you would like to use: &quot; HOSTNAME
#read -ep &quot;Please enter your email address for Let's Encrypt Registration: &quot; EMAIL
#read -r -p &quot;Would you like to enable password authorization? &amp;#91;y/N] &quot; response
case &quot;$response&quot; in
    &amp;#91;yY]&amp;#91;eE]&amp;#91;sS]|&amp;#91;yY])
        AUTH=1
        ;;
    *)
        AUTH=0
        ;;
esac


PROSODYPATH=/etc/prosody/conf.avail/${HOSTNAME}.cfg.lua
JITSIPATH=/etc/jitsi/meet/${HOSTNAME}-config.js
JICOFOPATH=/etc/jitsi/jicofo/sip-communicator.properties

# Remove and purge (Stop first and wait to avoid race condition)
purgeold() {        
        /opt/vultr/stopjitsi.sh
        sleep 5
        apt -y purge jigasi jitsi-meet jitsi-meet-web-config jitsi-meet-prosody jitsi-meet-turnserver jitsi-meet-web jicofo jitsi-videobridge2 jitsi*
}

# Reinstall
reinstalljitsi() {
        echo &quot;jitsi-videobridge2 jitsi-videobridge/jvb-hostname string ${HOSTNAME}&quot; | debconf-set-selections
        echo &quot;jitsi-meet-web-config jitsi-meet/cert-choice string Generate a new self-signed certificate (You will later get a chance to obtain a Let's encrypt certificate)&quot; | debconf-set-selections
        apt-get -y install jitsi-meet
}

# Remove nginx defaults
wipenginx() {
        rm -f /etc/nginx/sites-enabled/default
}

# Configure Lets Encrypt
configssl(){
    systemctl restart nginx
    sed -i -e 's/echo.*Enter your email and press.*/EMAIL=$1/' /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh
    sed -i -e 's/read EMAIL//'  /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh
    /usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh ${EMAIL}
}

configprosody() {
  AUHTLINE='authentication = &quot;internal_plain&quot;'
  sed -i &quot;s/authentication\ \=\ \&quot;anonymous\&quot;/${AUTHLINE}/g&quot; ${PROSODYPATH}
  cat &amp;lt;&amp;lt; EOT &gt;&gt; ${PROSODYPATH}

VirtualHost &quot;guest.${HOSTNAME}&quot;
    authentication = &quot;anonymous&quot;
    c2s_require_encryption = false

EOT
}

configjitsi() {
        sed -i &quot;s/\/\/\ anonymousdomain\:\ 'guest.example.com',/anonymousdomain\:\ 'guest.${HOSTNAME}',/g&quot; ${JITSIPATH}
}

configjicofo() {
        echo &quot;org.jitsi.jicofo.auth.URL=XMPP:${HOSTNAME}&quot; &gt;&gt; ${JICOFOPATH}
}

registeruser(){
        PASSWORD=$(&amp;lt; /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;)
        prosodyctl register admin ${HOSTNAME} ${PASSWORD}
}

restartjitsi() {
        /opt/vultr/stopjitsi.sh
        /opt/vultr/startjitsi.sh
}

completedsetup(){
    echo &quot;&quot;
    echo &quot;------------------------------&quot;
    echo &quot;|                            |&quot;
    echo &quot;|   JITSI SETUP COMPLETED!   |&quot;
    echo &quot;|                            |&quot;
    echo &quot;------------------------------&quot;
    echo &quot;JITSI URL: https://${HOSTNAME}&quot;/
    echo &quot;&quot;
}

outputUser(){
    echo &quot;USERNAME: admin&quot;
    echo &quot;PASSWORD: ${PASSWORD}&quot;
    echo &quot;&quot;
}

# Script start

purgeold
reinstalljitsi
wipenginx
configssl
if &amp;#91; &quot;$AUTH&quot; == &quot;1&quot; ]; then
    configprosody
    configjitsi
    configjicofo
    registeruser
    restartjitsi    
fi
completedsetup
if &amp;#91; &quot;$AUTH&quot; == &quot;1&quot; ]; then
    outputUser
fi</pre>



<h2 class="wp-block-heading">Summary + More Reading</h2>



<p>There you have it! With this project you can have a fully functional Jitsi instance on your own domain with end to end encryption in less than 5 minutes. When you are done, there&#8217;s no harm in deleting it so you aren&#8217;t charged.</p>



<p>Here are some references I used while creating this:</p>



<ul><li><a href="https://github.com/jonhowe/Virtjunkie.com/tree/master/Jitsi-JIT-Conferencing-TF-Vultr-Route53">https://github.com/jonhowe/Virtjunkie.com/tree/master/Jitsi-JIT-Conferencing-TF-Vultr-Route53</a></li><li><a href="https://www.vultr.com/docs/one-click-jitsi">https://www.vultr.com/docs/one-click-jitsi</a></li><li><a href="https://www.terraform.io/docs/providers/aws/d/route53_zone.html">https://www.terraform.io/docs/providers/aws/d/route53_zone.html</a></li><li><a href="https://www.terraform.io/docs/providers/aws/r/route53_record.html">https://www.terraform.io/docs/providers/aws/r/route53_record.html</a></li><li><a href="https://www.terraform.io/docs/providers/vultr/r/server.html#default_password">https://www.terraform.io/docs/providers/vultr/r/server.html#default_password</a></li><li><a href="https://www.terraform.io/docs/provisioners/connection.html#the-self-object">https://www.terraform.io/docs/provisioners/connection.html#the-self-object</a></li><li>Create Vultr API Key: <a href="https://my.vultr.com/settings/#settingsapi">https://my.vultr.com/settings/#settingsapi</a></li><li>Create AWS Access/Secret Key: <a href="https://console.aws.amazon.com/iam/home?#security_credential">https://console.aws.amazon.com/iam/home?#security_credential</a></li><li>Vultr API Reference &#8211; has examples that will get you plan, region, and app IDs. <a href="https://www.vultr.com/api/">https://www.vultr.com/api/</a></li></ul>
<p>The post <a href="/2020/05/04/jitsi-jit-conferencing-tf-vultr-route53/">Jitsi for Just in Time Conferencing using Terraform on Vultr with Route 53</a> appeared first on <a href="/">VirtJunkie</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>/2020/05/04/jitsi-jit-conferencing-tf-vultr-route53/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
