├── README.md
├── Share_RSA.yml
├── cloudevops-badge.png
├── deploy.json
├── destroy.json
├── install.yml
├── page.html
├── vRA-deploy-VM.yml
└── vRA-destroy-VM.yml
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | # Ansible roles for vRealize Automation - VMware vCloud IaaS solution
8 |
9 |
10 | ## Description
11 |
12 | vRA-deploy-VM is a playbook that use ansible uri core module to request a VM from vRealize automation solution, the Vmware Cloud Automation Center (vCAC)
13 | This script is built to be run from a jenkins slave with a minmal installation in order to create an ephemeral deployement machine to deploy test and destroy the machines after testing.
14 |
15 | HOW It WORKS
16 | ================
17 | vRA-deploy-VM is a playbook that use ansible uri core module to request a VM from vRealize automation solution, the vmware cloud.
18 | This script can either be played form jenkins with ansible or in adhoc mode.
19 |
20 | requierement : ** A valid vRA account able to create/destroy machines **
21 |
22 | As you can see there is two main role file :
23 |
24 | ## vRA-deploy-VM.yml :
25 | This file is used to request a VM to vRealize Automation it will play a full mimed json request to ask ressource from vcloud and then get ip and hostname.
26 | Please store user and password in a separate yml vault file
27 |
28 | ### HOW to use it
29 | ```shell
30 | ansible-playbook vRA-deploy-VM.yml --ask-vault-pass
31 | ```
32 |
33 | ###### Input :
34 | ```yaml
35 | VRA_HOST: {{ VRA_HOST}}
36 | VRA_USER: {{ VRA_USER }}
37 | VRA_PASS: {{ VRA_PASS }}
38 | VRA_TENANT: {{ VRA_TENANT }}
39 | ```
40 |
41 | ###### Output :
42 | ```yaml
43 | VM_Destroy_id="{{ list.json.content[item].id }}"
44 | VM_name="{{ list.json.content[item].name }}"
45 | VM_IP="{{ list.json.content[item].resourceData }}
46 | ```
47 |
48 | ## vRA-destroy-VM.yml :
49 |
50 | ### HOW to use it
51 | ```shell
52 | ansible-playbook vRA-destroy-VM.yml --ask-vault-pass
53 | ```
54 |
55 | ###### Input :
56 | ```yaml
57 | VRA_HOST: {{ VRA_HOST}}
58 | VRA_USER: {{ VRA_USER }}
59 | VRA_PASS: {{ VRA_PASS }}
60 | VRA_TENANT: {{ VRA_TENANT }}
61 | {{ DESTROY_ID }}
62 | ```
63 | ###### Output :
64 | NONE
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Share_RSA.yml:
--------------------------------------------------------------------------------
1 | - hosts: '{{ host }}'
2 | remote_user: '{{ user }}'
3 |
4 | tasks:
5 | - name: Add RSA key to the remote host
6 | authorized_key: user='{{ user }}' key="{{ lookup('file', '{{home_user}}/.ssh/id_rsa.pub') }}"
7 |
--------------------------------------------------------------------------------
/cloudevops-badge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ClouDevops101/Ansible-VMware-vRealize-Automation/67d3b1cf19c3a3eae1ece4522ba088a1eeccd651/cloudevops-badge.png
--------------------------------------------------------------------------------
/deploy.json:
--------------------------------------------------------------------------------
1 | {
2 | "@type": "CatalogItemRequest",
3 | "catalogItemRef": {
4 | "id": "##CATALOG_ITEM_ID##",
5 | "label": "##CATALOG_ITEM_LABEL##"
6 | },
7 | "organization": {
8 | "tenantRef": "##VRA_TENANT##",
9 | "tenantLabel": "##VRA_TENANT##",
10 | "subtenantRef": "##BG_ID##",
11 | "subtenantLabel": "##BG##"
12 | },
13 | "requestedFor": "##USER_REQUESTEDFOR##",
14 | "state": "SUBMITTED",
15 | "requestNumber": 0,
16 | "requestData": {
17 | "entries": [
18 | {
19 | "key": "provider-blueprintId",
20 | "value": {
21 | "type": "string",
22 | "value": "##BINDING_ID##"
23 | }
24 | },
25 | {
26 | "key": "provider-provisioningGroupId",
27 | "value": {
28 | "type": "string",
29 | "value": "##BG_ID##"
30 | }
31 | },
32 | {
33 | "key": "provider-Cafe.Shim.VirtualMachine.Description",
34 | "value": {
35 | "type": "string",
36 | "value": "##DESCRIPTION##"
37 | }
38 | },
39 | {
40 | "key": "provider-Cafe.Shim.VirtualMachine.Reason",
41 | "value":
42 | {
43 | "type": "string",
44 | "value": "##REASON##"
45 | }
46 | },
47 | {
48 | "key": "provider-Cafe.Shim.VirtualMachine.NumberOfInstances",
49 | "value":
50 | {
51 | "type": "integer",
52 | "value": 1
53 | }
54 | },
55 | {
56 | "key": "provider-VirtualMachine.CPU.Count",
57 | "value":
58 | {
59 | "type": "integer",
60 | "value": ##CPU_COUNT##
61 | }
62 | },
63 | {
64 | "key": "provider-__Notes",
65 | "value":
66 | {
67 | "type": "string",
68 | "value": "##DESCRIPTION##"
69 | }
70 | },
71 | {
72 | "key": "provider-VirtualMachine.Disk0.Size",
73 | "value":
74 | {
75 | "type": "string",
76 | "value": "45"
77 | }
78 | },
79 | {
80 | "key": "provider-VirtualMachine.LeaseDays",
81 | "value":
82 | {
83 | "type": "integer",
84 | "value": ##CPU_COUNT##
85 | }
86 | },
87 | {
88 | "key": "provider-VirtualMachine.Memory.Size",
89 | "value":
90 | {
91 | "type": "integer",
92 | "value": ##MEMORY_SIZE##
93 | }
94 | }
95 | ]
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/destroy.json:
--------------------------------------------------------------------------------
1 | {
2 | "@type": "ResourceActionRequest",
3 | "resourceRef": {
4 | "id": "##DESTROY_ID##"
5 | },
6 | "resourceActionRef": {
7 | "id": "a4fd545b-7e13-4c10-8582-682a7a515486"
8 | },
9 | "organization": {
10 | "tenantRef": "##VRA_TENANT##",
11 | "tenantLabel": "##VRA_TENANT##",
12 | "subtenantRef": "334be3f3-c8bf-4e06-9813-88aa9ad8c285",
13 | "subtenantLabel": "##BG##"
14 | },
15 | "state": "SUBMITTED",
16 | "requestNumber": 0,
17 | "requestData": {
18 | "entries": []
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/install.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | # Defining used variable
4 | vars:
5 | Object: '{{ Object }}'
6 |
7 | tasks:
8 | # Install it if it's an rpm package
9 | - name: install rpm with yum
10 | yum: name='{{ Object }}' state=present
11 | when: '{{ Object | match("^.*.rpm$") }}'
12 | register: result_yum
13 | # Execute it if it's a shekk script
14 | - name: install a shell script # iOK only if isFirstRun is defined
15 | command: '{{ Object }}'
16 | when: '{{ Object | match("^.*.sh$") }}'
17 | register: result_shell - debug: msg="yum {{ result_yum }} shell {{ result_shell.stdout }} "
18 |
--------------------------------------------------------------------------------
/page.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |