Code Examples from the vRealize Automation Technical Marketing Team
git clone https://github.com/VMwareCMBUTMM/vra-code-examples.gitThe vra-code-examples skill provides a curated set of code examples specifically designed by the vRealize Automation Technical Marketing Team. This skill focuses on enhancing marketing automation through practical coding solutions, allowing developers and product managers to implement effective automation strategies quickly. By utilizing these examples, users can streamline their marketing workflows and improve operational efficiency. One of the key benefits of this skill is its ability to save time in the implementation of automation tasks. Although specific time savings are not quantified, the intermediate complexity of the skill suggests that users can expect to achieve significant efficiencies when integrating these code examples into their existing systems. This skill is particularly valuable for those looking to enhance their AI automation capabilities within marketing departments, where rapid deployment and adaptability are crucial. This skill is ideal for developers, product managers, and AI practitioners who are focused on marketing automation. By leveraging the vra-code-examples skill, users can gain insights into best practices and innovative solutions that can be directly applied to their projects. For instance, a marketing team could use these code examples to automate reporting processes or to integrate various marketing tools seamlessly, thereby reducing manual effort and increasing productivity. With an intermediate difficulty level, the implementation of this skill requires a foundational understanding of coding and automation principles. Users can expect to spend approximately 30 minutes to implement these examples effectively. As organizations increasingly adopt AI-first workflows, integrating such automation skills into their operations becomes essential for maintaining a competitive edge in the market. The vra-code-examples skill not only enhances workflow automation but also aligns perfectly with the evolving landscape of AI-driven marketing solutions.
1. **Identify Your Use Case**: Determine whether you need infrastructure provisioning, configuration management, or both. For example, use Terraform for resource creation and Ansible for post-deployment configuration. 2. **Set Up Your Environment**: - Install Terraform (v1.0+) and the vRA provider - Configure vRA with proper API access (refresh tokens, permissions) - Install Ansible (v2.10+) and required collections (community.general) 3. **Customize the Examples**: - Replace placeholder values (URLs, tokens, resource names) - Adjust input parameters and constraints based on your requirements - Modify cloud template resources to match your target platform (AWS, Azure, vSphere) 4. **Test Incrementally**: - Start with a simple deployment (1 VM) before scaling - Use vRA's "Test" mode for cloud templates before deployment - Validate Terraform plans before applying 5. **Integrate and Extend**: - Combine examples into a single workflow using vRA's pipelines - Add error handling and logging to your scripts - Consider using vRA's ABX actions for custom logic between provisioning steps **Pro Tips:** - Use vRA's "Code Stream" for CI/CD pipelines with these examples - Store sensitive data (tokens, credentials) in vRA's secret management - Document your customizations in a README file for team reference
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/VMwareCMBUTMM/vra-code-examplesCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Generate a set of practical vRealize Automation (vRA) code examples for [USE_CASE]. Include Terraform, Cloud Template (YAML), and Ansible snippets where applicable. Focus on [SPECIFIC_VERSION] and demonstrate integration with [TARGET_PLATFORM]. Provide explanations for each section and highlight common pitfalls to avoid.
Here are three vRealize Automation code examples for deploying a multi-tier application on AWS using vRA 8.12:
**1. Terraform Provider for vRA (main.tf)**
```hcl
terraform {
required_providers {
vra = {
source = "vmware/vra"
version = ">= 0.4.0"
}
}
}
provider "vra" {
url = "https://vra812.example.com"
refresh_token = var.vra_refresh_token
}
resource "vra_deployment" "webapp" {
name = "multi-tier-app"
description = "Production web application stack"
blueprint_id = vra_cloud_template.webapp.id
inputs = {
"web_count" = 2
"db_size" = "medium"
"domain_name" = "example.com"
}
}
```
**2. Cloud Template (webapp.yaml)**
```yaml
formatVersion: 1
inputs:
web_count:
type: integer
default: 2
minimum: 1
maximum: 5
db_size:
type: string
default: medium
enum:
- small
- medium
- large
resources:
WebTier:
type: Cloud.Machine
properties:
image: ubuntu-2004
flavor: ${input.web_count > 2 ? 'large' : 'medium'}
networks:
- network: ${resource.WebNetwork.id}
cloudConfig: |
#cloud-config
package_update: true
packages:
- nginx
runcmd:
- systemctl enable nginx
WebNetwork:
type: Cloud.Network
properties:
networkType: existing
name: "WebTier-Network"
```
**3. Ansible Playbook (deploy-webapp.yml)**
```yaml
---
- name: Configure web application
hosts: all
become: yes
tasks:
- name: Install application dependencies
apt:
name: ["python3", "python3-pip"]
state: present
update_cache: yes
- name: Deploy application code
copy:
src: ./app/
dest: /opt/webapp
owner: www-data
group: www-data
- name: Configure web server
template:
src: templates/nginx.conf.j2
dest: /etc/nginx/sites-available/webapp
notify: restart nginx
handlers:
- name: restart nginx
service:
name: nginx
state: restarted
```
**Key Integration Points:**
- The Terraform provider uses the vRA REST API to manage deployments
- The Cloud Template defines the infrastructure blueprint with conditional logic
- The Ansible playbook configures the deployed VMs post-provisioning
**Common Pitfalls:**
1. Forgetting to update the vRA provider version when upgrading vRA
2. Not validating input parameters in cloud templates (use `minimum`/`maximum` constraints)
3. Assuming all cloud regions support the same flavors (check provider documentation)
4. Not handling token expiration in Terraform (implement refresh logic)
For production use, add error handling, logging, and consider using vRA's ABX actions for more complex workflows.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan