<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Variable for resource pool (Looking for GCP project name) in HPE Morpheus Enterprise</title>
    <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251602#M4776</link>
    <description>&lt;P&gt;I went ahead and submitted in the idea section as well.  I am getting null for &amp;lt;%=instance.resourcePoolId%&amp;gt; and don’t see it listed in the documentation either…  running 5.4.5&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2022 19:20:07 GMT</pubDate>
    <dc:creator />
    <dc:date>2022-06-03T19:20:07Z</dc:date>
    <item>
      <title>Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251597#M4771</link>
      <description>&lt;P&gt;I am trying to find the variable for the resource pool information and cannot seem to find it.  If anyone knows of a method to see this through a morpheus variable or api call, please let me know.  I am specifically looking to create a task to allow for network tags to be added to google compute instances after they have been deployed.  In order to do this, I need to be able to pull the variables for the project that the vms reside in (morpheus resourcepool).  The item I am looking for is in this pic as an example:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;DIV class="lightbox-wrapper"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.hpe.com/t5/image/serverpage/image-id/150633i94079EF34E802361/image-size/large?v=v2&amp;amp;px=2000" role="button" title="8c3423315c10bd7379f19823e5caa7342dee0be7.png" alt="8c3423315c10bd7379f19823e5caa7342dee0be7.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 13:29:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251597#M4771</guid>
      <dc:creator />
      <dc:date>2022-06-03T13:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251598#M4772</link>
      <description>&lt;P&gt;Are you running the task against the instance or individual server?  This would need to run against the instance itself.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.morpheusdata.com/en/latest/troubleshooting/Variables_Examples.html?highlight=variables#instance" class="onebox" target="_blank" rel="noopener"&gt;https://docs.morpheusdata.com/en/latest/troubleshooting/Variables_Examples.html?highlight=variables#instance&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 19:30:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251598#M4772</guid>
      <dc:creator>cbunge</dc:creator>
      <dc:date>2022-06-03T19:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251599#M4773</link>
      <description>&lt;P&gt;It looks like from a native variable aspect, we are only capturing the Resource Pool ID &amp;lt;%=instance.resourcePoolId%&amp;gt;.  Assuming you’d have to curl to Morpheus to get the pool name.  If you have jq installed you could run this as a local shell script, for example:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;serverUrl='&amp;lt;%=morpheus.applianceUrl%&amp;gt;'
accessToken='&amp;lt;%=morpheus.apiAccessToken%&amp;gt;'
cloud='&amp;lt;%=instance.input.zoneId%&amp;gt;'
pool='&amp;lt;%=instance.resourcePoolId%&amp;gt;'

poolName=$(curl "$serverUrl/api/zones/$cloud/resource-pools/$pool" -H "Authorization: BEARER $accessToken" | jq .resourcePool.name)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jun 2022 16:13:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251599#M4773</guid>
      <dc:creator>cbunge</dc:creator>
      <dc:date>2022-06-03T16:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251600#M4774</link>
      <description>&lt;P&gt;Also any desired functionality can be added to the Ideas section to capture for future improvements!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 16:29:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251600#M4774</guid>
      <dc:creator>cbunge</dc:creator>
      <dc:date>2022-06-03T16:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251601#M4775</link>
      <description>&lt;P&gt;Whenever you get a chance for the placing in cypher and pulling from it to the task, but definitely not when you are on PTO!  &lt;IMG src="https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20" /&gt;  I was able to get it to function overall by creating the service account and creating the key and storing it locally.  It was a bit of a task due to gcloud commands requiring the projectID and not name, so additional calls were required.  Overall, it is working though.  I just didn’t know if I could utilize whatever method that morpheus uses already to make it happen instead of going into a custom setup.  Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 18:44:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251601#M4775</guid>
      <dc:creator />
      <dc:date>2022-06-23T18:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251602#M4776</link>
      <description>&lt;P&gt;I went ahead and submitted in the idea section as well.  I am getting null for &amp;lt;%=instance.resourcePoolId%&amp;gt; and don’t see it listed in the documentation either…  running 5.4.5&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2022 19:20:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251602#M4776</guid>
      <dc:creator />
      <dc:date>2022-06-03T19:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251603#M4777</link>
      <description>&lt;P&gt;Hey Cbunge, I have finally gotten back around to this, and able to get the project name from the morpheus variables, which is fantastic, but now I am stuck as to how to get gcloud to run from the morphes server.  It is installed, but I am getting stuck as to what user the tasks are getting ran as, if outside of sudo.  If I can get the task to auth with gcloud, I think I am set.  Any chance you or anyone else has performed gcloud commands within a task?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 20:02:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251603#M4777</guid>
      <dc:creator />
      <dc:date>2022-06-20T20:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251604#M4778</link>
      <description>&lt;P&gt;Ah so you are using gcloud sdk? I’ve ran this by installing as the morpheus-local user (this is the local execution user and needs access to any modules you plan on using).&lt;/P&gt;
