{"id":2211,"date":"2025-03-11T19:30:00","date_gmt":"2025-03-11T23:30:00","guid":{"rendered":"https:\/\/enterpriseadmins.org\/blog\/?p=2211"},"modified":"2025-03-11T15:40:06","modified_gmt":"2025-03-11T19:40:06","slug":"automated-deployment-of-storage-server","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/virtualization\/automated-deployment-of-storage-server\/","title":{"rendered":"Automated Deployment of Storage Server"},"content":{"rendered":"\n<p>In this post, I\u2019ll walk through the process of automating the deployment of a storage server using Aria Automation. Specifically, I&#8217;ll show how to add an option to deploy a storage server dynamically in your lab environment and troubleshoot an iSCSI duplicate LUN ID issue.<\/p>\n\n\n\n<p>In a <a href=\"https:\/\/enterpriseadmins.org\/blog\/virtualization\/how-to-set-up-a-minimal-nfs-and-iscsi-storage-solution-using-ubuntu-24-04\/\">recent post<\/a>, I documented the creation of a storage server that could provide NFS or iSCSI storage for use in my lab.  To make consuming this appliance easier, I wanted to add a check box to my Aria Automation request form to determine if a storage server was needed.  If this box was checked, then a storage server would be included with the deployment.<\/p>\n\n\n\n<p>To achieve this, I added an additional vSphere.Machine object to my Assember Template and connected it to the same network as the nested ESXi host.  I then added a boolean input to the template.  Finally, the &#8216;count&#8217; property of the machine object is set using the following logic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>      count: ${input.deployStorageServer == true ? 1:0 }<\/code><\/pre>\n\n\n\n<p>This logic says that if the box is checked (boolean true) then the count is 1, otherwise it is 0. Here is a screenshot of the canvas after adding the machine:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2025\/03\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"161\" src=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2025\/03\/image.png\" alt=\"\" class=\"wp-image-2212\" srcset=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2025\/03\/image.png 597w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2025\/03\/image-300x81.png 300w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/a><\/figure>\n\n\n\n<p>I now have a toggle to deploy (or not) an external storage appliance when deploying nested ESXi hosts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Duplicate Device ID issue<\/h2>\n\n\n\n<p>After creating a couple of test deployments and adding hosts to vCenter Server, I ran into an interesting issue.  For deployment #1, I formatted LUN0 as VMFS.  For deployment #2, I tried to format LUN0 but it didn&#8217;t appear in the GUI.  Looking a bit more closely at the devices, I realized that the unique identifiers (naa.* value) of each LUN was the same.  This makes sense as each appliance was cloned with devices presented and all.  Next, I attempted to unmap and remap the iSCSI device from the appliance. Below are the commands I used.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo targetcli\n\n# Remove the iscsi LUN mapping\ncd \/iscsi\/iqn.2025-02.com.example.iscsi:target01\/tpg1\/luns\ndelete 0\n\n# Remove the disk mapping &amp; recreate\ncd \/backstores\/fileio\/\ndelete disk0\ncreate disk0 \/data\/iscsi\/disk0.img sparse=true write_back=false\n\n# Recreate the iscsi LUN mapping\ncd \/iscsi\/iqn.2025-02.com.example.iscsi:target01\/tpg1\/luns\ncreate \/backstores\/fileio\/disk0<\/code><\/pre>\n\n\n\n<p>After doing this and rescanning the host, I confirmed that the unique identifier (naa ID) changed and I was able to format LUN0 as VMFS.<\/p>\n\n\n\n<p>Longer term, I decided that I should not have the iSCSI mappings pre-created in my storage appliance.  I removed the configuration (<code>clearconfig confirm=True<\/code>) from the appliance, and instead placed the following script as: <code>\/data\/iscsi\/setup.sh<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>targetcli backstores\/fileio create disk0 \/data\/iscsi\/disk0.img sparse=true write_back=false\ntargetcli backstores\/fileio\/disk0 set attribute is_nonrot=1\ntargetcli backstores\/fileio create disk1 \/data\/iscsi\/disk1.img sparse=true write_back=false\ntargetcli backstores\/fileio\/disk1 set attribute is_nonrot=1\ntargetcli backstores\/fileio create disk2 \/data\/iscsi\/disk2.img sparse=true write_back=false\ntargetcli backstores\/fileio\/disk2 set attribute is_nonrot=1\n\ntargetcli \/iscsi create iqn.2025-02.com.example.iscsi:target01 \ntargetcli \/iscsi\/iqn.2025-02.com.example.iscsi:target01\/tpg1\/luns create \/backstores\/fileio\/disk0\ntargetcli \/iscsi\/iqn.2025-02.com.example.iscsi:target01\/tpg1\/luns create \/backstores\/fileio\/disk1\ntargetcli \/iscsi\/iqn.2025-02.com.example.iscsi:target01\/tpg1\/luns create \/backstores\/fileio\/disk2\n\ntargetcli \/iscsi\/iqn.2025-02.com.example.iscsi:target01\/tpg1\/acls create iqn.1998-01.com.vmware:h316-vesx-64.lab.enterpriseadmins.org:394284478:65\n\ntargetcli saveconfig<\/code><\/pre>\n\n\n\n<p>Now, after deploying the storage appliance, assuming I need an iSCSI target I can run <code>sudo \/data\/iscsi\/setup.sh<\/code> and have new identifiers generated at runtime.  This eliminates the identifier duplication and gets the automation ~80% of the way there. <\/p>\n\n\n\n<p>With the steps outlined above, I was able to automate the deployment of storage servers and resolve the issue with duplicate LUN IDs. This process saves time and ensures each deployment is consistent.  Going forward, I\u2019ll continue automating aspects of my lab environment to increase efficiency.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I\u2019ll walk through the process of automating the deployment of a storage server using Aria Automation. Specifically, I&#8217;ll show how to add an option to deploy a storage server dynamically in your lab environment and troubleshoot an &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/virtualization\/automated-deployment-of-storage-server\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9,4],"tags":[],"class_list":["post-2211","post","type-post","status-publish","format-standard","hentry","category-lab-infrastructure","category-virtualization"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/2211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=2211"}],"version-history":[{"count":5,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/2211\/revisions"}],"predecessor-version":[{"id":2217,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/2211\/revisions\/2217"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=2211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=2211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=2211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}