{"id":1545,"date":"2022-01-17T12:22:06","date_gmt":"2022-01-17T11:22:06","guid":{"rendered":"https:\/\/nine30.info\/?p=1545"},"modified":"2022-01-17T12:22:06","modified_gmt":"2022-01-17T11:22:06","slug":"salt-sddc-modules-getting-started","status":"publish","type":"post","link":"https:\/\/nine30.nxt70.com\/index.php\/2022\/01\/17\/salt-sddc-modules-getting-started\/","title":{"rendered":"Salt SDDC Modules &#8211; Getting Started"},"content":{"rendered":"\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/saltproject.io\/\" target=\"_blank\">Salptoject.io<\/a> recently released a collection of open source (of course!) Salt-maintained extension modules for VMware vSphere, VMware Cloud on AWS and NSX-T. You can find these modules on Github&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/saltstack\/salt-ext-modules-vmware\" target=\"_blank\">here<\/a>, the documentation <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.saltproject.io\/salt\/extensions\/salt-ext-modules-vmware\/en\/latest\/index.html#\" target=\"_blank\">here<\/a> and a pretty cool quickstart guide&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/waynew\/salt-ext-modules-vmware\/blob\/quickstart-docs\/docs\/quickstart.rst\" target=\"_blank\">here<\/a>. This is quite early days for these modules, so at the moment I am just planning to cover this topic with a couple of posts, hopefully helping a bit the project to get momentum.<\/p>\n\n\n\n<p>These extension modules are currently undergoing rapid evolution, so it&#8217;s a good idea to start playing with them in a dev or lab environment. Please, note this could also be your laptop (Python virtual environment or a Virtual Machine). This post assumes that you have installed Salt by following directions on&nbsp;<a href=\"https:\/\/repo.saltproject.io\/\">https:\/\/repo.saltproject.io\/<\/a>, of course this also apply to vRA SaltStack Config that you can deploy using its installer as described <a rel=\"noreferrer noopener\" href=\"https:\/\/nine30.info\/vra-saltstack-config-install\/\" target=\"_blank\">here<\/a> or by using vRealize Suite Lifecycle Manager <a rel=\"noreferrer noopener\" href=\"https:\/\/nine30.info\/vra-saltstack-config-install-with-vrlcm\/\" target=\"_blank\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configure your system<\/h2>\n\n\n\n<p>I did the following as <code>root<\/code> user in a lab virtual machine with Salt installed in the system-wide Python 3. This isn&#8217;t necessarily a good configuration and definitely it is not the most secure, but I am just kicking tires here. Here I am using both master and minion on the the same machine, however these extension modules work with a remote minion as well.<\/p>\n\n\n\n<p>The idea is to configure these extensions modules in local configuration that doesn&#8217;t affect the the system wide Salt deployment. In order to do that as first step I created some directories under my user home directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd\nmkdir -p salt\/etc\/salt\/pki\/\nmkdir -p salt\/var\/cache\/ salt\/var\/log\/\nmkdir -p salt\/srv\/pillar\/ salt\/srv\/salt\ncd salt<\/code><\/pre>\n\n\n\n<p>Add file <code>~\/salt\/Saltfile<\/code> with the content below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>salt-call:\n  local: True\n  config_dir: etc\/salt<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note<\/strong>: a <strong>Saltfile<\/strong> is a local configuration that is used to define a configuration\/CLI option for any Salt utility such as: <code>salt, salt-call, salt-ssh,<\/code> etc. The Saltfile configuration provides options that override the default utility behaviour. A Saltfile can be located at: i) current directory (this is applied in this post); ii) <code>SALT_SALTFILE<\/code> environment variable; iii) <code>--saltfile<\/code> CLI option and iv) <code>~\/.salt\/Saltfile<\/code><\/p><\/blockquote>\n\n\n\n<p>In our case the Saltfile applies to the <code>salt-call<\/code> utility only and we are specifying this is a local configuration and pointing <code>salt-call<\/code> to a specific (alternative) configuration directory (please note that the this is provided as a relative path).<\/p>\n\n\n\n<p>Add file <code>~\/salt\/etc\/salt\/master<\/code> with the following content: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>user: root\nroot_dir: \/root\/salt\/\nfile_roots:\n  base:\n    - \/root\/salt\/\npublish_port: 55505\nret_port: 55506<\/code><\/pre>\n\n\n\n<p>This master configuration will be used by the <code>salt-call<\/code> utility when executed from the <code>~\/salt<\/code> directory.<\/p>\n\n\n\n<p>Add file <code>~\/salt\/etc\/salt\/minion<\/code> with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>id: master_minion\nuser: root\nroot_dir: \/root\/salt\/\nfile_root: \/root\/salt\/srv\/salt\npillar_root: \/root\/salt\/srv\/pillar\nmaster: localhost\nmaster_port: 55506<\/code><\/pre>\n\n\n\n<p><meta charset=\"utf-8\">This minion configuration will be used by the <code>salt-call<\/code> utility when executed from the <code>~\/salt<\/code> directory. Here it is important to note that we are setting minion id to <code>master_minion<\/code>, instructing <code>salt-call<\/code> to pick State files from <meta charset=\"utf-8\"><code>\/root\/salt\/srv\/salt<\/code> and pillars from <meta charset=\"utf-8\"><code>\/root\/salt\/srv\/pillar<\/code>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note<\/strong>: <code>master_minion<\/code> is the minion ID of the minion installed on the master machine. While working on this lab I also learned that <code>master_minion<\/code> is a kind of special parameter that is dynamically derived from the <code>\/etc\/salt\/minion_id<\/code> file on the Salt master.<\/p><\/blockquote>\n\n\n\n<p>Add file <code>~\/salt\/srv\/pillar\/top.sls<\/code> with the following content. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>base:\n  master_minion:\n    - my_vsphere_conf<\/code><\/pre>\n\n\n\n<p><meta charset=\"utf-8\">Add file <code>~\/srv\/pillar\/my_vsphere_conf.sls<\/code> with the following content (of course you need to replace content in angular bracket with your actual details). The data in this pillar file will be used to connect to your vCenter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vmware_config:\n  host: &lt;my-vcenter-fqdn-or-ip&gt;\n  user: &lt;my-vcenter-admin-username&gt;\n  password: &lt;my-vcenter-password&gt;<\/code><\/pre>\n\n\n\n<p>Test the configuration is correct by running the command <code>salt-call pillar.items<\/code>, you should have an output as follows. Make sure you issue this command from <code>~\/salt<\/code> directory. <\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-id=\"1549\" src=\"https:\/\/nine30.info\/wp-content\/uploads\/2021\/12\/00.pillar-1024x574.png\" alt=\"\" class=\"wp-image-1549\"\/><\/figure>\n<\/figure>\n\n\n\n<p>If you get no output, verify that your minion ID in <code>~\/srv\/pillar\/top.sls<\/code> matches the ID configured in <code>~\/etc\/salt\/minion<\/code>. Try again using the debug level logging with <code>salt-call -ldebug pillar.items<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install the SDDC Extension Modules<\/h2>\n\n\n\n<p>Now that you&#8217;ve got your salt instance configured, it&#8217;s time to install the extension modules. These modules are installed using pip as reported below. In my lab I run this on the master machine, but these modules can also be installed on a remote minion that you want to communicate with your VMware SDDC (vSphere, VMware Cloud on AWS, NSX-T). In this case instead of <code>salt-call<\/code> use <code>salt &lt;your-minion-id&gt;<\/code> and change Saltfile accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>salt-call pip.install saltext.vmware<\/code><\/pre>\n\n\n\n<p>If everything went well you should see <code>Successfully installed saltext.vmware-&lt;your-installed-version&gt;<\/code> at the end of the installation output message. That&#8217;s it! You have SDDC Modules installed, now you can do some tests by running some salt command (using execution modules).<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note<\/strong>: as stated before this project progresses quite quickly so I suggest you to follow <a rel=\"noreferrer noopener\" href=\"https:\/\/twitter.com\/Salt_Project_OS\" target=\"_blank\">@Salt_Project_OS<\/a> on Twitter and regularly check for new releases with the command below. The <code>include_rc=True<\/code> option gives you access to release candidates that I suggest to check in these early days of the project.<\/p><\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>salt-call pip.list_all_versions saltext.vmware include_rc=True<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-id=\"1629\" src=\"https:\/\/nine30.info\/wp-content\/uploads\/2022\/01\/03.list_all_versions-1024x637.png\" alt=\"\" class=\"wp-image-1629\"\/><\/figure>\n<\/figure>\n\n\n\n<p>If you spot a newer version you want to try, you can upgrade with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install --upgrade saltext.vmware<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Run commands<\/h2>\n\n\n\n<p>We will start getting some information from the vCenter by using list function for datacenter and cluster modules:<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-id=\"1550\" src=\"https:\/\/nine30.info\/wp-content\/uploads\/2021\/12\/01.lists_-1024x574.png\" alt=\"\" class=\"wp-image-1550\"\/><\/figure>\n<\/figure>\n\n\n\n<p> And now we can get some properties from our cluster:<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" data-id=\"1551\" src=\"https:\/\/nine30.info\/wp-content\/uploads\/2021\/12\/02.cluster.props_-1024x574.png\" alt=\"\" class=\"wp-image-1551\"\/><\/figure>\n<\/figure>\n\n\n\n<p><strong>Note<\/strong>: one thing that puzzled me a bit is the modules naming, you need to prefix <code>vmware_<\/code> to the module name in the command. For instance: according to the documentation the datacenter module is referred to <code>saltext.vmware.modules.datacenter<\/code> and when you run the command the module is named <code>vmware_datacenter<\/code>.<\/p>\n\n\n\n<p>Commands are great and we all love them, however the power of Salt lies in the State files. We will cover States files in the next post. Hope you enjoyed this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Salptoject.io recently released a collection of open source (of course!) Salt-maintained extension modules for VMware vSphere, VMware Cloud on AWS and NSX-T. You can find these modules on Github&nbsp;here, the documentation here and a pretty cool quickstart guide&nbsp;here. This is quite early days for these modules, so at the moment I am just planning to&hellip; <a class=\"more-link\" href=\"https:\/\/nine30.nxt70.com\/index.php\/2022\/01\/17\/salt-sddc-modules-getting-started\/\">Continue reading <span class=\"screen-reader-text\">Salt SDDC Modules &#8211; Getting Started<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1553,"comment_status":"open","ping_status":"open","sticky":false,"template":"templates\/template-cover.php","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[23,99,116,122,126,143,145,150,177,178,182,191],"class_list":["post-1545","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-automation","tag-linux","tag-nsx-t","tag-opensource","tag-oss","tag-salt","tag-saltstack","tag-sddc-2","tag-vmc","tag-vmware","tag-vmwarecloudonaws","tag-vsphere","entry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/posts\/1545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/comments?post=1545"}],"version-history":[{"count":0,"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/posts\/1545\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/media?parent=1545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/categories?post=1545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nine30.nxt70.com\/index.php\/wp-json\/wp\/v2\/tags?post=1545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}