&lt;P&gt;You can store the credential JSON in cypher and call it to auth. I can try and build an example next week when I’m back from PTO.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 18:24:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251604#M4778</guid>
      <dc:creator>cbunge</dc:creator>
      <dc:date>2022-06-23T18:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251605#M4779</link>
      <description>&lt;P&gt;Hey &lt;A class="mention" href="https://community.hpe.com/u/smittyt2"&gt;@smittyt2&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;When I’ve worked with the gcloud command, I needed to auth using a service account.  Using the &lt;CODE style="background : #f0f1f2;"&gt;gcloud auth activate-service-account&lt;/CODE&gt; command, it appears it requires a key file.  For myself, I did end up writing it to disk temporarily in the task but maybe &lt;A class="mention" href="https://community.hpe.com/u/cbunge"&gt;@cbunge&lt;/A&gt; will have an even better example laying around.&lt;/P&gt;
&lt;P&gt;Not the full code but you should get the gist:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;$creds = '&amp;lt;%=cypher.read("secret/gcloud")%&amp;gt;'
$region = '&amp;lt;%=results.getinfo.regionName%&amp;gt;'
$projectId = '&amp;lt;%=results.getinfo.projectId%&amp;gt;'

$filename = (New-Guid).guid

Set-Content -Path "$env:HOME/$filename" -Value $creds
gcloud auth activate-service-account --key-file "$env:HOME/$filename" --quiet --user-output-enabled=false
gcloud compute addresses create $addressName --region=$region --project=$projectId --quiet --user-output-enabled=false
Remove-Item "$env:HOME/$filename"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the case above, $creds contains a Cypher secret that contains the contents of a key file I downloaded from my service account, example:&lt;/P&gt;
&lt;PRE style="background : #f0f1f2;"&gt;&lt;CODE class="lang-auto"&gt;{
  "type": "service_account",
  "project_id": "serviceaccounts-######",
  "private_key_id": "redacted",
  "private_key": "-----BEGIN PRIVATE KEY-----redacted-----END PRIVATE KEY-----\n",
  "client_email": "redacted@serviceaccounts-######.iam.gserviceaccount.com",
  "client_id": "redacted",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/redacted%40serviceaccounts-######.iam.gserviceaccount.com"
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I did find that at least in the same phase, the authentication session remained between tasks, so you can create the file on the first task and remove it on the last.&lt;/P&gt;
&lt;P&gt;Hope that helps!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 22:30:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251605#M4779</guid>
      <dc:creator>KoreyG</dc:creator>
      <dc:date>2022-06-24T22:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for resource pool (Looking for GCP project name)</title>
      <link>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251606#M4780</link>
      <description>&lt;P&gt;To add to what &lt;A class="mention" href="https://community.hpe.com/u/cbunge"&gt;@cbunge&lt;/A&gt; mentioned, it matters in the case of the context.  See the below output from a quick PowerShell script using &lt;CODE style="background : #f0f1f2;"&gt;server.resourceId&lt;/CODE&gt; and &lt;CODE style="background : #f0f1f2;"&gt;instance.resourceId&lt;/CODE&gt;.  &lt;STRONG&gt;8:15&lt;/STRONG&gt; was using the instance as the context, &lt;STRONG&gt;8:16&lt;/STRONG&gt; was using the same task at the server context:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;DIV class="lightbox-wrapper"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.hpe.com/t5/image/serverpage/image-id/149860i1A12C35D23E6E3A9/image-size/large?v=v2&amp;amp;px=2000" role="button" title="5b26c3b94e67d0f1ad6343dcdb5c28cf459c74cc.png" alt="5b26c3b94e67d0f1ad6343dcdb5c28cf459c74cc.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jun 2022 00:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/hpe-morpheus-enterprise/variable-for-resource-pool-looking-for-gcp-project-name/m-p/7251606#M4780</guid>
      <dc:creator>KoreyG</dc:creator>
      <dc:date>2022-06-04T00:27:59Z</dc:date>
    </item>
  </channel>
</rss>

