<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[CloudForms Now]]></provider_name><provider_url><![CDATA[http://cloudformsblog.redhat.com]]></provider_url><author_name><![CDATA[Victor Estival Lopez]]></author_name><author_url><![CDATA[https://cloudformsblog.redhat.com/author/vestival271017/]]></author_url><title><![CDATA[Ansible Custom Buttons in CloudForms (Part 2 creating the&nbsp;button)]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>This part will focus on how to create the Custom Button using an Ansible playbook.</p>
<h2><span style="font-weight:400;">Creating Custom Button</span></h2>
<p>CloudForms 4.6 has introduced more options while creating a button. This topic will be discussed in another post.</p>
<p><!--more--></p>
<p>Navigate to <b>Automation, Automate, Customizations, Custom Buttons.</b></p>
<p>Select the VM and Instance node.</p>
<p><img data-attachment-id="2454" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-31-20/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png" data-orig-size="1928,1020" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.31.20" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=1024" class="alignnone size-large wp-image-2454" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-31-20.png 1928w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>Select <b>Configuration, Add a new Button Group</b></p>
<p><img data-attachment-id="2457" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-33-56/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-33-56.png" data-orig-size="452,230" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.33.56" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-33-56.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-33-56.png?w=452" class="alignnone size-full wp-image-2457" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-33-56.png" alt="" /></p>
<p>Fill out the form as follows;</p>
<p><img data-attachment-id="2458" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-34-59/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png" data-orig-size="1902,564" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.34.59" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=1024" class="alignnone size-large wp-image-2458" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-34-59.png 1902w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>Select the button group you created in the previous steps.7</p>
<p><img data-attachment-id="2459" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-36-26/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png" data-orig-size="676,214" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.36.26" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png?w=300&#038;h=95" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png?w=676" class="alignnone wp-image-2459 size-medium" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png?w=300&#038;h=95" alt="" width="300" height="95" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png?w=300&amp;h=95 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png?w=600&amp;h=190 600w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-26.png?w=150&amp;h=47 150w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>Click on <b>Configuration, Add a new Button</b></p>
<p><img data-attachment-id="2460" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-36-56/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png" data-orig-size="506,312" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.36.56" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png?w=300&#038;h=185" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png?w=506" class="alignnone wp-image-2460 size-medium" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png?w=300&#038;h=185" alt="" width="300" height="185" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png?w=300&amp;h=185 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png?w=150&amp;h=92 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-36-56.png 506w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>Fill out the form as follows;</p>
<p><img data-attachment-id="2461" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-38-46/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png" data-orig-size="1862,790" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.38.46" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=1024" class="alignnone size-large wp-image-2461" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-38-46.png 1862w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>If a user clicks on the button, CloudForms will show the Dialog associated with the Service Catalog Item and will run the specified Ansible Playbook with the user provided details.</p>
<p>&nbsp;</p>
<p>Click on <b>Advanced</b> to add more details:</p>
<p><img data-attachment-id="2462" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-40-14/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png" data-orig-size="1460,1080" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.40.14" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=1024" class="alignnone size-large wp-image-2462" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-40-14.png 1460w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>The <b>Enablement</b> expression is validated to enable or disable the button based on the specified check. This allows you to enable the button only if some specific requirements are met. In the example above, we want to run an Ansible Playbook inside the VM. The expression validates the VM Power State and the button will be disabled if the VM is not powered on. An additional text will inform the user how to solve the issue.</p>
<p>&nbsp;</p>
<p>The <b>Visibility</b> allows you to define an expression which is validated to decide if the button should be shown at all. For example, if the guest Operating System is not Linux, the Ansible Playbook used will not work. If CloudForms detects a non-Linux VM, the menu will not be shown at all.</p>
<p>&nbsp;</p>
<p>Click on <b>Add</b> to create the button.</p>
<h2><span style="font-weight:400;">Testing it Out</span></h2>
<p>&nbsp;</p>
<p>Navigate to a Virtual Machine, click on <b>Operations, Install additional package</b>:</p>
<p><img data-attachment-id="2464" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-43-28/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png" data-orig-size="472,200" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.43.28" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png?w=300&#038;h=127" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png?w=472" class="alignnone wp-image-2464 size-medium" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png?w=300&#038;h=127" alt="" width="300" height="127" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png?w=300&amp;h=127 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png?w=150&amp;h=64 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-28.png 472w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p><img data-attachment-id="2465" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-43-49/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png" data-orig-size="1918,994" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.43.49" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=1024" class="alignnone size-large wp-image-2465" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-43-49.png 1918w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>After clicking the button, a new dialog will ask for details:</p>
<p><img data-attachment-id="2466" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-45-26/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png" data-orig-size="1970,586" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.45.26" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=1024" class="alignnone size-large wp-image-2466" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-26.png 1970w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>Specify a package to be installed on the virtual machine.</p>
<p><strong>Note</strong> that if the VM is powered off, the button should be disabled and a pop text with the hint specified earlier will be shown instead,</p>
<p><img data-attachment-id="2467" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-45-53/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png" data-orig-size="1940,416" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.45.53" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=1024" class="alignnone size-large wp-image-2467" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-45-53.png 1940w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>If the selected VM does not have Linux installed, the button and the corresponding menu should not show up at all.</p>
<p><img data-attachment-id="2468" data-permalink="https://cloudformsblog.redhat.com/2018/05/31/ansible-custom-buttons-in-cloudforms-part-2-creating-the-button/screen-shot-2018-05-28-at-14-46-38/" data-orig-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png" data-orig-size="1922,396" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Screen Shot 2018-05-28 at 14.46.38" data-image-description="" data-medium-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=300" data-large-file="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=1024" class="alignnone size-large wp-image-2468" src="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=1024" alt="" srcset="https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=1024 1024w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=150 150w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=300 300w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?w=768 768w, https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png 1922w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>
<p>In this example, a Windows VM was selected and the <b>Operations</b> button is not shown.</p>
<h1><span style="font-weight:400;">Conclusion</span></h1>
<p>This complete an example of building custom buttons utilizing Ansible Playbooks with CloudForms. This scenario allows users with unlimited, or no access to the virtual machine, to perform certain predefined actions. Further optimizations would be to simplify the dialog (hide the dialog element <b>Machine Credentials</b> and <b>Hosts</b>, since they are not needed.</p>
<p>&nbsp;</p>
<p>Instead of allowing the user to specify any package name in the text box, a drop-down list could be used to only allow the user to choose from a predefined list. The Role Based Access Control of CloudForms could also be used to allow access to this functionality only to specific user roles.</p>
<p>&nbsp;</p>
]]></html><thumbnail_url><![CDATA[https://cloudformsredhat.files.wordpress.com/2018/05/screen-shot-2018-05-28-at-14-46-38.png?fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[440]]></thumbnail_width><thumbnail_height><![CDATA[91]]></thumbnail_height></oembed>