<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by salmaan rashid on Medium]]></title>
        <description><![CDATA[Stories by salmaan rashid on Medium]]></description>
        <link>https://medium.com/@salmaan-rashid?source=rss-b78c1a5c6205------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aCKVjGByH9I2ilqV.</url>
            <title>Stories by salmaan rashid on Medium</title>
            <link>https://medium.com/@salmaan-rashid?source=rss-b78c1a5c6205------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 20:36:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@salmaan-rashid/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[medium->hugo]]></title>
            <link>https://salmaan-rashid.medium.com/medum-hugo-cc48bae04987?source=rss-b78c1a5c6205------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc48bae04987</guid>
            <dc:creator><![CDATA[salmaan rashid]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 19:20:43 GMT</pubDate>
            <atom:updated>2021-12-23T19:23:01.203Z</atom:updated>
            <content:encoded><![CDATA[<p>over the last couple of years i’ve been posting the tech articles related to my work and interests to medium.</p><p>the articles covered stuff i felt would be useful to readers and was primarily derived from my own challenges with the technology at hand (if i found it hard and finally found a solution, why not share it?)</p><p>however, medium isn’t the best um..medium for the type of articles i write which included a lot of inline code. The formatting restrictions was just not helpful and was never to my liking. I also didn’t care much for the paywall but thats another thing…</p><p>i’ve since started using <a href="https://gohugo.io/">hugo</a> to generate the site and have migrated many of the articles over. You can find what i write here</p><p><a href="https://blog.salrashid.dev/">just sal&#39;s blog</a></p><p>(that a picture of gigi)</p><p>you should be able to subscribe to <a href="https://blog.salrashid.dev/index.xml">rss</a>…i’ll also post some select articles to <a href="https://twitter.com/nonbeiyokocho">twitter</a>.</p><p>— -</p><p>anyway, happy holidays &amp; new year.</p><p>needless to say, we’re in this together..hang in there.</p><p>-sal</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc48bae04987" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a simple Debian installer (for Opencensus)]]></title>
            <link>https://salmaan-rashid.medium.com/creating-a-simple-debian-installer-for-opencensus-88c13aedc204?source=rss-b78c1a5c6205------2</link>
            <guid isPermaLink="false">https://medium.com/p/88c13aedc204</guid>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[salmaan rashid]]></dc:creator>
            <pubDate>Wed, 06 Mar 2019 02:30:32 GMT</pubDate>
            <atom:updated>2019-03-06T16:45:40.635Z</atom:updated>
            <content:encoded><![CDATA[<p>I usually cover topics related to Google Cloud but from time to time some random tasks that took me a fair amount to figure out. In the spirt of the latter, i found myself creating my very first packaged installer for linux. It wasn’t done for any particular customer-related critical issue but because a collegue of mine asked about how to easily install OpenCensus agent on a debian system and manage its service lifecycle (and the prospect of many fine beers :). That started me down the 8+ hour path in writing a package installer and distribution site from scratch and i thought i&#39;d document a simple how-to as sort of a personal log.</p><p>Ofcourse its nothing remarkable or novel or specific to GCP but here it is. This article:</p><ul><li>creates a debian .deb installer for <a href="https://opencensus.io/agent">OpenCensus Agent</a></li><li>creates a package distribution site (i.,e apt-repository; kinda like the professionals!)</li></ul><p>The references below cover both steps i ran on my laptop to generate the .deb and on Google Cloud Platform VMs to host the deb file and another VM to consume and install it (install it via apt-get)</p><blockquote><em>Note: big disclaimer: this is the first installer i’ve written…If you plan to use this for any real applicaiton, please read the official documentation carefully…this tutorial will just help you get started.</em></blockquote><h3>References</h3><ul><li><a href="https://wiki.debian.org/DebianInstaller/Build">Debian-Installer: Building the installer yourself</a></li><li><a href="https://www.debian.org/doc/manuals/maint-guide/dreq.en.html">Required files under the debian directory</a></li><li><a href="http://blog.jonliv.es/blog/2011/04/26/creating-your-own-signed-apt-repository-and-debian-packages/">Creating your own Signed APT Repository and Debian Packages</a></li><li><a href="https://www.debian.org/doc/manuals/packaging-tutorial/packaging-tutorial.en.pdf">Debian Packaging Tutorial</a></li></ul><h3>Creating a .deb file</h3><p>So what will out installer do:</p><ul><li>package the opencensus agent. The agent is already provided as a <a href="https://github.com/census-instrumentation/opencensus-service/releases">platform binary</a> so this article does not compile from source</li><li>create user/group that the agent will run as oc-agent/oc-agent.</li><li>install the agent and cofig file under /opt/opencensus-agent/*</li><li>install and configure systemd such that you can start/stop the agent easily.</li></ul><p>Lets get started. As mentioned in the introduction, i’m running all the steps using docker. Everything: the build environment, the repository server <em>and</em> the client system that will install the .deb file.</p><p>You can find the source here:</p><p><a href="https://github.com/salrashid123/randomwalk/tree/master/debian_installer">salrashid123/randomwalk</a></p><ol><li>Setup some libraries we will need later</li></ol><pre>apt-get update<br>apt-get install debhelper dh-systemd dh-make reprepro gnupg2 vim wget nginx lsb-release -y</pre><p>2. Generate a GPG key or use the one provided here (note, the password is opencensus0!)</p><pre>gpg --import stage/certs/oc_private.key </pre><pre>  gpg: /root/.gnupg/trustdb.gpg: trustdb created<br>  gpg: key 0C74009E141D7911: public key &quot;OpenCensus (https://opencensus.io) &lt;census-developers@googlegroups.com&gt;&quot; imported<br>  gpg: key 0C74009E141D7911: secret key imported<br>  gpg: Total number processed: 1<br>  gpg:               imported: 1<br>  gpg:       secret keys read: 1<br>  gpg:   secret keys imported: 1</pre><pre>gpg --import stage/certs/oc_public.key  <br>  gpg: key 0C74009E141D7911: &quot;OpenCensus (https://opencensus.io) &lt;census-developers@googlegroups.com&gt;&quot; not changed<br>  gpg: Total number processed: 1<br>  gpg:              unchanged: 1</pre><p>(or create your own key gpg --full-generate-key)</p><ul><li>pick sign only (option 4);</li><li>Username: Opencensus</li><li>email: census-developers@googlegroups.com</li><li>pick any password</li></ul><p>Now note down the keyID. In the example below, its 141D7911</p><pre>gpg --keyid-format SHORT --list-keys<br>  pub   rsa4096/141D7911 2019-03-01 [SC]<br>        9A70363996C3EE279ABBAF2E0C74009E141D7911<br>  uid         [ unknown] OpenCensus (https://opencensus.io) &lt;census-developers@googlegroups.com&gt;</pre><p>3. Create debian installer root folder</p><p>Create the folder to house our configuration files. I’m creating opencensusagent version 0.1.2 so i named the directory exactly in that format with a hyphen (the folder structure/name convention is important).</p><pre>mkdir opencensusagent-0.1.2/<br>cd opencensusagent-0.1.2/<br>export USER=`whoami`</pre><p>4. Use dh_make to to prefill the installation files</p><p><a href="https://manpages.debian.org/jessie/dh-make/dh_make.8.en.html">dh_make</a> sets up the baseline files we will use.</p><pre>dh_make  --createorig -e census-developers@googlegroups.com -s -y</pre><p>This will create the <a href="https://www.debian.org/doc/manuals/maint-guide/dreq.en.html">Required files under the debian directory</a></p><p>5. Configure installer</p><p>The link and references above covers the various files and how to set them up. If you just want the quick+dirty, preconfigured files, you can copy the ones spcific to this installer from here:</p><pre>cp -R ../stage/debian/* debian/</pre><p>The noteworthy files that we edited are:</p><ul><li>debian/control: describes what this repo does</li><li>debian/compat</li><li>debian/files</li><li>debain/opencensusagent-install: where to copy the installer files (in our case from debian/src/opt/opencensus-agent/* to /opt/)</li><li>debian/opencensusagent.service: systemd configuration</li><li>debian/preinst: preinstallation tasks to setup the user/group, etc</li><li>debian/postinst: post installation tasks</li><li>debian/postrm: remove the user/group and directories after the package is removed</li><li>debian/rules: this is an important file: this describes that we will install systemd and any overrides to systemd or installation to apply.</li><li>debian/source/include-binaries: the target binaries we need to package up (in our case, the opencensus binary and its config file)</li></ul><p>and the actual binaries we will install (remember, we’re not compiling with this deb file!)</p><ul><li>debian/src/opt/opencensus-agent/bin/ocagent</li><li>debian/src/opt/opencensus-agent/conf/oca.yaml</li></ul><p>6. Populate the opencensus binary</p><p>THis is done because i didn’t include the agent in this git repo!</p><pre>wget <a href="https://github.com/census-instrumentation/opencensus-service/releases/download/0.1.3/ocagent_linux">https://github.com/census-instrumentation/opencensus-service/releases/download/0.1.3/ocagent_linux</a> \<br>  -O debian/src/opt/opencensus-agent/bin/ocagent</pre><p>7. Build .deb file</p><p>Now we’re finally ready to build:</p><pre>dpkg-buildpackage -kcensus-developers@googlegroups.com</pre><p>(remember, the password is opencensus01)</p><p>This will create the .deb candidate in a directory above the current (../opencensusagent_0.1.2-1_all.deb)</p><p>8. Test .deb file candidate</p><p>To test, we’ll be setting up a GCP VM (so..yeah, i’m assuming you have access; otherwise, pick a debian system somewhere)</p><pre>cd  ../<br>gcloud compute instances create oc-client1 --zone=us-central1-a<br>gcloud compute scp opencensusagent_0.1.2-1_all.deb oc-client1:/tmp/<br>gcloud compute ssh oc-client1</pre><p>9. Install deb</p><p>SSH to the VM</p><pre>gcloud compute ssh oc-client1 --zone=us-central1-a<br>sudo su -<br>cd /tmp/</pre><pre>dpkg -i opencensusagent_0.1.2-1_all.deb <br>    Selecting previously unselected package opencensusagent.<br>    (Reading database ... 34432 files and directories currently installed.)<br>    Preparing to unpack opencensusagent_0.1.2-1_all.deb ...<br>    Adding system user `ocagent&#39; (UID 108) ...<br>    Adding new group `ocagent&#39; (GID 112) ...<br>    Adding new user `ocagent&#39; (UID 108) with group `ocagent&#39; ...<br>    Not creating home directory `/home/ocagent&#39;.<br>    Unpacking opencensusagent (0.1.2-1) ...<br>    Setting up opencensusagent (0.1.2-1) ...<br>    Created symlink /etc/systemd/system/multi-user.target.wants/opencensusagent.service → /lib/systemd/system/opencensusagent.service.<br>    Processing triggers for systemd (232-25+deb9u8) ...</pre><p>10. Verify the .deb</p><pre>$ service opencensusagent start</pre><pre>$ service opencensusagent status<br>  ● opencensusagent.service - Opencensus Agent<br>    Loaded: loaded (/lib/systemd/system/opencensusagent.service; enabled; vendor preset: enabled)<br>    Active: active (running) since Wed 2019-03-06 01:30:37 UTC; 1s ago<br>  Main PID: 894 (ocagent)<br>      Tasks: 7 (limit: 4915)<br>    CGroup: /system.slice/opencensusagent.service<br>            └─894 /opt/opencensus-agent/bin/ocagent -c /opt/opencensus-agent/conf/oca.yaml</pre><pre>  Mar 06 01:30:37 oc-client1 systemd[1]: Started Opencensus Agent.<br>  Mar 06 01:30:38 oc-client1 opencensusagent[894]: 2019/03/06 01:30:38 Running OpenCensus Trace and Metrics receivers as a gRPC service at &quot;localhost:55678&quot;<br>  Mar 06 01:30:38 oc-client1 opencensusagent[894]: 2019/03/06 01:30:38 Running zPages at &quot;:55679&quot;<br></pre><pre>$ ps -ef | grep ocagent<br>    root      18473      1  0 01:01 pts/0    00:00:00 /opt/opencensus-agent/bin/ocagent -c /opt/opencensus-agent/conf/oca.yaml<br>    root      18782      1  0 01:03 pts/0    00:00:00 grep ocagent</pre><pre>$ service opencensusagent stop<br>    [ ok ] Stopping opencensusagent:.</pre><p>11. Uninstall the deb</p><pre>$ dpkg -r opencensusagent<br>$ dpkg -P opencensusagent</pre><h3>Create APT Repository</h3><p>Ok now that we’ve verified the the .deb, lets package this in to an apt-repo</p><p>Back on your local vm</p><p>12. Create a ‘docroot’ of the repo and copy the opencensus .deb files over</p><pre>mkdir repo &amp;&amp; cd repo/<br>cp ../opencensusagent_0.1.2-1_all.deb .</pre><p>13. Create a default conf/distribution file under repo</p><p>conf/distributions has the following content:</p><pre>Origin: OpenCensus (https://opencensus.io/)<br>Label: OpenCensus<br>Codename: stretch<br>Architectures: amd64<br>Components: main<br>Description: OpenCensus Package Repo<br>SignWith: 0838A470<br>Pull: stretch</pre><pre>Origin: OpenCensus (https://opencensus.io/)<br>Label: OpenCensus<br>Codename: trusty<br>Architectures: amd64<br>Components: main<br>Description: OpenCensus Package Repo<br>SignWith: 0838A470<br>Pull: trusty</pre><p>14. Generate the archive</p><pre>$ reprepro  -Vb . includedeb stretch opencensusagent_0.1.2-1_all.deb</pre><pre>  opencensusagent_0.1.2_all.deb: component guessed as &#39;main&#39;<br>  Created directory &quot;./pool&quot;<br>  Created directory &quot;./pool/main&quot;<br>  Created directory &quot;./pool/main/o&quot;<br>  Created directory &quot;./pool/main/o/opencensusagent&quot;<br>  Exporting indices...<br>  Created directory &quot;./dists&quot;<br>  Created directory &quot;./dists/stretch&quot;<br>  Created directory &quot;./dists/stretch/main&quot;<br>  Created directory &quot;./dists/stretch/main/binary-amd64&quot;<br>  Successfully created &#39;./dists/stretch/Release.gpg.new&#39;<br>  Successfully created &#39;./dists/stretch/InRelease.new&#39;</pre><blockquote><em>Actually, thats it; you’ve got the repo now all setup. We just need to setup a webserver-distribution</em></blockquote><p>Final step is remove the deb and prepare the archive so we can tranmit it to the apt repo we will just setup next</p><pre>rm opencensusagent_0.1.2-1_all.deb<br>cd ../<br>tar cvf repo.tar</pre><p>15. Setup Webserver distribution point</p><p>Now lets prepare the VM that will host the repo with a serving certificate (since we want to use https!)</p><ul><li>Create ssl cert for the https distribution</li></ul><pre>openssl req  -nodes -new -x509  -keyout server.key -out server.cert</pre><p>(since this is testing; add any CN= value you want)</p><p>16. Create VM to host the repo</p><pre>gcloud compute instances create repo --zone=us-central1-a<br>NAME  ZONE           MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUS<br>repo  us-central1-a  n1-standard-1               10.128.0.48  35.202.237.155  RUNNING</pre><blockquote><em>Note the internalIP </em><em>10.128.0.48</em></blockquote><p>17. Copy the archive and certificate</p><pre>gcloud compute scp repo.tar repo:/tmp/ --zone=us-central1-a<br>gcloud compute scp server* repo:/tmp/ --zone=us-central1-a<br>gcloud compute scp stage/certs/oc_public.key repo:/tmp/  --zone=us-central1-a</pre><p>18. Configue nginx to service https</p><pre>gcloud compute ssh repo<br>sudo su -<br>apt-get update <br>apt-get install nginx -y</pre><ul><li>Copy certs over:</li></ul><pre>cp /tmp/server.key /etc/nginx/<br>cp /tmp/server.cert /etc/nginx/</pre><ul><li>configure nginx</li></ul><pre>vi /etc/nginx/sites-enabled/default</pre><pre>server {<br>    listen              443 ssl;<br>    listen              [::]:443 ssl;<br>    server_name         example2.com www.example2.com;<br>    root                /var/www/html;</pre><pre>    ssl_certificate     /etc/nginx/server.cert;<br>    ssl_certificate_key /etc/nginx/server.key;<br>    }</pre><ul><li>copy public key and certificate to the docroot</li></ul><pre>cd /var/www/html<br>cp /tmp/oc_public.key .<br>cp /tmp/repo.tar .<br>tar xvf repo.tar </pre><pre>service nginx restart</pre><h3>End-to-End Test</h3><p>Now to test the repo from a new client!</p><p>in a new shell, create the ‘client’. We want the</p><ul><li>setup some background libraries;tools</li></ul><pre>apt-get update<br>apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common vim</pre><ul><li>Download and allow apt to trust our public key</li></ul><pre>curl -fsSLk https://10.128.0.48/oc_public.key | apt-key add -<br>  <br>OK</pre><p>Check the cert fingerprint matches</p><pre>apt-key fingerprint 141D7911<br>  pub   rsa4096 2019-03-01 [SC]<br>        9A70 3639 96C3 EE27 9ABB  AF2E 0C74 009E 141D 7911<br>  uid           [ unknown] OpenCensus (https://opencensus.io) &lt;census-developers@googlegroups.com&gt;</pre><ul><li>Install the repo</li></ul><pre>add-apt-repository &quot;deb http://10.128.0.48/repo $(lsb_release -cs) main&quot;<br>apt-get update</pre><ul><li>Install the package!</li></ul><pre>apt-get install opencensusagent</pre><ul><li>Verify</li></ul><pre>service opencensusagent start</pre><pre>service opencensusagent status<br>● opencensusagent.service - Opencensus Agent<br>   Loaded: loaded (/lib/systemd/system/opencensusagent.service; enabled; vendor preset: enabled)<br>   Active: active (running) since Wed 2019-03-06 01:52:52 UTC; 33s ago<br> Main PID: 27922 (ocagent)<br>    Tasks: 8 (limit: 4915)<br>   CGroup: /system.slice/opencensusagent.service<br>           └─27922 /opt/opencensus-agent/bin/ocagent -c /opt/opencensus-agent/conf/oca.yaml</pre><pre>Mar 06 01:52:52 oc-client1 systemd[1]: Started Opencensus Agent.<br>Mar 06 01:52:53 oc-client1 opencensusagent[27922]: 2019/03/06 01:52:53 Running OpenCensus Trace and Metrics receivers as a gRPC service at &quot;localhost:55678&quot;<br>Mar 06 01:52:53 oc-client1 opencensusagent[27922]: 2019/03/06 01:52:53 Running zPages at &quot;:55679&quot;</pre><blockquote><em>note, if you want to run the agent via commandline</em></blockquote><blockquote><em>sudo -H -u ocagent bash -c &#39;/opt/opencensus-agent/bin/ocagent -c /opt/opencensus-agent/conf/oca.yaml&#39;</em></blockquote><ul><li>Uninstall</li></ul><pre>apt-get remove opencensusagent<br>apt-get purge opencensusagent</pre><h3>Done</h3><p>Ok, so i just did something that completely nothing new…just wrote this up since i did this from scratch; hopefully somone finds some of these step useful…i’m still waiting for the beer thats owed me</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88c13aedc204" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>