├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── ansible.cfg ├── docs └── index.md ├── main.yml ├── module_utils ├── gateway_firewall_service.py ├── gateway_nat_rule_service.py ├── gateway_ssl_certificates.py ├── gateway_static_route.py ├── vcd.py ├── vcd_errors.py └── vcd_resources_endpoint.py ├── modules ├── vcd_catalog.py ├── vcd_catalog_item.py ├── vcd_disk.py ├── vcd_external_network.py ├── vcd_gateway_services.py ├── vcd_org.py ├── vcd_org_vdc.py ├── vcd_resources.py ├── vcd_roles.py ├── vcd_user.py ├── vcd_vapp.py ├── vcd_vapp_network.py ├── vcd_vapp_vm.py ├── vcd_vapp_vm_disk.py ├── vcd_vapp_vm_nic.py ├── vcd_vapp_vm_snapshot.py ├── vcd_vdc_gateway.py └── vcd_vdc_network.py ├── requirements.txt └── roles ├── catalog_item ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── catalogs ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── disk ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── org ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── user ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vapp ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vappnetwork ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vappvm ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vappvmdisk ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vappvmnic ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_edge_gateway ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_external_network ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_gateway_services ├── .travis.yml ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_org_vdc_network ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_roles ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_vapp_vm_nic ├── .travis.yml ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml ├── vcd_vapp_vm_snapshot ├── README.md ├── defaults │ └── main.yml ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── tasks │ └── main.yml ├── tests │ ├── inventory │ └── test.yml └── vars │ └── main.yml └── vdc ├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks └── main.yml ├── tests ├── inventory └── test.yml └── vars └── main.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause 3 | 4 | *.retry 5 | .DS_STORE 6 | *.todo 7 | .ipynb_checkpoints/ 8 | *.ipynb 9 | docs/ 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Contributing to ansible-module-vcloud-director 4 | 5 | The ansible-module-vcloud-director project team welcomes contributions from the community. Before you start working with ansible-module-vcloud-director, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. 6 | 7 | ## Community 8 | 9 | ## Getting Started 10 | 11 | ## Contribution Flow 12 | 13 | This is a rough outline of what a contributor's workflow looks like: 14 | 15 | - Create a topic branch from where you want to base your work 16 | - Make commits of logical units 17 | - Make sure your commit messages are in the proper format (see below) 18 | - Push your changes to a topic branch in your fork of the repository 19 | - Submit a pull request 20 | 21 | Example: 22 | 23 | ``` shell 24 | git remote add upstream https://github.com/vmware/ansible-module-vcloud-director.git 25 | git checkout -b my-new-feature master 26 | git commit -a 27 | git push origin my-new-feature 28 | ``` 29 | 30 | ### Staying In Sync With Upstream 31 | 32 | When your branch gets out of sync with the vmware/master branch, use the following to update: 33 | 34 | ``` shell 35 | git checkout my-new-feature 36 | git fetch -a 37 | git pull --rebase upstream master 38 | git push --force-with-lease origin my-new-feature 39 | ``` 40 | 41 | ### Updating pull requests 42 | 43 | If your PR fails to pass CI or needs changes based on code review, you'll most likely want to squash these changes into 44 | existing commits. 45 | 46 | If your pull request contains a single commit or your changes are related to the most recent commit, you can simply 47 | amend the commit. 48 | 49 | ``` shell 50 | git add . 51 | git commit --amend 52 | git push --force-with-lease origin my-new-feature 53 | ``` 54 | 55 | If you need to squash changes into an earlier commit, you can use: 56 | 57 | ``` shell 58 | git add . 59 | git commit --fixup 60 | git rebase -i --autosquash master 61 | git push --force-with-lease origin my-new-feature 62 | ``` 63 | 64 | Be sure to add a comment to the PR indicating your new changes are ready to review, as GitHub does not generate a 65 | notification when you git push. 66 | 67 | ### Code Style 68 | 69 | ### Formatting Commit Messages 70 | 71 | We follow the conventions on [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/). 72 | 73 | Be sure to include any related GitHub issue references in the commit message. See 74 | [GFM syntax](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown) for referencing issues 75 | and commits. 76 | 77 | ## Reporting Bugs and Creating Issues 78 | 79 | When opening a new issue, try to roughly follow the commit message format conventions above. 80 | 81 | ## Repository Structure 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # ansible-module-vcloud-director 4 | 5 | ## Overview 6 | **ansible-module-vcloud-director** is a set of ansible modules to manage various operations on VMware vCloud Director. 7 | 8 | ## Try it out 9 | 10 | ## Prerequisites 11 | 12 | 1. [Python 3.6 or above](https://www.python.org/downloads/) 13 | 2. [pyvcloud](https://github.com/vmware/pyvcloud) 14 | 15 | ## Build & Run 16 | 17 | 1. pip install --user pyvcloud 18 | 2. git clone https://github.com/vmware/ansible-module-vcloud-director 19 | 3. cd ansible-module-vcloud-director 20 | 4. ansible-playbook -i main.yml 21 | 22 | ## Usage 23 | 24 | This reposiroty packaged below two components to manage VCD, 25 | 26 | 1. Ansible Modules 27 | 2. Ansbile Playbooks 28 | 29 | Ansible playbooks are the client which use modules as a gateway to interact with VCD. We have written various ansible playbooks to show how to interact with VCD. We are using [ansible roles](https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html) to define playbooks in modular fashion for each module. Please refer [roles](https://github.com/vmware/ansible-module-vcloud-director/tree/master/roles) and [main.yml](https://github.com/vmware/ansible-module-vcloud-director/blob/master/main.yml) to see usage. 30 | 31 | ## Deployment 32 | 33 | These modules may be deployed in two ways, 34 | 35 | ##### Local Deployment 36 | 37 | We may define `modules` and `module_utils` settings in `ansible.cfg` to deploy ansible modules local to a directory. We have packaged `ansible.cfg` with this repository. You may refer [this](https://github.com/vmware/ansible-module-vcloud-director/blob/master/ansible.cfg) 38 | 39 | ##### Global Deployment 40 | 41 | We may copy `modules` and `module_utils` to below paths to deploy ansible modules globally. 42 | 43 | - `/usr/share/ansible/plugins/modules/` 44 | - `/usr/share/ansible/plugins/module_utils` 45 | 46 | ## Documentation 47 | 48 | Refer [docs](https://github.com/vmware/ansible-module-vcloud-director/wiki/vCD-Ansible-Modules) to know more about available modules and their usage. 49 | 50 | 1. vcd_catalog 51 | 2. vcd_catalog_item 52 | 3. vcd_disk 53 | 4. vcd_external_network 54 | 5. vcd_org 55 | 6. vcd_org_vdc 56 | 7. vcd_roles 57 | 8. vcd_user 58 | 9. vcd_vapp 59 | 10. vcd_vapp_network 60 | 11. vcd_vapp_vm 61 | 12. vcd_vapp_vm_disk 62 | 13. vcd_vapp_vm_nic 63 | 14. vcd_vapp_vm_snapshot 64 | 15. vcd_vdc_gateway 65 | 16. vcd_vdc_network 66 | 17. vcd_gateway_services 67 | 68 | ## Releases & Major Branches 69 | 70 | Following is the approx version matrix which are tested and supported through vCD ansible modules, 71 | 72 | | vCD Version | API Versions | 73 | | ------------- | ------------- | 74 | | vCD 9.0 | 29.0 | 75 | | vCD 9.1 | 30.0 | 76 | | vCD 9.5 | 31.0 | 77 | | vCD 9.7 | 32.0 | 78 | | vCD 10.0 | 33.0 | 79 | | vCD 10.1 | 34.0 | 80 | 81 | Note - Testing is still in progress for new releases of vCD and Pyvcloud. 82 | 83 | ## Contributing 84 | 85 | The **ansible-module-vcloud-director** project team welcomes contributions from the community. Before you start working with ansible-module-vcloud-director, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). 86 | All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to [CONTRIBUTING.md](CONTRIBUTING.md). 87 | 88 | ## License 89 | [BSD-2 License or GPLv3](LICENSE.txt) 90 | -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | [defaults] 5 | library = modules 6 | module_utils = module_utils -------------------------------------------------------------------------------- /main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - name: vCloudDirectorAnsible 5 | hosts: localhost 6 | environment: 7 | env_user: terraformadmin 8 | env_password: XXXXXXXXXXXXX 9 | env_host: XXXXXXXXXXXXX 10 | env_org: Terraform 11 | env_api_version: 30.0 12 | env_verify_ssl_certs: false 13 | roles: 14 | - org 15 | - user 16 | - vdc 17 | - catalogs 18 | - catalog_items 19 | - disk 20 | - vapp 21 | - vcd_vapp_network 22 | - vappvm 23 | - external_networks 24 | - vcd_edge_gateway 25 | - org_vdc_networks 26 | - vcd_vapp_vm_snapshot 27 | - vcd_vapp_vm_disk 28 | - vcd_vapp_vm_nic 29 | - vcd_gateway_services 30 | -------------------------------------------------------------------------------- /module_utils/gateway_firewall_service.py: -------------------------------------------------------------------------------- 1 | 2 | import traceback 3 | from pyvcloud.vcd.firewall_rule import FirewallRule 4 | from pyvcloud.vcd.exceptions import BadRequestException 5 | from pyvcloud.vcd.exceptions import EntityNotFoundException 6 | 7 | 8 | class FirewallService(): 9 | def __init__(self, gateway, service_params=None): 10 | self.gateway = gateway 11 | self.service_params = service_params 12 | 13 | def get_firewall_rules(self): 14 | response = dict() 15 | response['changed'] = False 16 | response['msg'] = list() 17 | 18 | fw_rules = self.gateway.get_firewall_rules_list() 19 | for fw_rule in fw_rules: 20 | response['msg'].append({ 21 | "name": str(fw_rule["name"]), 22 | "id": int(fw_rule["ID"]), 23 | "type": str(fw_rule["ruleType"]) 24 | }) 25 | 26 | return response 27 | 28 | def get_firewall_rule(self, fw_rule_name): 29 | fw_rules = self.get_firewall_rules()['msg'] 30 | for fw_rule in fw_rules: 31 | if fw_rule["name"] == fw_rule_name: 32 | return FirewallRule(client=self.gateway.client, 33 | gateway_name=self.gateway.name, 34 | resource_id=fw_rule["id"]) 35 | 36 | msg = "Firewall rule {0} does not exists" 37 | raise EntityNotFoundException(msg.format(fw_rule_name)) 38 | 39 | def manage_states(self, state=None): 40 | if state == "present": 41 | return self.add() 42 | 43 | if state == "update": 44 | return self.update() 45 | 46 | if state == "absent": 47 | return self.delete() 48 | 49 | raise Exception("Please provide a valid state for the service") 50 | 51 | def manage_operations(self, operation=None): 52 | if operation == "list": 53 | return self.get_firewall_rules() 54 | 55 | raise Exception("Please provide a valid operation for the service") 56 | 57 | def _update_response(self, response, msg, warnings): 58 | if response['msg']: 59 | response['msg'] = msg.format(response['msg']) 60 | if response['warnings']: 61 | response['warnings'] = warnings.format(response['warnings']) 62 | 63 | return response 64 | 65 | def _prepare_service_values(self, services): 66 | if services is not None: 67 | for service in services: 68 | for name, value in service.copy().items(): 69 | service[name] = { 70 | value["source_port"]: value["destination_port"] 71 | } 72 | 73 | return services 74 | 75 | def _prepare_route_values(self, route_values): 76 | response = list() 77 | if route_values is not None: 78 | for route_value in route_values: 79 | for route, value in route_value.items(): 80 | if value[0].lower() == 'any': 81 | return ['any'] 82 | response.append("{0}:{1}".format(value[0], route)) 83 | 84 | return response 85 | 86 | def add(self): 87 | response = dict() 88 | response['changed'] = False 89 | response['warnings'] = list() 90 | response['msg'] = list() 91 | msg = 'Firewall rule(s) {0} have been created' 92 | warnings = 'Firewall rule(s) {0} are already present' 93 | 94 | for service_param in self.service_params: 95 | name = service_param.get("name") 96 | action = service_param.get("action") or 'accept' 97 | firewall_type = service_param.get("type") or 'User' 98 | enabled = service_param.get("enabled") or True 99 | logging_enabled = service_param.get("logging_enabled") or False 100 | 101 | try: 102 | self.get_firewall_rule(name) 103 | except EntityNotFoundException: 104 | self.gateway.add_firewall_rule(name=name, action=action, 105 | type=firewall_type, 106 | enabled=enabled, 107 | logging_enabled=logging_enabled) 108 | try: 109 | self.update([service_param]) 110 | except Exception: 111 | self.delete([service_param]) 112 | raise Exception(traceback.format_exc()) 113 | else: 114 | response['msg'].append(name) 115 | response['changed'] = True 116 | else: 117 | response['warnings'].append(name) 118 | 119 | return self._update_response(response, msg, warnings) 120 | 121 | def update(self, service_params=None): 122 | response = dict() 123 | response['changed'] = False 124 | response['msg'] = list() 125 | response['warnings'] = list() 126 | msg = 'Firewall rule(s) {0} have been updated' 127 | warnings = 'Firewall rule(s) {0} are not present' 128 | 129 | service_params = service_params or self.service_params 130 | for service_param in service_params: 131 | name = service_param.get("name") 132 | new_name = service_param.get("new_name") or name 133 | services = service_param.get("services") or None 134 | source_values = service_param.get("source_values") or None 135 | destination_values = service_param.get( 136 | "destination_values") or None 137 | 138 | try: 139 | firewall_rule = self.get_firewall_rule(name) 140 | services = self._prepare_service_values(services) 141 | source_values = self._prepare_route_values(source_values) 142 | destination_values = self._prepare_route_values( 143 | destination_values) 144 | if 'any' in destination_values or 'any' in source_values: 145 | continue 146 | firewall_rule.edit(source_values=source_values, 147 | services=services, 148 | destination_values=destination_values, 149 | new_name=new_name) 150 | response['msg'].append(name) 151 | response['changed'] = True 152 | except EntityNotFoundException: 153 | response['warnings'].append(name) 154 | except BadRequestException as ex: 155 | raise Exception(ex) 156 | 157 | return self._update_response(response, msg, warnings) 158 | 159 | def delete(self, service_params=None): 160 | response = dict() 161 | response['changed'] = False 162 | response['msg'] = list() 163 | response['warnings'] = list() 164 | msg = 'Firewall rule(s) {0} have been deleted' 165 | warnings = 'Firewall rule(s) {0} are not present' 166 | 167 | service_params = service_params or self.service_params 168 | for service_param in service_params: 169 | try: 170 | name = service_param.get("name") 171 | firewall_rule = self.get_firewall_rule(name) 172 | except EntityNotFoundException: 173 | response['warnings'].append(name) 174 | else: 175 | firewall_rule.delete() 176 | response['msg'].append(name) 177 | response['changed'] = True 178 | 179 | return self._update_response(response, msg, warnings) 180 | -------------------------------------------------------------------------------- /module_utils/gateway_nat_rule_service.py: -------------------------------------------------------------------------------- 1 | 2 | from pyvcloud.vcd.nat_rule import NatRule 3 | from pyvcloud.vcd.utils import build_network_url_from_gateway_url 4 | from pyvcloud.vcd.network_url_constants import NAT_RULE_URL_TEMPLATE 5 | 6 | 7 | class NatRuleService(): 8 | def __init__(self, gateway, service_params=None): 9 | self.gateway = gateway 10 | self.service_params = service_params 11 | 12 | def manage_states(self, state=None): 13 | if state == "present": 14 | return self.add() 15 | 16 | if state == "update": 17 | return self.update() 18 | 19 | if state == "absent": 20 | return self.delete() 21 | 22 | raise Exception("Please provide a valid state for the service") 23 | 24 | def manage_operations(self, operation=None): 25 | if operation == "list": 26 | return self.get_nat_rules() 27 | 28 | raise Exception("Please provide a valid operation for the service") 29 | 30 | def get_nat_rule_href(self, nat_rule_id): 31 | network_url = build_network_url_from_gateway_url(self.gateway.href) 32 | nat_href = network_url + NAT_RULE_URL_TEMPLATE 33 | 34 | return nat_href.format(nat_rule_id) 35 | 36 | def get_nat_rules(self): 37 | response = dict() 38 | response['changed'] = False 39 | response['msg'] = list() 40 | 41 | nat_rules_resource = self.gateway.get_nat_rules() 42 | if (hasattr(nat_rules_resource.natRules, 'natRule')): 43 | for nat_rule in nat_rules_resource.natRules.natRule: 44 | nat_rule_info = {} 45 | nat_rule_info['ID'] = int(nat_rule.ruleId) 46 | nat_rule_info['Action'] = str(nat_rule.action) 47 | nat_rule_info['Enabled'] = str(nat_rule.enabled) 48 | if hasattr(nat_rule, 'description'): 49 | nat_rule_info['Description'] = str(nat_rule.description) 50 | nat_rule_info['href'] = self.get_nat_rule_href( 51 | nat_rule_info['ID']) 52 | response['msg'].append(nat_rule_info) 53 | 54 | return response 55 | 56 | def add(self): 57 | response = dict() 58 | response['changed'] = False 59 | 60 | for service_param in self.service_params: 61 | action = service_param.get("action") 62 | original_address = service_param.get("original_address") 63 | translated_address = service_param.get("translated_address") 64 | description = service_param.get("description", '') 65 | protocol = service_param.get("protocol", 'any') 66 | original_port = service_param.get("original_port", 'any') 67 | translated_port = service_param.get("translated_port", 'any') 68 | access_type = service_param.get("access_type", 'User') 69 | icmp_type = service_param.get("icmp_type", 'any') 70 | enabled = service_param.get("enabled", True) 71 | logging_enabled = service_param.get("logging_enabled", False) 72 | vnic = service_param.get("vnic", 0) 73 | 74 | self.gateway.add_nat_rule(action, original_address, 75 | translated_address, description, 76 | protocol, original_port, 77 | translated_port, access_type, 78 | icmp_type, logging_enabled, 79 | enabled, vnic) 80 | response['msg'] = 'Nat rule(s) are added' 81 | response['changed'] = True 82 | 83 | return response 84 | 85 | def update(self): 86 | response = dict() 87 | response['changed'] = False 88 | response['msg'] = list() 89 | 90 | for service_param in self.service_params: 91 | nat_rule_id = service_param.get("nat_rule_id") 92 | original_address = service_param.get("original_address") 93 | translated_address = service_param.get("translated_address") 94 | description = service_param.get("description", '') 95 | protocol = service_param.get("protocol", 'any') 96 | original_port = service_param.get("original_port", 'any') 97 | translated_port = service_param.get("translated_port", 'any') 98 | icmp_type = service_param.get("icmp_type", 'any') 99 | enabled = service_param.get("enabled", True) 100 | logging_enabled = service_param.get("logging_enabled", False) 101 | vnic = service_param.get("vnic", 0) 102 | nat_rule_obj = NatRule(client=self.gateway.client, 103 | gateway_name=self.gateway.name, 104 | rule_id=nat_rule_id) 105 | nat_rule_obj.href = self.get_nat_rule_href(nat_rule_id) 106 | nat_rule_obj.update_nat_rule( 107 | original_address, 108 | translated_address, 109 | description, 110 | protocol, 111 | original_port, 112 | translated_port, 113 | icmp_type, 114 | logging_enabled, 115 | enabled, 116 | vnic 117 | ) 118 | response['msg'].append(nat_rule_id) 119 | response['msg'] = 'Nat rule(s) {0} are updated'.format(response['msg']) 120 | response['changed'] = True 121 | 122 | return response 123 | 124 | def delete(self): 125 | response = dict() 126 | response['changed'] = False 127 | response['msg'] = list() 128 | 129 | for service_param in self.service_params: 130 | nat_rule_id = service_param.get("nat_rule_id") 131 | nat_rule_obj = NatRule(client=self.gateway.client, 132 | gateway_name=self.gateway.name, 133 | rule_id=nat_rule_id) 134 | nat_rule_obj.href = self.get_nat_rule_href(nat_rule_id) 135 | nat_rule_obj.delete_nat_rule() 136 | response['msg'].append(nat_rule_id) 137 | response['msg'] = 'Nat rule(s) {0} are deleted'.format(response['msg']) 138 | response['changed'] = True 139 | 140 | return response 141 | -------------------------------------------------------------------------------- /module_utils/gateway_ssl_certificates.py: -------------------------------------------------------------------------------- 1 | 2 | from pyvcloud.vcd.certificate import Certificate 3 | 4 | 5 | class SSLCertificates(): 6 | def __init__(self, gateway, service_params=None): 7 | self.gateway = gateway 8 | self.service_params = service_params 9 | 10 | def manage_states(self, state=None): 11 | if state == "present": 12 | return self.add() 13 | 14 | if state == "update": 15 | return self.update() 16 | 17 | if state == "absent": 18 | return self.delete() 19 | 20 | raise Exception("Please provide a valid state for the service") 21 | 22 | def manage_operations(self, operation=None): 23 | if operation == "list": 24 | return self.get_ssl_certificates() 25 | 26 | raise Exception("Please provide a valid operation for the service") 27 | 28 | def get_service_certificates(self): 29 | response = list() 30 | for certs in self.gateway.list_service_certificates(): 31 | response.append({ 32 | 'name': str(certs["Name"]), 33 | 'object_id': str(certs["Object_Id"]) 34 | }) 35 | 36 | return response 37 | 38 | def get_ca_certificates(self): 39 | response = list() 40 | for certs in self.gateway.list_ca_certificates(): 41 | response.append({ 42 | 'name': str(certs["Name"]), 43 | 'object_id': str(certs["Object_Id"]) 44 | }) 45 | 46 | return response 47 | 48 | def get_crl_certificates(self): 49 | response = list() 50 | for certs in self.gateway.list_crl_certificates(): 51 | response.append({ 52 | 'name': str(certs["Name"]), 53 | 'object_id': str(certs["Object_Id"]) 54 | }) 55 | 56 | return response 57 | 58 | def get_ssl_certificates(self): 59 | response = dict() 60 | response['changed'] = False 61 | response['msg'] = self.get_service_certificates( 62 | ) + self.get_ca_certificates() + self.get_crl_certificates() 63 | 64 | return response 65 | 66 | def add(self): 67 | response = dict() 68 | response['changed'] = False 69 | response['warnings'] = list() 70 | response['msg'] = list() 71 | msg = 'SSL Certificates have been added' 72 | 73 | for service_param in self.service_params: 74 | cert_type = service_param.get("cert_type") or 'service' 75 | if cert_type == 'service': 76 | self.add_service_certificate(service_param) 77 | if cert_type == 'ca': 78 | self.add_ca_certificate(service_param) 79 | if cert_type == 'crl': 80 | self.add_crl_certificate(service_param) 81 | 82 | response['msg'] = msg 83 | response['changed'] = True 84 | 85 | return response 86 | 87 | def add_service_certificate(self, service_param): 88 | cert_file_path = service_param.get('cert_file_path') 89 | key_file_path = service_param.get('key_file_path') 90 | key_passphrase = service_param.get('key_passphrase') 91 | description = service_param.get('description') 92 | 93 | return self.gateway.add_service_certificate( 94 | cert_file_path, key_file_path, key_passphrase, description) 95 | 96 | def add_ca_certificate(self, service_param): 97 | cert_file_path = service_param.get('cert_file_path') 98 | description = service_param.get('description') 99 | 100 | return self.gateway.add_ca_certificate(cert_file_path, description) 101 | 102 | def add_crl_certificate(self, service_param): 103 | cert_file_path = service_param.get('cert_file_path') 104 | description = service_param.get('description') 105 | 106 | return self.gateway.add_crl_certificate(cert_file_path, description) 107 | 108 | def delete(self): 109 | response = dict() 110 | response['changed'] = False 111 | response['msg'] = list() 112 | response['warnings'] = list() 113 | msg = 'SSL Certificates have been deleted' 114 | 115 | for service_param in self.service_params: 116 | cert_type = service_param.get("cert_type") or 'service' 117 | if cert_type == 'service': 118 | self.delete_service_certificate(service_param) 119 | if cert_type == 'ca': 120 | self.delete_ca_certificate(service_param) 121 | if cert_type == 'crl': 122 | self.delete_crl_certificate(service_param) 123 | 124 | response['msg'] = msg 125 | response['changed'] = True 126 | 127 | return response 128 | 129 | def delete_service_certificate(self, service_param): 130 | service_certs = self.get_service_certificates() 131 | cert_name = service_param.get("cert_name") 132 | for service_cert in service_certs: 133 | if service_cert.get("name") == cert_name: 134 | cert = Certificate(client=self.gateway.client, 135 | gateway_name=self.gateway.name, 136 | resource_id=service_cert.get("object_id")) 137 | cert.delete_certificate() 138 | 139 | def delete_ca_certificate(self, service_param): 140 | ca_certs = self.get_ca_certificates() 141 | cert_name = service_param.get("cert_name") 142 | for ca_cert in ca_certs: 143 | if ca_cert.get("name") == cert_name: 144 | cert = Certificate(client=self.gateway.client, 145 | gateway_name=self.gateway.name, 146 | resource_id=ca_cert.get("object_id")) 147 | cert.delete_certificate() 148 | 149 | def delete_crl_certificate(self, service_param): 150 | crl_certs = self.get_crl_certificates() 151 | cert_name = service_param.get("cert_name") 152 | for crl_cert in crl_certs: 153 | if crl_cert.get("name") == cert_name: 154 | cert = Certificate(client=self.gateway.client, 155 | gateway_name=self.gateway.name, 156 | resource_id=crl_cert.get("object_id")) 157 | cert.delete_certificate() 158 | -------------------------------------------------------------------------------- /module_utils/gateway_static_route.py: -------------------------------------------------------------------------------- 1 | 2 | from pyvcloud.vcd.static_route import StaticRoute 3 | from pyvcloud.vcd.exceptions import BadRequestException 4 | from pyvcloud.vcd.exceptions import EntityNotFoundException 5 | 6 | 7 | class StaticRoutes(): 8 | def __init__(self, gateway, service_params=None): 9 | self.gateway = gateway 10 | self.service_params = service_params 11 | 12 | def manage_states(self, state=None): 13 | if state == "present": 14 | return self.add() 15 | 16 | if state == "update": 17 | return self.update() 18 | 19 | if state == "absent": 20 | return self.delete() 21 | 22 | raise Exception("Please provide a valid state for the service") 23 | 24 | def manage_operations(self, operation=None): 25 | if operation == "list": 26 | return self.get_static_routes() 27 | 28 | raise Exception("Please provide a valid operation for the service") 29 | 30 | def _update_response(self, response, msg, warnings): 31 | if response['msg']: 32 | response['msg'] = msg.format(response['msg']) 33 | if response['warnings']: 34 | response['warnings'] = warnings.format(response['warnings']) 35 | 36 | return response 37 | 38 | def get_static_routes(self): 39 | response = dict() 40 | response['changed'] = False 41 | 42 | response['msg'] = self.gateway.list_static_routes() 43 | return response 44 | 45 | def is_route_present(self, network): 46 | for route in self.gateway.list_static_routes(): 47 | if route['Network'] == network: 48 | return True 49 | raise EntityNotFoundException() 50 | 51 | def add(self): 52 | response = dict() 53 | response['changed'] = False 54 | response['warnings'] = list() 55 | response['msg'] = list() 56 | msg = 'Static Route(s) {0} have been created' 57 | warnings = 'Static Route(s) {0} may already present' 58 | 59 | for service_param in self.service_params: 60 | try: 61 | network = service_param.get("network") 62 | next_hop = service_param.get("next_hop") 63 | mtu = service_param.get("mtu") or 1500 64 | description = service_param.get("description") 65 | route_type = service_param.get("route_type") or 'User' 66 | vnic = service_param.get("vnic") or 0 67 | 68 | self.gateway.add_static_route(network=network, 69 | next_hop=next_hop, 70 | mtu=mtu, 71 | description=description, 72 | type=route_type, 73 | vnic=vnic) 74 | except BadRequestException: 75 | response['warnings'].append(network) 76 | else: 77 | response['msg'].append(network) 78 | response['changed'] = True 79 | 80 | return self._update_response(response, msg, warnings) 81 | 82 | def update(self): 83 | response = dict() 84 | response['changed'] = False 85 | response['msg'] = list() 86 | response['warnings'] = list() 87 | msg = 'Static Route(s) {0} have been updated' 88 | warnings = 'Static Route(s) {0} are not present' 89 | 90 | for service_param in self.service_params: 91 | try: 92 | network = service_param.get("network") 93 | new_network = service_param.get("new_network") or network 94 | next_hop = service_param.get("next_hop") 95 | mtu = service_param.get("mtu") or 1500 96 | description = service_param.get("description") 97 | vnic = service_param.get("vnic") or 0 98 | 99 | if self.is_route_present(network): 100 | static_route = StaticRoute(client=self.gateway.client, 101 | gateway_name=self.gateway.name, 102 | route_network_id=network) 103 | static_route.update_static_route(network=new_network, 104 | next_hop=next_hop, 105 | mtu=mtu, 106 | description=description, 107 | vnic=vnic) 108 | response['msg'].append(network) 109 | response['changed'] = True 110 | except EntityNotFoundException: 111 | response['warnings'].append(network) 112 | 113 | return self._update_response(response, msg, warnings) 114 | 115 | def delete(self): 116 | response = dict() 117 | response['changed'] = False 118 | response['msg'] = list() 119 | response['warnings'] = list() 120 | msg = 'Static Route(s) {0} have been deleted' 121 | warnings = 'Static Route(s) {0} are not present' 122 | 123 | for service_param in self.service_params: 124 | try: 125 | network = service_param.get("network") 126 | if self.is_route_present(network): 127 | static_route = StaticRoute(client=self.gateway.client, 128 | gateway_name=self.gateway.name, 129 | route_network_id=network) 130 | static_route.delete_static_route() 131 | response['msg'].append(network) 132 | response['changed'] = True 133 | except EntityNotFoundException: 134 | response['warnings'].append(network) 135 | 136 | return self._update_response(response, msg, warnings) 137 | -------------------------------------------------------------------------------- /module_utils/vcd.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | from lxml import etree 5 | from pyvcloud.vcd.client import Client 6 | from pyvcloud.vcd.client import TaskStatus 7 | from ansible.module_utils.basic import AnsibleModule, env_fallback 8 | from pyvcloud.vcd.client import BasicLoginCredentials 9 | from requests.packages import urllib3 10 | 11 | urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 12 | 13 | 14 | def vcd_argument_spec(): 15 | return dict( 16 | user=dict(type='str', required=True, fallback=(env_fallback, ['env_user'])), 17 | password=dict(type='str', required=True, no_log=True, fallback=(env_fallback, ['env_password'])), 18 | org=dict(type='str', required=True, fallback=(env_fallback, ['env_org'])), 19 | host=dict(type='str', required=True, fallback=(env_fallback, ['env_host'])), 20 | api_version=dict(type='str', fallback=(env_fallback, ['env_api_version']), default='30.0'), 21 | verify_ssl_certs=dict(type='bool', fallback=(env_fallback, ['env_verify_ssl_certs']), default=False) 22 | ) 23 | 24 | 25 | class VcdAnsibleModule(AnsibleModule): 26 | def __init__(self, *args, **kwargs): 27 | argument_spec = vcd_argument_spec() 28 | argument_spec.update(kwargs.get('argument_spec', dict())) 29 | kwargs['argument_spec'] = argument_spec 30 | 31 | super(VcdAnsibleModule, self).__init__(*args, **kwargs) 32 | self.login() 33 | 34 | def login(self): 35 | try: 36 | user = self.params.get('user') 37 | password = self.params.get('password') 38 | org = self.params.get('org') 39 | host = self.params.get('host') 40 | api_version = self.params.get('api_version') 41 | verify_ssl_certs = self.params.get('verify_ssl_certs') 42 | self.client = Client(host, 43 | api_version=api_version, 44 | verify_ssl_certs=verify_ssl_certs) 45 | 46 | self.client.set_credentials(BasicLoginCredentials(user, org, password)) 47 | 48 | except Exception as error: 49 | self.fail_json(msg='Login failed for user {} to org {}'.format(user, org)) 50 | 51 | def execute_task(self, task): 52 | task_monitor = self.client.get_task_monitor() 53 | task_state = task_monitor.wait_for_status( 54 | task=task, 55 | timeout=60, 56 | poll_frequency=2, 57 | fail_on_statuses=None, 58 | expected_target_statuses=[ 59 | TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR, 60 | TaskStatus.CANCELED 61 | ], 62 | callback=None) 63 | 64 | task_status = task_state.get('status') 65 | if task_status != TaskStatus.SUCCESS.value: 66 | raise Exception(etree.tostring(task_state, pretty_print=True)) 67 | 68 | return 1 69 | -------------------------------------------------------------------------------- /module_utils/vcd_errors.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | 5 | class VCDVappCreationError(Exception): 6 | def __init__(self, msg): 7 | Exception.__init__(self, msg) 8 | 9 | 10 | class VCDLoginError(Exception): 11 | def __init__(self, msg): 12 | Exception.__init__(self, msg) 13 | 14 | 15 | class VDCNotFoundError(Exception): 16 | def __init__(self, msg): 17 | Exception.__init__(self, " VDCNotFoundError [" + msg + "]") 18 | 19 | 20 | class ItemFoundError(Exception): 21 | def __init__(self, msg): 22 | Exception.__init__(self, " ItemFoundError [" + msg + "]") 23 | 24 | 25 | class VCDDiskCreationError(Exception): 26 | def __init__(self, msg): 27 | Exception.__init__(self, msg) 28 | 29 | 30 | class VCDDiskDeletionError(Exception): 31 | def __init__(self, msg): 32 | Exception.__init__(self, msg) 33 | 34 | 35 | class VCDOrgCreationError(Exception): 36 | def __init__(self, msg): 37 | Exception.__init__(self, msg) 38 | 39 | 40 | class VCDOrgDeleteError(Exception): 41 | def __init__(self, msg): 42 | Exception.__init__(self, msg) 43 | 44 | 45 | class APINotImplement(Exception): 46 | def __init__(self, msg): 47 | Exception.__init__(self, msg) 48 | 49 | 50 | class VCDVdcDeleteError(Exception): 51 | def __init__(self, msg): 52 | Exception.__init__(self, msg) 53 | 54 | 55 | class VCDVdcCreateError(Exception): 56 | def __init__(self, msg): 57 | Exception.__init__(self, msg) 58 | 59 | 60 | class VappVmCreateError(Exception): 61 | def __init__(self, msg): 62 | Exception.__init__(self, msg) 63 | 64 | 65 | class VappVmDeleteError(Exception): 66 | def __init__(self, msg): 67 | Exception.__init__(self, msg) 68 | 69 | 70 | class VappVmReloadError(Exception): 71 | def __init__(self, msg): 72 | Exception.__init__(self, msg) 73 | 74 | 75 | class VappVmModifyCPUError(Exception): 76 | def __init__(self, msg): 77 | Exception.__init__(self, msg) 78 | 79 | 80 | class VappVmModifyMemoryError(Exception): 81 | def __init__(self, msg): 82 | Exception.__init__(self, msg) 83 | 84 | 85 | class VappVmUnDeployError(Exception): 86 | def __init__(self, msg): 87 | Exception.__init__(self, msg) 88 | 89 | 90 | class VappVmPowerOnError(Exception): 91 | def __init__(self, msg): 92 | Exception.__init__(self, msg) 93 | 94 | 95 | class VappVmPowerOffError(Exception): 96 | def __init__(self, msg): 97 | Exception.__init__(self, msg) 98 | 99 | 100 | class VappNetworkCreateError(Exception): 101 | def __init__(self, msg): 102 | Exception.__init__(self, msg) 103 | 104 | 105 | class VappUpdateError(Exception): 106 | def __init__(self, msg): 107 | Exception.__init__(self, msg) 108 | -------------------------------------------------------------------------------- /module_utils/vcd_resources_endpoint.py: -------------------------------------------------------------------------------- 1 | NSXT_MANAGER_ENDPOINT = "/api/admin/extension/nsxtManagers" 2 | -------------------------------------------------------------------------------- /modules/vcd_catalog.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | # !/usr/bin/python 5 | 6 | ANSIBLE_METADATA = { 7 | 'metadata_version': '1.1', 8 | 'status': ['preview'], 9 | 'supported_by': 'community' 10 | } 11 | 12 | DOCUMENTATION = ''' 13 | --- 14 | module: vcd_catalog 15 | short_description: Manage catalog's states/operations in vCloud Director 16 | version_added: "2.4" 17 | description: 18 | - Manage catalog's states/operations in vCloud Director 19 | 20 | options: 21 | user: 22 | description: 23 | - vCloud Director user name 24 | required: false 25 | password: 26 | description: 27 | - vCloud Director user password 28 | required: false 29 | host: 30 | description: 31 | - vCloud Director host address 32 | required: false 33 | org: 34 | description: 35 | - Organization name on vCloud Director to access 36 | required: false 37 | api_version: 38 | description: 39 | - Pyvcloud API version 40 | required: false 41 | verify_ssl_certs: 42 | description: 43 | - whether to use secure connection to vCloud Director host 44 | required: false 45 | org_name: 46 | description: 47 | - target org name 48 | - required for service providers to create resources in other orgs 49 | - default value is module level / environment level org 50 | required: false 51 | catalog_name: 52 | description: 53 | - catalog name 54 | required: true 55 | new_catalog_name: 56 | description: 57 | - new catalog name. Used while updating catalog name. 58 | required: false 59 | description: 60 | description: 61 | - description of the catalog 62 | required: false 63 | shared: 64 | description: 65 | - shared state of catalog("true"/"false") 66 | required: false 67 | state: 68 | description: 69 | - state of catalog ('present'/'absent'/'update'). 70 | - One from state or operation has to be provided. 71 | required: false 72 | operation: 73 | description: 74 | - operation to perform on catalog (read/shared/list_items). 75 | - One from state or operation has to be provided. 76 | required: false 77 | 78 | author: 79 | - pcpandey@mail.com 80 | - mtaneja@vmware.com 81 | ''' 82 | 83 | EXAMPLES = ''' 84 | - name: create catalog 85 | vcd_catalog: 86 | catalog_name: "catalog_name" 87 | description: "description" 88 | state: "present" 89 | register: output 90 | ''' 91 | 92 | RETURN = ''' 93 | msg: success/failure message corresponding to catalog state/operation 94 | changed: true if resource has been changed else false 95 | ''' 96 | 97 | from pyvcloud.vcd.org import Org 98 | from pyvcloud.vcd.client import NSMAP 99 | from ansible.module_utils.vcd import VcdAnsibleModule 100 | from pyvcloud.vcd.exceptions import EntityNotFoundException 101 | 102 | 103 | VCD_CATALOG_STATES = ['present', 'absent', 'update'] 104 | VCD_CATALOG_OPERATIONS = ['read', 'shared', 'list_items'] 105 | 106 | 107 | def vcd_catalog_argument_spec(): 108 | return dict( 109 | catalog_name=dict(type='str', required=True), 110 | new_catalog_name=dict(type='str', required=False), 111 | description=dict(type='str', required=False), 112 | shared=dict(type='bool', required=False, default=True), 113 | org_name=dict(type='str', required=False, default=None), 114 | state=dict(choices=VCD_CATALOG_STATES, required=False), 115 | operation=dict(choices=VCD_CATALOG_OPERATIONS, required=False) 116 | ) 117 | 118 | 119 | class Catalog(VcdAnsibleModule): 120 | def __init__(self, **kwargs): 121 | super(Catalog, self).__init__(**kwargs) 122 | self.org = self.get_org() 123 | 124 | def manage_states(self): 125 | state = self.params.get('state') 126 | if state == "present": 127 | return self.create() 128 | 129 | if state == "absent": 130 | return self.delete() 131 | 132 | if state == "update": 133 | return self.update() 134 | 135 | def manage_operations(self): 136 | operation = self.params.get('operation') 137 | if operation == "shared": 138 | return self.shared() 139 | 140 | if operation == "read": 141 | return self.read() 142 | 143 | if operation == "list_items": 144 | return self.list_items() 145 | 146 | def get_org(self): 147 | org_name = self.params.get('org_name') 148 | org_resource = self.client.get_org() 149 | if org_name: 150 | org_resource = self.client.get_org_by_name(org_name) 151 | 152 | return Org(self.client, resource=org_resource) 153 | 154 | def create(self): 155 | catalog_name = self.params.get('catalog_name') 156 | description = self.params.get('description') 157 | response = dict() 158 | response['changed'] = False 159 | 160 | try: 161 | self.org.get_catalog(name=catalog_name) 162 | except EntityNotFoundException: 163 | self.org.create_catalog(name=catalog_name, description=description) 164 | msg = 'Catalog {} has been created.' 165 | response['msg'] = msg.format(catalog_name) 166 | response['changed'] = True 167 | else: 168 | msg = 'Catalog {} is already present.' 169 | response['warnings'] = msg.format(catalog_name) 170 | 171 | return response 172 | 173 | def delete(self): 174 | catalog_name = self.params.get('catalog_name') 175 | response = dict() 176 | response['changed'] = False 177 | 178 | try: 179 | self.org.get_catalog(name=catalog_name) 180 | except EntityNotFoundException: 181 | msg = 'Catalog {} is not present.' 182 | response['warnings'] = msg.format(catalog_name) 183 | else: 184 | self.org.delete_catalog(catalog_name) 185 | msg = 'Catalog {} has been deleted.' 186 | response['msg'] = msg.format(catalog_name) 187 | response['changed'] = True 188 | 189 | return response 190 | 191 | def update(self): 192 | catalog_name = self.params.get('catalog_name') 193 | new_catalog_name = self.params.get('new_catalog_name') 194 | description = self.params.get('description') 195 | response = dict() 196 | response['changed'] = False 197 | 198 | if not new_catalog_name: 199 | new_catalog_name = catalog_name 200 | 201 | self.org.update_catalog(old_catalog_name=catalog_name, 202 | new_catalog_name=new_catalog_name, 203 | description=description) 204 | response['msg'] = 'Catalog {} has been updated.'.format(catalog_name) 205 | response['changed'] = True 206 | 207 | return response 208 | 209 | def shared(self): 210 | catalog_name = self.params.get('catalog_name') 211 | shared = self.params.get('shared') 212 | response = dict() 213 | response['changed'] = False 214 | 215 | self.org.share_catalog(name=catalog_name, share=shared) 216 | msg = 'Catalog {} shared state has been updated to [shared={}].' 217 | response['msg'] = msg.format(catalog_name, shared) 218 | response['changed'] = True 219 | 220 | return response 221 | 222 | def read(self): 223 | catalog_name = self.params.get('catalog_name') 224 | response = dict() 225 | result = dict() 226 | response['changed'] = False 227 | 228 | catalog = self.org.get_catalog(catalog_name) 229 | result['name'] = str(catalog.get("name")) 230 | result['description'] = str(catalog.Description) 231 | result['shared'] = str(catalog.IsPublished) 232 | response['msg'] = result 233 | 234 | return response 235 | 236 | def list_items(self): 237 | catalog_name = self.params.get('catalog_name') 238 | response = dict() 239 | response['changed'] = False 240 | 241 | catalog_items = self.org.list_catalog_items(catalog_name) 242 | response['msg'] = [catalog_item['name'] 243 | for catalog_item in catalog_items] 244 | 245 | return response 246 | 247 | 248 | def main(): 249 | argument_spec = vcd_catalog_argument_spec() 250 | response = dict(msg=dict(type='str')) 251 | module = Catalog(argument_spec=argument_spec, supports_check_mode=True) 252 | 253 | try: 254 | if module.check_mode: 255 | response = dict() 256 | response['changed'] = False 257 | response['msg'] = "skipped, running in check mode" 258 | response['skipped'] = True 259 | elif module.params.get('state'): 260 | response = module.manage_states() 261 | elif module.params.get('operation'): 262 | response = module.manage_operations() 263 | else: 264 | raise Exception('Please provide state/operation for resource') 265 | except Exception as error: 266 | response['msg'] = error.__str__() 267 | module.fail_json(**response) 268 | else: 269 | module.exit_json(**response) 270 | 271 | 272 | if __name__ == '__main__': 273 | main() 274 | -------------------------------------------------------------------------------- /modules/vcd_gateway_services.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | # !/usr/bin/python 5 | 6 | ANSIBLE_METADATA = { 7 | 'metadata_version': '1.1', 8 | 'status': ['preview'], 9 | 'supported_by': 'community' 10 | } 11 | 12 | DOCUMENTATION = ''' 13 | --- 14 | module: vcd_gateway_services 15 | short_description: Manage edge gateway service in vCloud Director 16 | version_added: "2.7" 17 | description: 18 | - Manage edge gateway service in vCloud Director 19 | 20 | options: 21 | user: 22 | description: 23 | - vCloud Director user name 24 | type: str 25 | required: false 26 | password: 27 | description: 28 | - vCloud Director user password 29 | type: str 30 | required: false 31 | host: 32 | description: 33 | - vCloud Director host address 34 | type: str 35 | required: false 36 | org: 37 | description: 38 | - Organization name on vCloud Director to access 39 | type: str 40 | required: false 41 | api_version: 42 | description: 43 | - Pyvcloud API version 44 | type: float 45 | required: false 46 | verify_ssl_certs: 47 | description: 48 | - whether to use secure connection to vCloud Director host 49 | type: bool 50 | required: false 51 | org_name: 52 | description: 53 | - target org name 54 | - required for service providers to create resources in other orgs 55 | - default value is module level / environment level org 56 | required: false 57 | vdc: 58 | description: 59 | - vdc name 60 | required: true 61 | type: str 62 | service: 63 | description: 64 | - The name of the edge gateway service 65 | - supported services are 66 | - firewall 67 | - nat_rule 68 | - static_route 69 | - ssl_certificates 70 | required: true 71 | type: str 72 | service_params: 73 | description: 74 | - A list type respective service parameters 75 | required: false 76 | type: list 77 | state: 78 | description: 79 | - State of the edge gateway service 80 | type: string 81 | required: true 82 | choices: ['present', 'update', 'absent'] 83 | operation: 84 | description: 85 | - Operation on the edge gateway service 86 | type: string 87 | required: false 88 | choices: ['list'] 89 | 90 | author: 91 | - Mukul Taneja 92 | ''' 93 | 94 | EXAMPLES = ''' 95 | - name: create gateway services 96 | vcd_gateway_services: 97 | user: acmeadmin 98 | password: ******* 99 | org: Acme 100 | vdc: ACME_PAYG 101 | gateway: edge-gateway 102 | service: firewall 103 | service_params: 104 | - name: test_firewall 105 | action: accept 106 | type: User 107 | enabled: True 108 | logging_enabled: False 109 | state: present 110 | 111 | ''' 112 | 113 | 114 | RETURN = ''' 115 | msg: success/failure message corresponding to edge gateway state 116 | changed: true if resource has been changed else false 117 | ''' 118 | 119 | from pyvcloud.vcd.org import Org 120 | from pyvcloud.vcd.vdc import VDC 121 | from pyvcloud.vcd.gateway import Gateway 122 | from ansible.module_utils.vcd import VcdAnsibleModule 123 | from pyvcloud.vcd.exceptions import EntityNotFoundException 124 | from ansible.module_utils.gateway_static_route import StaticRoutes 125 | from ansible.module_utils.gateway_nat_rule_service import NatRuleService 126 | from ansible.module_utils.gateway_firewall_service import FirewallService 127 | from ansible.module_utils.gateway_ssl_certificates import SSLCertificates 128 | 129 | 130 | EDGE_SERVICES = ["firewall", "nat_rule", "static_route", "ssl_certificates"] 131 | EDGE_SERVICES_STATES = ['present', 'update', 'absent'] 132 | EDGE_SERVICES_OPERATIONS = ['list'] 133 | 134 | 135 | def vcd_gateway_services_argument_spec(): 136 | return dict( 137 | vdc=dict(type='str', required=True), 138 | gateway=dict(type='str', required=True), 139 | service_params=dict(type='list', required=False), 140 | service=dict(choices=EDGE_SERVICES, required=True), 141 | org_name=dict(type='str', required=False, default=None), 142 | state=dict(choices=EDGE_SERVICES_STATES, required=False), 143 | operation=dict(choices=EDGE_SERVICES_OPERATIONS, required=False) 144 | ) 145 | 146 | 147 | class EdgeServices(VcdAnsibleModule): 148 | def __init__(self, **kwargs): 149 | super(EdgeServices, self).__init__(**kwargs) 150 | self.org = self.get_org() 151 | vdc = self.org.get_vdc(self.params.get('vdc')) 152 | self.vdc = VDC(self.client, href=vdc.get('href')) 153 | 154 | def manage_states(self): 155 | state = self.params.get("state") 156 | if state == "present": 157 | return self.add_service() 158 | 159 | if state == "update": 160 | return self.update_service() 161 | 162 | if state == "absent": 163 | return self.delete_service() 164 | 165 | def manage_operations(self): 166 | operation = self.params.get("operation") 167 | 168 | return self.apply_operation_on_service(operation) 169 | 170 | def get_org(self): 171 | org_name = self.params.get('org_name') 172 | org_resource = self.client.get_org() 173 | if org_name: 174 | org_resource = self.client.get_org_by_name(org_name) 175 | 176 | return Org(self.client, resource=org_resource) 177 | 178 | def get_gateway(self): 179 | gateway_name = self.params.get("gateway") 180 | gateway = self.vdc.get_gateway(gateway_name) 181 | if gateway is None: 182 | msg = "Gateway {0} not found".format(gateway_name) 183 | raise EntityNotFoundException(msg) 184 | 185 | extra_args = {"name": gateway_name, "href": gateway.get("href")} 186 | return Gateway(self.client, **extra_args) 187 | 188 | def add_service(self): 189 | service = self.params.get("service") 190 | service_params = self.params.get("service_params") 191 | if service == "firewall": 192 | service = FirewallService(self.get_gateway(), service_params) 193 | 194 | if service == "nat_rule": 195 | service = NatRuleService(self.get_gateway(), service_params) 196 | 197 | if service == "static_route": 198 | service = StaticRoutes(self.get_gateway(), service_params) 199 | 200 | if service == "ssl_certificates": 201 | service = SSLCertificates(self.get_gateway(), service_params) 202 | 203 | return service.manage_states(state="present") 204 | 205 | def delete_service(self): 206 | service = self.params.get("service") 207 | service_params = self.params.get("service_params") 208 | if service == "firewall": 209 | service = FirewallService(self.get_gateway(), service_params) 210 | 211 | if service == "nat_rule": 212 | service = NatRuleService(self.get_gateway(), service_params) 213 | 214 | if service == "static_route": 215 | service = StaticRoutes(self.get_gateway(), service_params) 216 | 217 | if service == "ssl_certificates": 218 | service = SSLCertificates(self.get_gateway(), service_params) 219 | 220 | return service.manage_states(state="absent") 221 | 222 | def update_service(self): 223 | service = self.params.get("service") 224 | service_params = self.params.get("service_params") 225 | if service == "firewall": 226 | service = FirewallService(self.get_gateway(), service_params) 227 | 228 | if service == "nat_rule": 229 | service = NatRuleService(self.get_gateway(), service_params) 230 | 231 | if service == "static_route": 232 | service = StaticRoutes(self.get_gateway(), service_params) 233 | 234 | return service.manage_states(state="update") 235 | 236 | def apply_operation_on_service(self, operation): 237 | service = self.params.get("service") 238 | if service == "firewall": 239 | service = FirewallService(self.get_gateway()) 240 | 241 | if service == "nat_rule": 242 | service = NatRuleService(self.get_gateway()) 243 | 244 | if service == "static_route": 245 | service = StaticRoutes(self.get_gateway()) 246 | 247 | if service == "ssl_certificates": 248 | service = SSLCertificates(self.get_gateway()) 249 | 250 | return service.manage_operations(operation=operation) 251 | 252 | 253 | def main(): 254 | argument_spec = vcd_gateway_services_argument_spec() 255 | response = dict(msg=dict(type='str')) 256 | module = EdgeServices( 257 | argument_spec=argument_spec, supports_check_mode=True) 258 | 259 | try: 260 | if module.check_mode: 261 | response = dict() 262 | response['changed'] = False 263 | response['msg'] = "skipped, running in check mode" 264 | response['skipped'] = True 265 | elif module.params.get('state'): 266 | response = module.manage_states() 267 | elif module.params.get('operation'): 268 | response = module.manage_operations() 269 | else: 270 | raise Exception('Please provide state for resource') 271 | 272 | except Exception as error: 273 | response['msg'] = error.__str__() 274 | module.fail_json(**response) 275 | else: 276 | module.exit_json(**response) 277 | 278 | 279 | if __name__ == '__main__': 280 | main() 281 | -------------------------------------------------------------------------------- /modules/vcd_resources.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | # !/usr/bin/python 5 | 6 | ANSIBLE_METADATA = { 7 | 'metadata_version': '1.1', 8 | 'status': ['preview'], 9 | 'supported_by': 'community' 10 | } 11 | 12 | DOCUMENTATION = ''' 13 | --- 14 | module: vcd_resources 15 | short_description: Add/Delete/Update VCD Infrastructure resources 16 | version_added: "2.4" 17 | description: 18 | - Add/Delete/Update VCD Infrastructure resources 19 | 20 | options: 21 | user: 22 | description: 23 | - vCloud Director user name 24 | required: false 25 | password: 26 | description: 27 | - vCloud Director user password 28 | required: false 29 | host: 30 | description: 31 | - vCloud Director host address 32 | required: false 33 | org: 34 | description: 35 | - Organization name on vCloud Director to access 36 | required: false 37 | api_version: 38 | description: 39 | - Pyvcloud API version 40 | required: false 41 | verify_ssl_certs: 42 | description: 43 | - whether to use secure connection to vCloud Director host 44 | required: false 45 | nsxts: 46 | description: 47 | - List of network type of Infrastructure resource 48 | required: true 49 | state: 50 | description: 51 | - state of vcd resource ('present'/'absent'/'update'). 52 | required: false 53 | operation: 54 | description: 55 | - operations on vcd resource ('read'). 56 | required: false 57 | 58 | author: 59 | - mtaneja@vmware.com 60 | ''' 61 | 62 | EXAMPLES = ''' 63 | - name: add vcd resources 64 | vcd_resources 65 | nsxt: 66 | url: "" 67 | username: "" 68 | password: "" 69 | networkProviderScope: "" 70 | state: "present" 71 | register: output 72 | ''' 73 | 74 | RETURN = ''' 75 | msg: success/failure message corresponding to resource state 76 | changed: true if resource has been changed 77 | ''' 78 | 79 | from ansible.module_utils.vcd import VcdAnsibleModule 80 | from pyvcloud.vcd.nsxt_extension import NsxtExtension 81 | from pyvcloud.vcd.exceptions import EntityNotFoundException 82 | 83 | VCD_RESOURCES_STATES = ['present', 'absent', 'update'] 84 | VCD_RESOURCES_OPERATIONS = ['list'] 85 | 86 | 87 | def vcd_resources_argument_spec(): 88 | return dict( 89 | nsxts=dict(type='list', required=False), 90 | state=dict(choices=VCD_RESOURCES_STATES, required=False), 91 | operation=dict(choices=VCD_RESOURCES_OPERATIONS, required=False) 92 | ) 93 | 94 | 95 | class VcdResources(VcdAnsibleModule): 96 | def __init__(self, **kwargs): 97 | super(VcdResources, self).__init__(**kwargs) 98 | self.nsxt_extension = NsxtExtension(self.client) 99 | 100 | def manage_states(self): 101 | state = self.params.get('state') 102 | if state == "present": 103 | return self.add() 104 | 105 | if state == "absent": 106 | return self.delete() 107 | 108 | if state == "update": 109 | return self.update() 110 | 111 | def manage_operations(self): 112 | operation = self.params.get('operation') 113 | if operation == "list": 114 | return self.list() 115 | 116 | def get(self, name): 117 | return self.nsxt_extension.get(name) 118 | 119 | def add(self): 120 | nsxts = self.params.get('nsxts') 121 | response = dict() 122 | response['changed'] = False 123 | response['msg'] = list() 124 | 125 | for nsxt in nsxts: 126 | try: 127 | name = nsxt.get('name') 128 | self.get(name) 129 | response['msg'].append('Nsx-T manager {0} is already exists'.format(name)) 130 | except EntityNotFoundException: 131 | url = nsxt.get('url') 132 | username = nsxt.get('username') 133 | password = nsxt.get('password') 134 | self.nsxt_extension.add(name, url, username, password) 135 | response['msg'].append('NSX-T Manager {0} is added'.format(name)) 136 | response['changed'] = True 137 | 138 | return response 139 | 140 | def delete(self): 141 | nsxts = self.params.get('nsxts') 142 | response = dict() 143 | response['changed'] = False 144 | response['msg'] = list() 145 | 146 | for nsxt in nsxts: 147 | try: 148 | name = nsxt.get('name') 149 | self.get(name) 150 | self.nsxt_extension.delete(name) 151 | response['msg'].append('NSX-T Manager {0} is deleted'.format(name)) 152 | response['changed'] = True 153 | except EntityNotFoundException: 154 | response['msg'].append('NSX-T Manager {0} is not present'.format(name)) 155 | 156 | 157 | return response 158 | 159 | def update(self): 160 | nsxts = self.params.get('nsxts') 161 | response = dict() 162 | response['changed'] = False 163 | response['msg'] = list() 164 | 165 | for nsxt in nsxts: 166 | try: 167 | name = nsxt.get('name') 168 | self.get(name) 169 | new_name = nsxt.get('new_name') 170 | url = nsxt.get('url') 171 | username = nsxt.get('username') 172 | password = nsxt.get('password') 173 | self.nsxt_extension.update(name, new_name, url, username, password) 174 | response['msg'].append('NSX-T Manager {0} is updated'.format(name)) 175 | response['changed'] = True 176 | except EntityNotFoundException: 177 | response['msg'].append('NSX-T Manager {0} is not present'.format(name)) 178 | 179 | return response 180 | 181 | def list(self): 182 | response = dict() 183 | response['changed'] = False 184 | response['msg'] = list() 185 | 186 | for nsxt_manager in self.nsxt_extension.list(): 187 | response['msg'].append({ 188 | 'name': nsxt_manager.get('name'), 189 | 'url': str(nsxt_manager.Url), 190 | 'version': str(nsxt_manager.Version), 191 | 'deployment_type': str(nsxt_manager.DeploymentType) 192 | }) 193 | 194 | return response 195 | 196 | 197 | def main(): 198 | argument_spec = vcd_resources_argument_spec() 199 | response = dict(msg=dict(type='str')) 200 | module = VcdResources(argument_spec=argument_spec, supports_check_mode=True) 201 | 202 | try: 203 | if module.check_mode: 204 | response = dict() 205 | response['changed'] = False 206 | response['msg'] = "skipped, running in check mode" 207 | response['skipped'] = True 208 | elif module.params.get('state'): 209 | response = module.manage_states() 210 | elif module.params.get('operation'): 211 | response = module.manage_operations() 212 | else: 213 | raise Exception('Please provide state/operation for resource') 214 | except Exception as error: 215 | response['msg'] = error.__str__() 216 | module.fail_json(**response) 217 | else: 218 | module.exit_json(**response) 219 | 220 | 221 | if __name__ == '__main__': 222 | main() 223 | -------------------------------------------------------------------------------- /modules/vcd_roles.py: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | # !/usr/bin/python 5 | 6 | ANSIBLE_METADATA = { 7 | 'metadata_version': '1.1', 8 | 'status': ['preview'], 9 | 'supported_by': 'community' 10 | } 11 | 12 | DOCUMENTATION = ''' 13 | --- 14 | module: vcd_roles 15 | short_description: Manage role's states/operations in vCloud Director 16 | version_added: "2.4" 17 | description: 18 | - Manage role's states/operations in vCloud Director 19 | 20 | options: 21 | user: 22 | description: 23 | - vCloud Director user name 24 | type: str 25 | password: 26 | description: 27 | - vCloud Director user password 28 | type: str 29 | host: 30 | description: 31 | - vCloud Director host address 32 | type: str 33 | org: 34 | description: 35 | - Organization name on vCloud Director to access 36 | type: str 37 | api_version: 38 | description: 39 | - Pyvcloud API version, required as float i.e 31 => 31.0 40 | type: float 41 | verify_ssl_certs: 42 | description: 43 | - whether to use secure connection to vCloud Director host 44 | type: bool 45 | org_name: 46 | description: 47 | - target org name 48 | - required for service providers to create resources in other orgs 49 | - default value is module level / environment level org 50 | required: false 51 | role_name: 52 | description: 53 | - The name of the role 54 | type: str 55 | role_description: 56 | description: 57 | - The description of the role 58 | type: str 59 | role_rights: 60 | description: 61 | - list of rights attached to the new role 62 | type: list 63 | state: 64 | description: 65 | - state of new role ('present'/'absent'/'update'). 66 | - One from state or operation has to be provided. 67 | type: str 68 | choices: ['present', 'absent', 'update'] 69 | operation: 70 | description: 71 | - list operations on available roles & rights inside an org 72 | type: str 73 | choices: ['list_roles', 'list_rights'] 74 | 75 | author: 76 | - mtaneja@vmware.com 77 | ''' 78 | 79 | EXAMPLES = ''' 80 | - name: Test with a message 81 | vcd_org_vdc: 82 | user: terraform 83 | password: abcd 84 | host: csa.sandbox.org 85 | org: Terraform 86 | api_version: 30.0 87 | verify_ssl_certs: False 88 | role_name: sample_role 89 | role_description: sample role 90 | role_rights: 91 | - "Catalog: Import Media from vSphere" 92 | state: "present" 93 | ''' 94 | 95 | RETURN = ''' 96 | msg: success/failure message corresponding to roles state/operation 97 | changed: true if resource has been changed else false 98 | ''' 99 | 100 | 101 | from pyvcloud.vcd.org import Org 102 | from pyvcloud.vcd.vdc import VDC 103 | from pyvcloud.vcd.client import E 104 | from pyvcloud.vcd.system import System 105 | from pyvcloud.vcd.client import EntityType 106 | from pyvcloud.vcd.client import RelationType 107 | from ansible.module_utils.vcd import VcdAnsibleModule 108 | from pyvcloud.vcd.exceptions import EntityNotFoundException 109 | 110 | 111 | VCD_ROLE_STATES = ['present', 'absent', 'update'] 112 | VCD_ROLE_OPERATIONS = ['list_rights', 'list_roles'] 113 | 114 | 115 | def vcd_roles_argument_spec(): 116 | return dict( 117 | role_name=dict(type='str', required=False), 118 | role_description=dict(type='str', required=False, default=''), 119 | role_rights=dict(type='list', required=False), 120 | org_name=dict(type='str', required=False, default=None), 121 | state=dict(choices=VCD_ROLE_STATES, required=False), 122 | operation=dict(choices=VCD_ROLE_OPERATIONS, required=False), 123 | ) 124 | 125 | 126 | class Roles(VcdAnsibleModule): 127 | def __init__(self, **kwargs): 128 | super(Roles, self).__init__(**kwargs) 129 | self.org = self.get_org() 130 | 131 | def manage_states(self): 132 | state = self.params.get('state') 133 | if state == 'present': 134 | return self.create() 135 | 136 | if state == 'absent': 137 | return self.delete() 138 | 139 | if state == 'update': 140 | return self.update() 141 | 142 | def manage_operations(self): 143 | operation = self.params.get('operation') 144 | if operation == "list_rights": 145 | return self.list_rights() 146 | 147 | if operation == "list_roles": 148 | return self.list_roles() 149 | 150 | def get_org(self): 151 | org_name = self.params.get('org_name') 152 | org_resource = self.client.get_org() 153 | if org_name: 154 | org_resource = self.client.get_org_by_name(org_name) 155 | 156 | return Org(self.client, resource=org_resource) 157 | 158 | def create(self): 159 | role_name = self.params.get('role_name') 160 | role_description = self.params.get('role_description') 161 | role_rights = self.params.get('role_rights') 162 | response = dict() 163 | response['changed'] = False 164 | 165 | try: 166 | self.org.get_role_record(role_name) 167 | except EntityNotFoundException: 168 | self.org.create_role(role_name, role_description, role_rights) 169 | response['msg'] = 'Role {} has been created'.format(role_name) 170 | response['changed'] = True 171 | else: 172 | response['warnings'] = 'Role {} is already present'.format(role_name) 173 | 174 | return response 175 | 176 | def update(self): 177 | role_name = self.params.get('role_name') 178 | role_description = self.params.get('role_description') 179 | role_rights = self.params.get('role_rights') 180 | response = dict() 181 | response['changed'] = False 182 | 183 | role = self.org.get_role_record(role_name) 184 | role_resource = self.org.get_role_resource(role_name) 185 | role_resource.Description = E.Description(role_description) 186 | role_rights = tuple() if role_rights is None else role_rights 187 | 188 | for role_right in tuple(role_rights): 189 | role_right_record = self.org.get_right_record(role_right) 190 | role_resource.RightReferences.append( 191 | E.RightReference( 192 | name=role_right_record.get('name'), 193 | href=role_right_record.get('href'), 194 | type=EntityType.RIGHT.value)) 195 | 196 | self.client.put_resource( 197 | role.get('href'), role_resource, EntityType.ROLE.value) 198 | response['msg'] = 'Role {} has been updated.'.format(role_name) 199 | response['changed'] = True 200 | 201 | return response 202 | 203 | def delete(self): 204 | role_name = self.params.get('role_name') 205 | response = dict() 206 | response['changed'] = False 207 | 208 | try: 209 | self.org.get_role_record(role_name) 210 | self.org.delete_role(role_name) 211 | response['msg'] = 'Role {} has been deleted'.format(role_name) 212 | response['changed'] = True 213 | except EntityNotFoundException: 214 | response['warnings'] = 'Role {} is not present'.format(role_name) 215 | 216 | return response 217 | 218 | def list_rights(self): 219 | response = dict() 220 | response['changed'] = False 221 | response['msg'] = self.org.list_rights_of_org() 222 | 223 | return response 224 | 225 | def list_roles(self): 226 | response = dict() 227 | response['changed'] = False 228 | response['msg'] = self.org.list_roles() 229 | 230 | return response 231 | 232 | 233 | def main(): 234 | argument_spec = vcd_roles_argument_spec() 235 | response = dict(msg=dict(type='str')) 236 | module = Roles(argument_spec=argument_spec, supports_check_mode=True) 237 | 238 | try: 239 | if module.check_mode: 240 | response = dict() 241 | response['changed'] = False 242 | response['msg'] = "skipped, running in check mode" 243 | response['skipped'] = True 244 | elif module.params.get("state"): 245 | response = module.manage_states() 246 | elif module.params.get("operation"): 247 | response = module.manage_operations() 248 | else: 249 | raise Exception("Please provide state/operation for resource") 250 | 251 | except Exception as error: 252 | response['msg'] = error.__str__() 253 | module.fail_json(**response) 254 | else: 255 | module.exit_json(**response) 256 | 257 | 258 | if __name__ == '__main__': 259 | main() 260 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyvcloud 2 | lxml 3 | requests -------------------------------------------------------------------------------- /roles/catalog_item/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/catalog_item/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # defaults file for roles/catalog_item -------------------------------------------------------------------------------- /roles/catalog_item/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # handlers file for roles/catalog_item -------------------------------------------------------------------------------- /roles/catalog_item/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/catalog_item/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # tasks file for roles/catalog_item 6 | 7 | ############################################ upload-media ############################################################## 8 | - name: upload media 9 | vcd_catalog_item: 10 | catalog_name: "{{ catalog_name }}" 11 | item_name: "{{ media_item_name }}" 12 | file_name : "{{ media_file_name }}" 13 | chunk_size: "{{ chunk_size }}" 14 | state: "present" 15 | register: output 16 | 17 | - name: upload media output 18 | debug: 19 | msg: '{{ output }}' 20 | 21 | # ############################################ delete-media ############################################################## 22 | - name: delete media 23 | vcd_catalog_item: 24 | catalog_name: "{{ catalog_name }}" 25 | item_name: "{{ media_item_name }}" 26 | state: "absent" 27 | register: output 28 | 29 | - name: delete media output 30 | debug: 31 | msg: '{{ output }}' 32 | 33 | 34 | ############################################ upload-ova ############################################################## 35 | - name: upload ova 36 | vcd_catalog_item: 37 | user: 'XXXXXXXXXX' 38 | org: 'XXXXXXXXXX' 39 | password: 'XXXXXXXXXX' 40 | host: 'XXXXXXXXXX' 41 | catalog_name: "{{ catalog_name }}" 42 | item_name: "{{ ova_item_name }}" 43 | file_name : "{{ ova_file_name }}" 44 | chunk_size: "{{ chunk_size }}" 45 | state: "present" 46 | register: output 47 | 48 | - name: upload ova output 49 | debug: 50 | msg: '{{ output }}' 51 | 52 | ############################################ delete-ova ############################################################## 53 | - name: delete ova 54 | vcd_catalog_item: 55 | catalog_name: "{{ catalog_name }}" 56 | item_name: "{{ ova_item_name }}" 57 | state: "absent" 58 | register: output 59 | 60 | - name: delete ova output 61 | debug: 62 | msg: '{{ output }}' 63 | 64 | ############################################ capture-vapp ############################################################## 65 | - name: capture vapp 66 | vcd_catalog_item: 67 | user: 'XXXXXXXXXX' 68 | org: 'XXXXXXXXXX' 69 | password: 'XXXXXXXXXX' 70 | host: 'XXXXXXXXXX' 71 | catalog_name: "{{ catalog_name }}" 72 | item_name: "{{ capture_vapp_item_name }}" 73 | vapp_name: "{{ vapp_name }}" 74 | vdc_name: "{{ vdc_name }}" 75 | description: "{{ description }}" 76 | customize_on_instantiate: "{{ customize_on_instantiate }}" 77 | overwrite: "{{ overwrite }}" 78 | operation: "capturevapp" 79 | register: output 80 | 81 | - name: capture vapp output 82 | debug: 83 | msg: '{{ output }}' 84 | 85 | ############################################ delete-capture-vapp ############################################################## 86 | - name: delete capture-vapp 87 | vcd_catalog_item: 88 | user: 'XXXXXXXXXX' 89 | org: 'XXXXXXXXXX' 90 | password: 'XXXXXXXXXX' 91 | host: 'XXXXXXXXXX' 92 | catalog_name: "{{ catalog_name }}" 93 | item_name: "{{ capture_vapp_item_name }}" 94 | state: "absent" 95 | register: output 96 | 97 | - name: delete capture-vapp output 98 | debug: 99 | msg: '{{ output }}' 100 | 101 | ############################################ list-vms ############################################################## 102 | - name: list catalog item vms 103 | vcd_catalog_item: 104 | user: 'XXXXXXXXXX' 105 | org: 'XXXXXXXXXX' 106 | password: 'XXXXXXXXXX' 107 | host: 'XXXXXXXXXX' 108 | catalog_name: "{{ catalog_name }}" 109 | item_name: "{{ capture_vapp_item_name }}" 110 | operation: "list_vms" 111 | register: output 112 | 113 | - name: list catalog item vms output 114 | debug: 115 | msg: '{{ output }}' 116 | -------------------------------------------------------------------------------- /roles/catalog_item/tests/inventory: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | localhost 5 | 6 | -------------------------------------------------------------------------------- /roles/catalog_item/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | - hosts: localhost 6 | remote_user: root 7 | roles: 8 | - roles/catalog_item -------------------------------------------------------------------------------- /roles/catalog_item/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # vars file for roles/catalog_item 6 | 7 | catalog_name: "test_catalog_100" 8 | chunk_size: 1048576 9 | 10 | # for media 11 | media_item_name: "test_item_media_100" 12 | media_file_name: "/home/parkash/workspace/vmware/Ansible/official/media/test_vapp_template.zip" 13 | 14 | # for ova 15 | ova_item_name: "test_item_ova_100" 16 | ova_file_name: "/Users/mtaneja/Downloads/Tiny Linux VM.ovf" 17 | 18 | # for capture vapp 19 | capture_vapp_item_name: "test_item_capture_100" 20 | vapp_name: "VM1" 21 | vdc_name: "ACME_PAYG" 22 | description: "capture_vapp_desc" 23 | customize_on_instantiate: false 24 | overwrite: false -------------------------------------------------------------------------------- /roles/catalogs/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/catalogs/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # defaults file for roles/catalogs -------------------------------------------------------------------------------- /roles/catalogs/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # handlers file for roles/catalogs -------------------------------------------------------------------------------- /roles/catalogs/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (GPLv2, CC-BY, etc) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. -------------------------------------------------------------------------------- /roles/catalogs/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | #tasks file for roles/catalogs 6 | 7 | #################################### Create ########################################################################## 8 | - name: create catalog 9 | vcd_catalog: 10 | user: 'XXXXXXXXXX' 11 | org: 'XXXXXXXXXX' 12 | password: 'XXXXXXXXXX' 13 | host: 'XXXXXXXXXX' 14 | catalog_name: "{{ catalog_name }}" 15 | description: "{{ description }}" 16 | state: "present" 17 | register: output 18 | 19 | - name: create catalog output 20 | debug: 21 | msg: '{{ output }}' 22 | 23 | #################################### Read-Catalog ########################################################################## 24 | 25 | - name: read catalog 26 | vcd_catalog: 27 | user: 'XXXXXXXXXX' 28 | org: 'XXXXXXXXXX' 29 | password: 'XXXXXXXXXX' 30 | host: 'XXXXXXXXXX' 31 | catalog_name: "{{ catalog_name }}" 32 | operation: "read" 33 | register: output 34 | 35 | - name: Read catalog output 36 | debug: 37 | msg: '{{ output }}' 38 | 39 | 40 | #################################### Update-Name-And description ########################################################################## 41 | 42 | - name: update catalog name and description 43 | vcd_catalog: 44 | user: 'XXXXXXXXXX' 45 | org: 'XXXXXXXXXX' 46 | password: 'XXXXXXXXXX' 47 | host: 'XXXXXXXXXX' 48 | catalog_name: "{{ catalog_name }}" 49 | new_catalog_name: "{{ new_catalog_name }}" 50 | description: "{{ description }}" 51 | state: "update" 52 | register: output 53 | 54 | - name: Update Catalog name and description output 55 | debug: 56 | msg: '{{ output }}' 57 | 58 | #################################### shared/unshare-catalog ########################################################################## 59 | 60 | - name: share/unshare catalog 61 | vcd_catalog: 62 | user: 'XXXXXXXXXX' 63 | org: 'XXXXXXXXXX' 64 | password: 'XXXXXXXXXX' 65 | host: 'XXXXXXXXXX' 66 | catalog_name: "{{ new_catalog_name }}" 67 | shared: "{{ shared }}" 68 | operation: "shared" 69 | register: output 70 | 71 | - name: share/unshare catalog output 72 | debug: 73 | msg: '{{ output }}' 74 | 75 | #################################### Delete ########################################################################## 76 | - name: delete catalog 77 | vcd_catalog: 78 | user: 'XXXXXXXXXX' 79 | org: 'XXXXXXXXXX' 80 | password: 'XXXXXXXXXX' 81 | host: 'XXXXXXXXXX' 82 | catalog_name: "{{ new_catalog_name }}" 83 | state: "absent" 84 | register: output 85 | 86 | - name: delete catalog output 87 | debug: 88 | msg: '{{ output }}' 89 | 90 | #################################### List items ########################################################################## 91 | - name: list catalog items 92 | vcd_catalog: 93 | user: 'XXXXXXXXXX' 94 | org: 'XXXXXXXXXX' 95 | password: 'XXXXXXXXXX' 96 | host: 'XXXXXXXXXX' 97 | catalog_name: "{{ new_catalog_name }}" 98 | operation: "list_items" 99 | register: output 100 | 101 | - name: list catalog items output 102 | debug: 103 | msg: '{{ output }}' 104 | -------------------------------------------------------------------------------- /roles/catalogs/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/catalogs/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | - hosts: localhost 6 | remote_user: root 7 | roles: 8 | - roles/catalogs -------------------------------------------------------------------------------- /roles/catalogs/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # vars file for roles/catalogs 6 | catalog_name: test_catalog_104 7 | description: test_catalog_description_104 8 | new_catalog_name: test_catalog_105 9 | 10 | shared: true -------------------------------------------------------------------------------- /roles/disk/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/disk/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for roles/disk -------------------------------------------------------------------------------- /roles/disk/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for roles/disk -------------------------------------------------------------------------------- /roles/disk/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/disk/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for roles/disk 5 | 6 | - name: create disk 7 | vcd_disk: 8 | disk_name: "{{ disk_name }}" 9 | description: "Test Disk" 10 | size: "100" 11 | vdc: "Terraform_VDC" 12 | storage_profile: "Standard" 13 | state: "present" 14 | register: output 15 | 16 | - name: create disk output 17 | debug: 18 | msg: '{{ output }}' 19 | 20 | - name: update disk 21 | vcd_disk: 22 | disk_name: "{{ disk_name }}" 23 | new_disk_name: "{{ updated_disk_name }}" 24 | new_size: "200" 25 | vdc: "Terraform_VDC" 26 | new_storage_profile: "Standard" 27 | state: "update" 28 | register: output 29 | 30 | - name: update disk output 31 | debug: 32 | msg: '{{ output }}' 33 | 34 | - name: delete disk 35 | vcd_disk: 36 | disk_name: "{{ updated_disk_name }}" 37 | description: "Test Disk" 38 | vdc: "Terraform_VDC" 39 | state: "absent" 40 | register: output 41 | 42 | - name: delete disk output 43 | debug: 44 | msg: '{{ output }}' 45 | -------------------------------------------------------------------------------- /roles/disk/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/disk/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/disk 8 | -------------------------------------------------------------------------------- /roles/disk/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/disk 5 | 6 | disk_name: "test_disk" 7 | updated_disk_name: "test_disk_2" 8 | -------------------------------------------------------------------------------- /roles/org/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/org/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # defaults file for roles/org -------------------------------------------------------------------------------- /roles/org/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # handlers file for roles/org -------------------------------------------------------------------------------- /roles/org/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/org/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | # --- 5 | # tasks file for roles/org 6 | 7 | --- 8 | # tasks file for org 9 | 10 | - name: create org 11 | vcd_org: 12 | org_name: acme_sample 13 | full_name: acme_sample 14 | is_enabled: true 15 | state: present 16 | register: output 17 | 18 | - name: create org output 19 | debug: 20 | msg: '{{ output }}' 21 | 22 | - name: update org 23 | vcd_org: 24 | org_name: acme_sample 25 | is_enabled: false 26 | state: update 27 | register: output 28 | 29 | - name: update org output 30 | debug: 31 | msg: '{{ output }}' 32 | 33 | - name: read org 34 | vcd_org: 35 | org_name: acme_sample 36 | is_enabled: true 37 | operation: read 38 | register: output 39 | 40 | - name: read org output 41 | debug: 42 | msg: '{{ output }}' 43 | 44 | - name: add rights to org 45 | vcd_org: 46 | org_name: acme_sample 47 | org_rights: 48 | - "Catalog: Import Media from vSphere" 49 | operation: add_rights 50 | register: output 51 | 52 | - name: add rights output 53 | debug: 54 | msg: '{{ output }}' 55 | 56 | - name: list rights of org 57 | vcd_org: 58 | org_name: acme_sample 59 | operation: list_rights 60 | register: output 61 | 62 | - name: add rights output 63 | debug: 64 | msg: ' {{ output }}' 65 | 66 | - name: list roles 67 | vcd_org: 68 | org_name: acme_sample 69 | operation: list_roles 70 | register: output 71 | 72 | - name: list roles output 73 | debug: 74 | msg: '{{ output }}' 75 | 76 | - name: list vdcs 77 | vcd_org: 78 | org_name: Acme 79 | operation: list_vdcs 80 | register: output 81 | 82 | - name: list vdcs output 83 | debug: 84 | msg: '{{ output }}' 85 | 86 | - name: delete org 87 | vcd_org: 88 | org_name: acme_sample 89 | state: absent 90 | register: output 91 | 92 | - name: delete org output 93 | debug: 94 | msg: '{{ output }}' 95 | -------------------------------------------------------------------------------- /roles/org/tests/inventory: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | localhost 5 | 6 | -------------------------------------------------------------------------------- /roles/org/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/org 8 | -------------------------------------------------------------------------------- /roles/org/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/org 5 | 6 | org_name: "test_org_100" 7 | org_full_name: "test_org_full_name_100" 8 | 9 | #org enabled 10 | is_enabled: True 11 | 12 | #Force delete org 13 | force: True 14 | 15 | #Recursive delete org 16 | recursive: True 17 | -------------------------------------------------------------------------------- /roles/user/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/user/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/user 5 | -------------------------------------------------------------------------------- /roles/user/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/user 5 | -------------------------------------------------------------------------------- /roles/user/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/user/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for roles/user 5 | 6 | - name: create user 7 | no_log: False 8 | vcd_user: 9 | username: "{{ username }}" 10 | userpassword: test_password 11 | role_name: "Organization Administrator" 12 | state: "present" 13 | register: output 14 | 15 | - name: create user output 16 | debug: 17 | msg: '{{ output }}' 18 | 19 | - name: update user 20 | no_log: False 21 | vcd_user: 22 | username: "{{ username }}" 23 | is_enabled: "true" 24 | state: "update" 25 | register: output 26 | 27 | - name: update user output 28 | debug: 29 | msg: '{{ output }}' 30 | 31 | - name: delete user 32 | no_log: False 33 | vcd_user: 34 | username: "{{ username }}" 35 | state: "absent" 36 | register: output 37 | 38 | - name: delete user output 39 | debug: 40 | msg: '{{ output }}' 41 | -------------------------------------------------------------------------------- /roles/user/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/user/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/user 8 | -------------------------------------------------------------------------------- /roles/user/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/user 5 | username: test_user 6 | -------------------------------------------------------------------------------- /roles/vapp/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vapp/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/vapp 5 | -------------------------------------------------------------------------------- /roles/vapp/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/vapp 5 | -------------------------------------------------------------------------------- /roles/vapp/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/vapp/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for roles/vapp 5 | - name: instantiate vapp 6 | vcd_vapp: 7 | vapp_name: test_vapp_1 8 | template_name: centos 9 | catalog_name: test_catalog_300 10 | vdc: ACME_PAYG 11 | power_on: False 12 | storage_profile: Standard 13 | state: present 14 | register: output 15 | 16 | - name: instantiate vapp output 17 | debug: 18 | msg: '{{ output }}' 19 | 20 | - name: create vapp 21 | vcd_vapp: 22 | vapp_name: test_vapp_1 23 | vdc: ACME_PAYG 24 | power_on: False 25 | state: present 26 | register: output 27 | 28 | - name: create vapp output 29 | debug: 30 | msg: '{{ output }}' 31 | 32 | - name: power on vapp 33 | vcd_vapp: 34 | vapp_name: test_vapp_1 35 | vdc: ACME_PAYG 36 | operation: poweron 37 | register: output 38 | 39 | - name: power on vapp output 40 | debug: 41 | msg: '{{ output }}' 42 | 43 | - name: power on vapp 44 | vcd_vapp: 45 | vapp_name: test_vapp_1 46 | vdc: ACME_PAYG 47 | operation: poweron 48 | register: output 49 | 50 | - name: power on vapp output 51 | debug: 52 | msg: '{{ output }}' 53 | 54 | - name: power off vapp 55 | vcd_vapp: 56 | vapp_name: test_vapp_1 57 | vdc: ACME_PAYG" 58 | operation: poweroff 59 | register: output 60 | 61 | - name: power off vapp output 62 | debug: 63 | msg: '{{ output }}' 64 | 65 | - name: power off vapp 66 | vcd_vapp: 67 | vapp_name: test_vapp_1 68 | vdc: ACME_PAYG 69 | operation: poweroff 70 | register: output 71 | 72 | - name: power off vapp output 73 | debug: 74 | msg: '{{ output }}' 75 | 76 | - name: undeploy vapp 77 | vcd_vapp: 78 | vapp_name: test_vapp_1 79 | vdc: ACME_PAYG 80 | operation: undeploy 81 | register: output 82 | 83 | - name: undeploy vapp output 84 | debug: 85 | msg: '{{ output }}' 86 | 87 | - name: undeploy vapp 88 | vcd_vapp: 89 | vapp_name: test_vapp_1 90 | vdc: ACME_PAYG 91 | operation: undeploy 92 | register: output 93 | 94 | - name: undeploy vapp output 95 | debug: 96 | msg: '{{ output }}' 97 | 98 | - name: deploy vapp 99 | vcd_vapp: 100 | vapp_name: test_vapp_1 101 | vdc: ACME_PAYG 102 | operation: deploy 103 | register: output 104 | 105 | - name: deploy vapp output 106 | debug: 107 | msg: '{{ output }}' 108 | 109 | - name: deploy vapp 110 | vcd_vapp: 111 | vapp_name: test_vapp_1 112 | vdc: ACME_PAYG 113 | operation: deploy 114 | register: output 115 | 116 | - name: deploy vapp output 117 | debug: 118 | msg: '{{ output }}' 119 | 120 | - name: get list of vms 121 | vcd_vapp: 122 | vapp_name: test_vapp_1 123 | vdc: ACME_PAYG 124 | operation: list_vms 125 | register: output 126 | 127 | - name: get list of vms output 128 | debug: 129 | msg: '{{ output }}' 130 | 131 | - name: get list of networks 132 | vcd_vapp: 133 | vapp_name: test_vapp_1 134 | vdc: ACME_PAYG 135 | operation: list_networks 136 | register: output 137 | 138 | - name: get list of networks output 139 | debug: 140 | msg: '{{ output }}' 141 | 142 | - name: share vapp 143 | vcd_vapp: 144 | user: acmeadmin 145 | password: XXXXXXXXXX 146 | org: Acme 147 | vapp_name: test_vapp 148 | vdc: ACME_PAYG 149 | operation: share 150 | register: output 151 | 152 | - name: share vapp output 153 | debug: 154 | msg: '{{ output }}' 155 | 156 | - name: unshare vapp 157 | vcd_vapp: 158 | user: acmeadmin 159 | password: XXXXXXXXXX 160 | org: Acme 161 | vapp_name: acme_vapp 162 | vdc: ACME_PAYG 163 | operation: unshare 164 | register: output 165 | 166 | - name: unshare vapp output 167 | debug: 168 | msg: '{{ output }}' 169 | 170 | - name: set vapp metadata 171 | vcd_vapp: 172 | user: acmeadmin 173 | password: XXXXXXXXXX 174 | org: Acme 175 | vapp_name: acme_vapp 176 | vdc: ACME_PAYG 177 | metadata: 178 | sample7: sample-value4 179 | sample8: sample-value4 180 | sample9: sample-value4 181 | operation: set_meta 182 | register: output 183 | 184 | - name: set vapp metadata output 185 | debug: 186 | msg: '{{ output }}' 187 | 188 | - name: get vapp metadata 189 | vcd_vapp: 190 | user: acmeadmin 191 | password: XXXXXXXXXX 192 | org: Acme 193 | vapp_name: acme_vapp 194 | vdc: ACME_PAYG 195 | operation: get_meta 196 | register: output 197 | 198 | - name: get vapp metadata output 199 | debug: 200 | msg: '{{ output }}' 201 | 202 | - name: remove vapp metadata 203 | vcd_vapp: 204 | user: acmeadmin 205 | password: XXXXXXXXXX 206 | org: Acme 207 | vapp_name: acme_vapp 208 | vdc: ACME_PAYG 209 | metadata: 210 | sample7: sample-value4 211 | sample8: sample-value4 212 | sample9: sample-value4 213 | operation: remove_meta 214 | register: output 215 | 216 | - name: remove vapp metadata output 217 | debug: 218 | msg: '{{ output }}' 219 | 220 | - name: add org network 221 | vcd_vapp: 222 | user: acmeadmin 223 | password: XXXXXXXXXX 224 | org: Acme 225 | vapp_name: acme_vapp 226 | vdc: ACME_PAYG 227 | network: acme_internal_direct_2 228 | operation: add_org_network 229 | register: output 230 | 231 | - name: add org network 232 | debug: 233 | msg: '{{ output }}' 234 | 235 | - name: delete org network 236 | vcd_vapp: 237 | user: acmeadmin 238 | password: XXXXXXXXXX 239 | org: Acme 240 | vapp_name: acme_vapp 241 | vdc: ACME_PAYG 242 | network: acme_internal_direct_2 243 | operation: delete_org_network 244 | register: output 245 | 246 | - name: delete org network 247 | debug: 248 | msg: '{{ output }}' 249 | 250 | - name: delete vapp 251 | vcd_vapp: 252 | vapp_name: test_vapp_1 253 | vdc: ACME_PAYG 254 | force: true 255 | state: absent 256 | register: output 257 | 258 | - name: delete vapp output 259 | debug: 260 | msg: '{{ output }}' 261 | 262 | - name: delete vapp 263 | vcd_vapp: 264 | vapp_name: test_vapp_2 265 | vdc: ACME_PAYG 266 | force: true 267 | state: absent 268 | register: output 269 | 270 | - name: delete vapp output 271 | debug: 272 | msg: '{{ output }}' 273 | -------------------------------------------------------------------------------- /roles/vapp/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vapp/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/vapp 8 | -------------------------------------------------------------------------------- /roles/vapp/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/vapp 5 | vapp_name: "test_vapp_100" 6 | -------------------------------------------------------------------------------- /roles/vappnetwork/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vappnetwork/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/vappnetwork 5 | -------------------------------------------------------------------------------- /roles/vappnetwork/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/vappnetwork 5 | -------------------------------------------------------------------------------- /roles/vappnetwork/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (GPLv2, CC-BY, etc) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/vappnetwork/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for roles/vappnetwork 5 | 6 | - name: add vapp network 7 | vcd_vapp_network: 8 | user: acmeadmin 9 | password: XXXXXXXXXX 10 | org: Acme 11 | vdc: ACME_PAYG 12 | vapp: vApp_system_2 13 | network: sample_2 14 | network_cidr: 192.168.102.2/24 15 | primary_dns_ip: 192.168.102.1 16 | dns_suffix: dn 17 | ip_ranges: 18 | - 192.168.102.5-192.168.102.10 19 | is_guest_vlan_allowed: False 20 | state: present 21 | register: output 22 | 23 | - name: add vapp network output 24 | debug: 25 | msg: "{{ output }}" 26 | 27 | - name: read vapp networks 28 | vcd_vapp_network: 29 | user: acmeadmin 30 | password: XXXXXXXXXX 31 | org: Acme 32 | vdc: ACME_PAYG 33 | vapp: vApp_system_2 34 | operation: read 35 | register: output 36 | 37 | - name: read vapp networks output 38 | debug: 39 | msg: "{{ output }}" 40 | 41 | - name: update vapp network 42 | vcd_vapp_network: 43 | user: acmeadmin 44 | password: XXXXXXXXXX 45 | org: Acme 46 | vdc: ACME_PAYG 47 | vapp: vApp_system_2 48 | network: sample_2 49 | new_network: sample_3 50 | state: update 51 | register: output 52 | 53 | - name: update vapp network output 54 | debug: 55 | msg: "{{ output }}" 56 | 57 | - name: read vapp networks 58 | vcd_vapp_network: 59 | user: acmeadmin 60 | password: XXXXXXXXXX 61 | org: Acme 62 | vdc: ACME_PAYG 63 | vapp: vApp_system_2 64 | operation: read 65 | register: output 66 | 67 | - name: read vapp networks output 68 | debug: 69 | msg: "{{ output }}" 70 | 71 | - name: delete vapp network 72 | vcd_vapp_network: 73 | user: acmeadmin 74 | password: XXXXXXXXXX 75 | org: Acme 76 | vdc: ACME_PAYG 77 | vapp: vApp_system_2 78 | network: sample_3 79 | state: absent 80 | register: output 81 | 82 | - name: delete vapp network output 83 | debug: 84 | msg: "{{ output }}" 85 | 86 | - name: read vapp networks 87 | vcd_vapp_network: 88 | user: acmeadmin 89 | password: XXXXXXXXXX 90 | org: Acme 91 | vdc: ACME_PAYG 92 | vapp: vApp_system_2 93 | operation: read 94 | register: output 95 | 96 | - name: read vapp networks output 97 | debug: 98 | msg: "{{ output }}" 99 | -------------------------------------------------------------------------------- /roles/vappnetwork/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vappnetwork/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/vappnetwork 8 | -------------------------------------------------------------------------------- /roles/vappnetwork/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/vappnetwork 5 | vapp_network: "test_vapp_network" 6 | -------------------------------------------------------------------------------- /roles/vappvm/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vappvm/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/vappvm 5 | -------------------------------------------------------------------------------- /roles/vappvm/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/vappvm 5 | -------------------------------------------------------------------------------- /roles/vappvm/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/vappvm/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for roles/vappvm 5 | 6 | - name: create vapp vm "{{ vapp_vm_1 }}" from catalog 7 | no_log: False 8 | vcd_vapp_vm: 9 | target_vm_name: "{{ vapp_vm_1 }}" 10 | target_vapp: "web2" 11 | source_vdc: "Terraform_VDC" 12 | target_vdc: "Terraform_VDC" 13 | source_catalog_name: "test_catalog" 14 | source_template_name: "centos7" 15 | source_vm_name: "CentOS7" 16 | hostname: "vcdcell" 17 | vmpassword: "rootpass" 18 | vmpassword_auto: "false" 19 | vmpassword_reset: "false" 20 | ip_allocation_mode: "DHCP" 21 | state: "present" 22 | power_on: "false" 23 | all_eulas_accepted: "true" 24 | storage_profile: "Standard" 25 | network: "web2Network" 26 | register: output 27 | 28 | - name: create vapp vm output 29 | debug: 30 | msg: "{{ output }}" 31 | 32 | - name: create vapp vm "{{ vapp_vm_2 }}" from vapp 33 | no_log: False 34 | vcd_vapp_vm: 35 | target_vm_name: "{{ vapp_vm_2 }}" 36 | target_vapp: "web2" 37 | source_vdc: "Terraform_VDC" 38 | target_vdc: "Terraform_VDC" 39 | source_vapp: "web" 40 | source_vm_name: "web1" 41 | hostname: "vcdcell" 42 | vmpassword: "rootpass" 43 | vmpassword_auto: "false" 44 | vmpassword_reset: "false" 45 | ip_allocation_mode: "DHCP" 46 | state: "present" 47 | power_on: "false" 48 | all_eulas_accepted: "true" 49 | storage_profile: "Standard" 50 | network: "web2Network" 51 | register: output 52 | 53 | - name: create vapp vm output 54 | debug: 55 | msg: "{{ output }}" 56 | 57 | - name: power on "{{ vapp_vm_1 }}" vapp vm 58 | vcd_vapp_vm: 59 | target_vm_name: "{{ vapp_vm_1 }}" 60 | target_vapp: "web2" 61 | target_vdc: "Terraform_VDC" 62 | operation: "poweron" 63 | register: output 64 | 65 | - name: power on vapp vm output 66 | debug: 67 | msg: "{{ output }}" 68 | 69 | - name: power on "{{ vapp_vm_2 }}" vapp vm 70 | vcd_vapp_vm: 71 | target_vm_name: "{{ vapp_vm_2 }}" 72 | target_vapp: "web2" 73 | target_vdc: "Terraform_VDC" 74 | operation: "poweron" 75 | register: output 76 | 77 | - name: power on vapp vm output 78 | debug: 79 | msg: "{{ output }}" 80 | 81 | - name: power off "{{ vapp_vm_1 }}" vapp vm 82 | vcd_vapp_vm: 83 | target_vm_name: "{{ vapp_vm_1 }}" 84 | target_vapp: "web2" 85 | target_vdc: "Terraform_VDC" 86 | operation: "poweroff" 87 | register: output 88 | 89 | - name: power off vapp vm output 90 | debug: 91 | msg: "{{ output }}" 92 | 93 | - name: power off "{{ vapp_vm_2 }}" vapp vm 94 | vcd_vapp_vm: 95 | target_vm_name: "{{ vapp_vm_2 }}" 96 | target_vapp: "web2" 97 | target_vdc: "Terraform_VDC" 98 | operation: "poweroff" 99 | register: output 100 | 101 | - name: power off vapp vm output 102 | debug: 103 | msg: "{{ output }}" 104 | 105 | - name: modify "{{ vapp_vm_1 }}" cpu vapp vm 106 | vcd_vapp_vm: 107 | target_vm_name: "{{ vapp_vm_1 }}" 108 | target_vapp: "web2" 109 | target_vdc: "Terraform_VDC" 110 | virtual_cpus: 2 111 | cores_per_socket: 2 112 | state: "update" 113 | register: output 114 | 115 | - name: update vapp vm output 116 | debug: 117 | msg: "{{ output }}" 118 | 119 | - name: modify "{{ vapp_vm_2 }}" cpu vapp vm 120 | vcd_vapp_vm: 121 | target_vm_name: "{{ vapp_vm_2 }}" 122 | target_vapp: "web2" 123 | target_vdc: "Terraform_VDC" 124 | virtual_cpus: 2 125 | cores_per_socket: 2 126 | state: "update" 127 | register: output 128 | 129 | - name: update vapp vm output 130 | debug: 131 | msg: "{{ output }}" 132 | 133 | - name: modify "{{ vapp_vm_1 }}" memory vapp vm 134 | vcd_vapp_vm: 135 | target_vm_name: "{{ vapp_vm_1 }}" 136 | target_vapp: "web2" 137 | target_vdc: "Terraform_VDC" 138 | memory: 4096 139 | state: "update" 140 | register: output 141 | 142 | - name: update vapp vm output 143 | debug: 144 | msg: "{{ output }}" 145 | 146 | - name: modify "{{ vapp_vm_2 }}" memory vapp vm 147 | vcd_vapp_vm: 148 | target_vm_name: "{{ vapp_vm_2 }}" 149 | target_vapp: "web2" 150 | target_vdc: "Terraform_VDC" 151 | memory: 4096 152 | state: "update" 153 | register: output 154 | 155 | - name: update vapp vm output 156 | debug: 157 | msg: "{{ output }}" 158 | 159 | - name: modify "{{ vapp_vm_1 }}" compute policy vapp vm 160 | vcd_vapp_vm: 161 | target_vm_name: "{{ vapp_vm_1 }}" 162 | target_vapp: "web2" 163 | target_vdc: "Terraform_VDC" 164 | compute_policy_href: "https://vcloud.example.com/cloudapi/1.0.0/vdcComputePolicies/51" 165 | state: "update" 166 | register: output 167 | 168 | - name: update vapp vm output 169 | debug: 170 | msg: "{{ output }}" 171 | 172 | - name: modify "{{ vapp_vm_2 }}" compute policy vapp vm 173 | vcd_vapp_vm: 174 | target_vm_name: "{{ vapp_vm_2 }}" 175 | target_vapp: "web2" 176 | target_vdc: "Terraform_VDC" 177 | compute_policy_href: "https://vcloud.example.com/cloudapi/1.0.0/vdcComputePolicies/51" 178 | state: "update" 179 | register: output 180 | 181 | - name: update vapp vm output 182 | debug: 183 | msg: "{{ output }}" 184 | 185 | - name: reload "{{ vapp_vm_1 }}" vapp vm 186 | vcd_vapp_vm: 187 | target_vm_name: "{{ vapp_vm_1 }}" 188 | target_vapp: "web2" 189 | target_vdc: "Terraform_VDC" 190 | operation: "reloadvm" 191 | register: output 192 | 193 | - name: reload vapp vm output 194 | debug: 195 | msg: "{{ output }}" 196 | 197 | - name: reload "{{ vapp_vm_2 }}" vapp vm 198 | vcd_vapp_vm: 199 | target_vm_name: "{{ vapp_vm_2 }}" 200 | target_vapp: "web2" 201 | target_vdc: "Terraform_VDC" 202 | operation: "reloadvm" 203 | register: output 204 | 205 | - name: reload vapp vm output 206 | debug: 207 | msg: "{{ output }}" 208 | 209 | - name: undeploy "{{ vapp_vm_1 }}" vapp vm 210 | vcd_vapp_vm: 211 | target_vm_name: "{{ vapp_vm_1 }}" 212 | target_vapp: "web2" 213 | target_vdc: "Terraform_VDC" 214 | operation: "undeploy" 215 | register: output 216 | 217 | - name: undeploy vapp vm output 218 | debug: 219 | msg: "{{ output }}" 220 | 221 | - name: undeploy "{{ vapp_vm_2 }}" vapp vm 222 | vcd_vapp_vm: 223 | target_vm_name: "{{ vapp_vm_2 }}" 224 | target_vapp: "web2" 225 | target_vdc: "Terraform_VDC" 226 | operation: "undeploy" 227 | register: output 228 | 229 | - name: undeploy vapp vm output 230 | debug: 231 | msg: "{{ output }}" 232 | 233 | - name: deploy "{{ vapp_vm_1 }}" vapp vm 234 | vcd_vapp_vm: 235 | target_vm_name: "{{ vapp_vm_1 }}" 236 | target_vapp: "web2" 237 | target_vdc: "Terraform_VDC" 238 | operation: "deploy" 239 | register: output 240 | 241 | - name: deploy vapp vm output 242 | debug: 243 | msg: "{{ output }}" 244 | 245 | - name: deploy "{{ vapp_vm_2 }}" vapp vm 246 | vcd_vapp_vm: 247 | target_vm_name: "{{ vapp_vm_2 }}" 248 | target_vapp: "web2" 249 | target_vdc: "Terraform_VDC" 250 | operation: "deploy" 251 | register: output 252 | 253 | - name: deploy vapp vm output 254 | debug: 255 | msg: "{{ output }}" 256 | 257 | - name: delete "{{ vapp_vm_1 }}" vapp vm 258 | vcd_vapp_vm: 259 | target_vm_name: "{{ vapp_vm_1 }}" 260 | target_vapp: "web2" 261 | target_vdc: "Terraform_VDC" 262 | state: "absent" 263 | register: output 264 | 265 | - name: delete vapp vm output 266 | debug: 267 | msg: "{{ output }}" 268 | 269 | - name: delete "{{ vapp_vm_2 }}" vapp vm 270 | vcd_vapp_vm: 271 | target_vm_name: "{{ vapp_vm_2 }}" 272 | target_vapp: "web2" 273 | target_vdc: "Terraform_VDC" 274 | state: "absent" 275 | register: output 276 | 277 | - name: delete vapp vm output 278 | debug: 279 | msg: "{{ output }}" 280 | 281 | - name: list "{{ vapp_vm_2 }}" vapp vm disks 282 | vcd_vapp_vm: 283 | target_vm_name: "{{ vapp_vm_2 }}" 284 | target_vapp: "web2" 285 | target_vdc: "Terraform_VDC" 286 | operation: "list_disks" 287 | register: output 288 | 289 | - name: list "{{ vapp_vm_2 }}" vapp vm disks output 290 | debug: 291 | msg: "{{ output }}" 292 | 293 | - name: list "{{ vapp_vm_2 }}" vapp vm nics 294 | vcd_vapp_vm: 295 | target_vm_name: "{{ vapp_vm_2 }}" 296 | target_vapp: "web2" 297 | target_vdc: "Terraform_VDC" 298 | operation: "list_nics" 299 | register: output 300 | 301 | - name: list "{{ vapp_vm_2 }}" vapp vm nics output 302 | debug: 303 | msg: "{{ output }}" 304 | 305 | - name: set vm metadata 306 | vcd_vapp_vm: 307 | user: acmeadmin 308 | password: XXXXXXXXXX 309 | org: Acme 310 | target_vm_name: centos 311 | target_vapp: acme_vapp 312 | target_vdc: ACME_PAYG 313 | metadata: 314 | sample7: sample-value4 315 | sample8: sample-value4 316 | sample9: sample-value4 317 | operation: set_meta 318 | register: output 319 | 320 | - name: set vm metadata output 321 | debug: 322 | msg: '{{ output }}' 323 | 324 | - name: get vm metadata 325 | vcd_vapp_vm: 326 | user: acmeadmin 327 | password: XXXXXXXXXX 328 | org: Acme 329 | target_vm_name: centos 330 | target_vdc: ACME_PAYG 331 | target_vapp: acme_vapp 332 | operation: get_meta 333 | register: output 334 | 335 | - name: get vm metadata output 336 | debug: 337 | msg: '{{ output }}' 338 | 339 | - name: remove vm metadata 340 | vcd_vapp_vm: 341 | user: acmeadmin 342 | password: XXXXXXXXXX 343 | org: Acme 344 | target_vm_name: centos 345 | target_vapp: acme_vapp 346 | target_vdc: ACME_PAYG 347 | metadata: 348 | sample7: sample-value4 349 | sample8: sample-value4 350 | sample9: sample-value4 351 | operation: remove_meta 352 | register: output 353 | 354 | - name: remove vm metadata output 355 | debug: 356 | msg: '{{ output }}' 357 | 358 | -------------------------------------------------------------------------------- /roles/vappvm/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vappvm/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/vappvm 8 | -------------------------------------------------------------------------------- /roles/vappvm/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/vappvm 5 | vapp_vm_1: "test_vapp_vm_1" 6 | vapp_vm_2: "test_vapp_vm_2" 7 | -------------------------------------------------------------------------------- /roles/vappvmdisk/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vappvmdisk/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/vappvmdisk 5 | -------------------------------------------------------------------------------- /roles/vappvmdisk/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/vappvmdisk 5 | -------------------------------------------------------------------------------- /roles/vappvmdisk/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/vappvmdisk/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for vcd_vapp_vm_disk 3 | 4 | 5 | - name: add a disk 6 | vcd_vapp_vm_disk: 7 | user: acmeadmin 8 | password: XXXXXXXXXX 9 | org: Acme 10 | vm_name: centos 11 | vapp: vApp_system_2 12 | vdc: ACME_PAYG 13 | disks: 14 | - size: 1 15 | controller: lsilogic 16 | name: "Hard disk 1" 17 | - size: 1 18 | controller: VirtualSCSI 19 | name: "Hard disk 2" 20 | state: present 21 | register: myResult 22 | 23 | - name: Show the data 24 | debug: 25 | msg: "{{ myResult }}" 26 | 27 | - name: update a disk 28 | vcd_vapp_vm_disk: 29 | user: acmeadmin 30 | password: XXXXXXXXXX 31 | org: Acme 32 | vm_name: centos 33 | vapp: vApp_system_2 34 | vdc: ACME_PAYG 35 | disks: 36 | - name: Hard disk 1 37 | size: 3 38 | state: update 39 | register: myResult 40 | 41 | - name: Show the data 42 | debug: 43 | msg: "{{ myResult }}" 44 | 45 | - name: Read my disks 46 | vcd_vapp_vm_disk: 47 | user: acmeadmin 48 | password: XXXXXXXXXX 49 | org: Acme 50 | vm_name: centos 51 | vapp: vApp_system_2 52 | vdc: ACME_PAYG 53 | operation: read 54 | register: myResult 55 | 56 | - name: Show the data 57 | debug: 58 | msg: "{{ myResult }}" 59 | 60 | - name: delete my disks 61 | vcd_vapp_vm_disk: 62 | user: acmeadmin 63 | password: XXXXXXXXXX 64 | org: Acme 65 | vm_name: centos 66 | vapp: vApp_system_2 67 | vdc: ACME_PAYG 68 | disks: 69 | - name: Hard disk 1 70 | state: absent 71 | register: myResult 72 | 73 | - name: Show the data 74 | debug: 75 | msg: "{{ myResult }}" 76 | -------------------------------------------------------------------------------- /roles/vappvmdisk/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vappvmdisk/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/vappvmdisk 8 | -------------------------------------------------------------------------------- /roles/vappvmdisk/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/vappvmdisk 5 | vm_name: "test_vm" 6 | vapp: "test_vapp" 7 | vdc: "test_vdc" 8 | -------------------------------------------------------------------------------- /roles/vappvmnic/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vappvmnic/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/vappvmnic 5 | -------------------------------------------------------------------------------- /roles/vappvmnic/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/vappvmnic 5 | -------------------------------------------------------------------------------- /roles/vappvmnic/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/vappvmnic/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for roles/vappvmnic 5 | - name: create vapp vm nic 6 | vcd_vapp_vm_nic: 7 | vm_name: "Tiny Linux template" 8 | vapp: "web2" 9 | vdc: "ACME_PAYG" 10 | network: "172.16.1.0" 11 | ip_allocation_mode: "MANUAL" 12 | ip_address: "172.16.1.121" 13 | state: "present" 14 | register: output 15 | 16 | - name: create vapp vm nic output 17 | debug: 18 | msg: '{{ output }}' 19 | 20 | - name: update nic 21 | vcd_vapp_vm_nic: 22 | vm_name: "Tiny Linux template" 23 | vapp: "web2" 24 | vdc: "ACME_PAYG" 25 | nic_id: 3 26 | ip_address: "172.16.1.122" 27 | state: "update" 28 | register: output 29 | 30 | - name: update nic output 31 | debug: 32 | msg: '{{ output }}' 33 | 34 | - name: read vapp vm nics 35 | vcd_vapp_vm_nic: 36 | vm_name: "Tiny Linux template" 37 | vapp: "web2" 38 | vdc: "ACME_PAYG" 39 | operation: "read" 40 | register: output 41 | 42 | - name: read vapp vm nics output 43 | debug: 44 | msg: '{{ output }}' 45 | 46 | - name: update nic 47 | vcd_vapp_vm_nic: 48 | vm_name: "Tiny Linux template" 49 | vapp: "web2" 50 | vdc: "ACME_PAYG" 51 | nic_id: 3 52 | network: "test_network" 53 | state: "update" 54 | register: output 55 | 56 | - name: update nic output 57 | debug: 58 | msg: '{{ output }}' 59 | 60 | - name: read vapp vm nics 61 | vcd_vapp_vm_nic: 62 | vm_name: "Tiny Linux template" 63 | vapp: "web2" 64 | vdc: "ACME_PAYG" 65 | operation: "read" 66 | register: output 67 | 68 | - name: read vapp vm nics output 69 | debug: 70 | msg: '{{ output }}' 71 | 72 | - name: update nic 73 | vcd_vapp_vm_nic: 74 | vm_name: "Tiny Linux template" 75 | vapp: "web2" 76 | vdc: "ACME_PAYG" 77 | nic_id: 3 78 | ip_allocation_mode: "DHCP" 79 | state: "update" 80 | register: output 81 | 82 | - name: update nic output 83 | debug: 84 | msg: '{{ output }}' 85 | 86 | - name: read vapp vm nics 87 | vcd_vapp_vm_nic: 88 | vm_name: "Tiny Linux template" 89 | vapp: "web2" 90 | vdc: "ACME_PAYG" 91 | operation: "read" 92 | register: output 93 | 94 | - name: read vapp vm nics output 95 | debug: 96 | msg: '{{ output }}' 97 | 98 | - name: update nic 99 | vcd_vapp_vm_nic: 100 | vm_name: "Tiny Linux template" 101 | vapp: "web2" 102 | vdc: "ACME_PAYG" 103 | nic_id: 3 104 | ip_allocation_mode: "MANUAL" 105 | ip_address: "172.16.1.122" 106 | network: "172.16.1.0" 107 | state: "update" 108 | register: output 109 | 110 | - name: update nic output 111 | debug: 112 | msg: '{{ output }}' 113 | 114 | - name: read vapp vm nics 115 | vcd_vapp_vm_nic: 116 | vm_name: "Tiny Linux template" 117 | vapp: "web2" 118 | vdc: "ACME_PAYG" 119 | operation: "read" 120 | register: output 121 | 122 | - name: read vapp vm nics output 123 | debug: 124 | msg: '{{ output }}' 125 | 126 | - name: delete nic 127 | vcd_vapp_vm_nic: 128 | vm_name: "Tiny Linux template" 129 | vapp: "web2" 130 | vdc: "ACME_PAYG" 131 | nic_ids: 132 | - 3 133 | state: "absent" 134 | register: output 135 | 136 | - name: delete nic output 137 | debug: 138 | msg: '{{ output }}' 139 | 140 | -------------------------------------------------------------------------------- /roles/vappvmnic/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vappvmnic/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/vappvmnic 8 | -------------------------------------------------------------------------------- /roles/vappvmnic/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/vappvmnic 5 | vm_name: "test_vm" 6 | vapp: "test_vapp" 7 | vdc: "test_vdc" 8 | -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_edge_gateway -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_edge_gateway -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.4 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for vcd_edge_gateway 3 | 4 | - name: create edge gateway 5 | vcd_vdc_gateway: 6 | org_name: Acme 7 | vdc_name: ACME_PAYG 8 | gateway_name: test-gateway 9 | gateway_backing_config: compact 10 | external_networks: 11 | - external-network 12 | state: present 13 | register: output 14 | 15 | - name: create edge gateway output 16 | debug: 17 | msg: '{{ output }}' 18 | 19 | - name: update edge gateway 20 | vcd_vdc_gateway: 21 | org_name: Acme 22 | vdc_name: ACME_PAYG 23 | gateway_name: test-gateway 24 | new_gateway_name: test-gateway-01 25 | ha_enabled: true 26 | state: update 27 | register: output 28 | 29 | - name: update edge gateway output 30 | debug: 31 | msg: '{{ output }}' 32 | 33 | - name: update edge gateway 34 | vcd_vdc_gateway: 35 | org_name: Acme 36 | vdc_name: ACME_PAYG 37 | gateway_name: test-gateway 38 | ext_net_subnet_allocated_ip_pool: 39 | external-network: 10.176.3.20-10.176.3.25 40 | operation: update_ip_pool 41 | register: output 42 | 43 | - name: update edge gateway 44 | debug: 45 | msg: '{{ output }}' 46 | 47 | - name: update edge gateway 48 | vcd_vdc_gateway: 49 | org_name: Acme 50 | vdc_name: ACME_PAYG 51 | gateway_name: test-gateway 52 | ext_net_to_participated_subnet_with_ip_settings: 53 | external-network: 54 | 172.17.11.1/24: 172.17.11.102 55 | operation: add_network 56 | register: output 57 | 58 | - name: update edge gateway 59 | debug: 60 | msg: '{{ output }}' 61 | 62 | - name: update edge gateway 63 | vcd_vdc_gateway: 64 | org_name: Acme 65 | vdc_name: ACME_PAYG 66 | gateway_name: test-gateway 67 | external_networks: 68 | - external-network 69 | operation: remove_network 70 | register: output 71 | 72 | - name: update edge gateway 73 | debug: 74 | msg: '{{ output }}' 75 | 76 | - name: delete edge gateway 77 | vcd_vdc_gateway: 78 | org_name: Acme 79 | vdc_name: ACME_PAYG 80 | gateway_name: test-gateway 81 | state: absent 82 | register: output 83 | 84 | - name: delete edge gateway output 85 | debug: 86 | msg: '{{ output }}' -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_edge_gateway -------------------------------------------------------------------------------- /roles/vcd_edge_gateway/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_edge_gateway -------------------------------------------------------------------------------- /roles/vcd_external_network/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_external_network/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_external_networks -------------------------------------------------------------------------------- /roles/vcd_external_network/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_external_networks -------------------------------------------------------------------------------- /roles/vcd_external_network/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.4 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_external_network/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for vcd_external_networks 3 | 4 | - name: create external network 5 | vcd_external_network: 6 | vc_name: vc.0 7 | port_group_names: 8 | - VM Network 9 | network_name: external-network 10 | gateway_ip: 10.176.3.253 11 | netmask: 255.255.0.0 12 | ip_ranges: 13 | - 10.176.7.68-10.176.7.69 14 | state: "present" 15 | register: output 16 | 17 | - name: create external network output 18 | debug: 19 | msg: '{{ output }}' 20 | 21 | - name: update external network 22 | vcd_external_network: 23 | network_name: external-network 24 | new_network_name: new-name 25 | description: updated network 26 | state: "update" 27 | register: output 28 | 29 | - name: update external network output 30 | debug: 31 | msg: '{{ output }}' 32 | 33 | - name: add subnet to external network 34 | vcd_external_network: 35 | network_name: new-name 36 | gateway_ip: 10.196.10.253 37 | netmask: 255.255.0.0 38 | ip_ranges: 39 | - 10.196.7.68-10.196.7.69 40 | operation: add_subnet 41 | register: output 42 | 43 | - name: add subnet to external network 44 | debug: 45 | msg: '{{ output }}' 46 | 47 | - name: add ip ranges to external network subnet 48 | vcd_external_network: 49 | network_name: new-name 50 | gateway_ip: 10.196.10.253 51 | ip_ranges: 52 | - 10.196.8.68-10.196.8.69 53 | operation: add_ip_ranges 54 | register: output 55 | 56 | - name: add ip ranges to external network subnet 57 | debug: 58 | msg: '{{ output }}' 59 | 60 | - name: modify ip ranges to external network subnet 61 | vcd_external_network: 62 | network_name: new-name 63 | gateway_ip: 10.196.10.253 64 | ip_ranges: 65 | - 10.196.8.68-10.196.8.69 66 | new_ip_ranges: 67 | - 10.196.9.68-10.196.9.69 68 | operation: modify_ip_ranges 69 | register: output 70 | 71 | - name: modify ip ranges to external network subnet 72 | debug: 73 | msg: '{{ output }}' 74 | 75 | - name: delete ip ranges to external network subnet 76 | vcd_external_network: 77 | network_name: new-name 78 | gateway_ip: 10.196.10.253 79 | ip_ranges: 80 | - 10.196.9.68-10.196.9.69 81 | operation: delete_ip_ranges 82 | register: output 83 | 84 | - name: delete ip ranges to external network subnet 85 | debug: 86 | msg: '{{ output }}' 87 | 88 | - name: disable external network subnet 89 | vcd_external_network: 90 | network_name: new-name 91 | gateway_ip: 10.196.10.253 92 | enable_subnet: False 93 | operation: enable_subnet 94 | register: output 95 | 96 | - name: disable external network subnet 97 | debug: 98 | msg: '{{ output }}' 99 | 100 | - name: enable external network subnet 101 | vcd_external_network: 102 | network_name: new-name 103 | gateway_ip: 10.196.10.253 104 | enable_subnet: True 105 | operation: enable_subnet 106 | register: output 107 | 108 | - name: enable external network subnet 109 | debug: 110 | msg: '{{ output }}' 111 | 112 | - name: list external networks 113 | vcd_external_network: 114 | operation: list_networks 115 | register: output 116 | 117 | 118 | - name: list external networks output 119 | debug: 120 | msg: '{{ output }}' 121 | 122 | - name: delete external network 123 | vcd_external_network: 124 | network_name: new-name 125 | state: "absent" 126 | register: output 127 | 128 | 129 | - name: delete external network output 130 | debug: 131 | msg: '{{ output }}' -------------------------------------------------------------------------------- /roles/vcd_external_network/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_external_network/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_external_networks -------------------------------------------------------------------------------- /roles/vcd_external_network/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_external_networks -------------------------------------------------------------------------------- /roles/vcd_gateway_services/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | # Use the new container infrastructure 6 | sudo: false 7 | 8 | # Install ansible 9 | addons: 10 | apt: 11 | packages: 12 | - python-pip 13 | 14 | install: 15 | # Install ansible 16 | - pip install ansible 17 | 18 | # Check ansible version 19 | - ansible --version 20 | 21 | # Create ansible.cfg with correct roles_path 22 | - printf '[defaults]\nroles_path=../' >ansible.cfg 23 | 24 | script: 25 | # Basic role syntax check 26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check 27 | 28 | notifications: 29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ -------------------------------------------------------------------------------- /roles/vcd_gateway_services/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_gateway_services/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_gateway_services -------------------------------------------------------------------------------- /roles/vcd_gateway_services/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_gateway_services -------------------------------------------------------------------------------- /roles/vcd_gateway_services/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your role description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.9 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_gateway_services/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | 4 | --- 5 | # tasks file for roles/vcd_gateway_services 6 | 7 | - name: create gateway services 8 | vcd_gateway_services: 9 | user: acmeadmin 10 | password: XXXXXXXXXXXX 11 | org: Acme 12 | vdc: ACME_PAYG 13 | gateway: edge-gateway 14 | service: firewall 15 | service_params: 16 | - name: test_firewall 17 | action: accept 18 | type: User 19 | enabled: True 20 | logging_enabled: False 21 | source_values: 22 | - ip: 23 | - "192.168.110.102-192.168.110.115" 24 | destination_values: 25 | - gatewayinterface: 26 | - "external-network-3" 27 | services: 28 | - tcp: 29 | source_port: any 30 | destination_port: any 31 | - name: test_firewall_2 32 | action: accept 33 | type: User 34 | enabled: True 35 | logging_enabled: False 36 | source_values: 37 | - ip: 38 | - "192.168.110.102-192.168.110.115" 39 | destination_values: 40 | - gatewayinterface: 41 | - "external-network-3" 42 | services: 43 | - tcp: 44 | source_port: any 45 | destination_port: any 46 | state: present 47 | register: output 48 | 49 | - name: create gateway services output 50 | debug: 51 | msg: '{{ output }}' 52 | 53 | - name: update gateway services 54 | vcd_gateway_services: 55 | user: acmeadmin 56 | password: XXXXXXXXXXXX 57 | org: Acme 58 | vdc: ACME_PAYG 59 | gateway: edge-gateway 60 | service: firewall 61 | service_params: 62 | - name: test_firewall 63 | source_values: 64 | - gatewayinterface: 65 | - "external-network-3" 66 | destination_values: 67 | - ip: 68 | - "192.168.110.102-192.168.110.115" 69 | services: 70 | - tcp: 71 | source_port: any 72 | destination_port: any 73 | - name: test_firewall_2 74 | source_values: 75 | - gatewayinterface: 76 | - "external-network-3" 77 | destination_values: 78 | - ip: 79 | - "192.168.110.102-192.168.110.115" 80 | services: 81 | - tcp: 82 | source_port: any 83 | destination_port: any 84 | state: update 85 | register: output 86 | 87 | - name: update gateway services output 88 | debug: 89 | msg: '{{ output }}' 90 | 91 | - name: list gateway firewalls 92 | vcd_gateway_services: 93 | user: acmeadmin 94 | password: XXXXXXXXXXXX 95 | org: Acme 96 | vdc: ACME_PAYG 97 | gateway: edge-gateway 98 | service: firewall 99 | operation: list 100 | register: output 101 | 102 | - name: list gateway services output 103 | debug: 104 | msg: '{{ output }}' 105 | 106 | - name: delete gateway services 107 | vcd_gateway_services: 108 | user: acmeadmin 109 | password: XXXXXXXXXXXX 110 | org: Acme 111 | vdc: ACME_PAYG 112 | gateway: edge-gateway 113 | service: firewall 114 | service_params: 115 | - name: test_firewall 116 | - name: test_firewall_2 117 | state: absent 118 | register: output 119 | 120 | - name: delete gateway services output 121 | debug: 122 | msg: '{{ output }}' 123 | 124 | - name: list gateway services 125 | vcd_gateway_services: 126 | user: acmeadmin 127 | password: XXXXXXXXXXXX 128 | org: Acme 129 | vdc: ACME_PAYG 130 | gateway: edge-gateway 131 | service: firewall 132 | operation: list 133 | register: output 134 | 135 | - name: list gateway services output 136 | debug: 137 | msg: '{{ output }}' 138 | 139 | - name: create nat rule 140 | vcd_gateway_services: 141 | user: acmeadmin 142 | password: XXXXXXXXXXXX 143 | org: Acme 144 | vdc: ACME_PAYG 145 | gateway: edge-gateway 146 | service: nat_rule 147 | service_params: 148 | - action: snat 149 | original_address: 10.172.17.11 150 | translated_address: 192.168.11.1 151 | state: present 152 | register: output 153 | 154 | - name: create gateway services output 155 | debug: 156 | msg: '{{ output }}' 157 | 158 | - name: list nat rules 159 | vcd_gateway_services: 160 | user: acmeadmin 161 | password: XXXXXXXXXXXX 162 | org: Acme 163 | vdc: ACME_PAYG 164 | gateway: edge-gateway 165 | service: nat_rule 166 | operation: list 167 | register: output 168 | 169 | - name: list nat rules output 170 | debug: 171 | msg: '{{ output }}' 172 | 173 | - name: update nat rule 174 | vcd_gateway_services: 175 | user: acmeadmin 176 | password: XXXXXXXXXXXX 177 | org: Acme 178 | vdc: ACME_PAYG 179 | gateway: edge-gateway 180 | service: nat_rule 181 | service_params: 182 | - nat_rule_id: "{{ output.get('msg')[0]['ID'] }}" 183 | original_address: 10.172.17.20 184 | translated_address: 192.168.11.50 185 | state: update 186 | register: output 187 | 188 | - name: update nat rule output 189 | debug: 190 | msg: '{{ output }}' 191 | 192 | - name: list nat rules 193 | vcd_gateway_services: 194 | user: acmeadmin 195 | password: XXXXXXXXXXXX 196 | org: Acme 197 | vdc: ACME_PAYG 198 | gateway: edge-gateway 199 | service: nat_rule 200 | operation: list 201 | register: output 202 | 203 | - name: list nat rules output 204 | debug: 205 | msg: '{{ output }}' 206 | 207 | - name: delete nat rule 208 | vcd_gateway_services: 209 | user: acmeadmin 210 | password: XXXXXXXXXXXX 211 | org: Acme 212 | vdc: ACME_PAYG 213 | gateway: edge-gateway 214 | service: nat_rule 215 | service_params: 216 | - nat_rule_id: "{{ output.get('msg')[0]['ID'] }}" 217 | state: absent 218 | register: output 219 | 220 | - name: delete nat rule output 221 | debug: 222 | msg: '{{ output }}' 223 | 224 | - name: list nat rules 225 | vcd_gateway_services: 226 | user: acmeadmin 227 | password: XXXXXXXXXXXX 228 | org: Acme 229 | vdc: ACME_PAYG 230 | gateway: edge-gateway 231 | service: nat_rule 232 | operation: list 233 | register: output 234 | 235 | - name: list nat rules output 236 | debug: 237 | msg: '{{ output }}' -------------------------------------------------------------------------------- /roles/vcd_gateway_services/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_gateway_services/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_gateway_services -------------------------------------------------------------------------------- /roles/vcd_gateway_services/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_gateway_services -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_org_vdc_network -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_org_vdc_network -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.4 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for org_vdc_networks 3 | 4 | - name: create isolated org vdc network 5 | vcd_vdc_network: 6 | org_name: Acme 7 | vdc_name: ACME_PAYG 8 | network_name: acme_internal 9 | description: acme internal isolated network 10 | network_cidr: 10.176.7.61/24 11 | shared: true 12 | isolated: true 13 | state: present 14 | register: output 15 | 16 | - name: create isolated org vdc network output 17 | debug: 18 | msg: '{{ output }}' 19 | 20 | - name: create direct org vdc network 21 | vcd_vdc_network: 22 | org_name: Acme 23 | vdc_name: ACME_PAYG 24 | network_name: acme_internal_direct 25 | parent_network_name: external-network 26 | description: acme internal direct network 27 | shared: true 28 | direct: true 29 | state: present 30 | register: output 31 | 32 | - name: create direct org vdc network output 33 | debug: 34 | msg: '{{ output }}' 35 | 36 | - name: delete isolated org vdc network 37 | vcd_vdc_network: 38 | org_name: Acme 39 | vdc_name: ACME_PAYG 40 | network_name: acme_internal 41 | isolated: true 42 | state: absent 43 | register: output 44 | 45 | - name: delete isolated org vdc network output 46 | debug: 47 | msg: '{{ output }}' 48 | 49 | - name: delete direct org vdc network 50 | vcd_vdc_network: 51 | org_name: Acme 52 | vdc_name: ACME_PAYG 53 | network_name: acme_internal_direct 54 | direct: true 55 | state: absent 56 | register: output 57 | 58 | - name: delete direct org vdc network output 59 | debug: 60 | msg: '{{ output }}' 61 | -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_org_vdc_network -------------------------------------------------------------------------------- /roles/vcd_org_vdc_network/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_org_vdc_network -------------------------------------------------------------------------------- /roles/vcd_roles/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_roles/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_roles -------------------------------------------------------------------------------- /roles/vcd_roles/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_roles -------------------------------------------------------------------------------- /roles/vcd_roles/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.4 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_roles/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for roles 3 | 4 | - name: create role 5 | vcd_roles: 6 | user: acmeadmin 7 | password: XXXXXXXXXX 8 | org: Acme 9 | role_name: sample_role_2 10 | role_description: sample role 11 | role_rights: 12 | - "Catalog: Import Media from vSphere" 13 | state: present 14 | register: output 15 | 16 | - name: create role output 17 | debug: 18 | msg: '{{ output }}' 19 | 20 | - name: update role 21 | vcd_roles: 22 | user: acmeadmin 23 | password: XXXXXXXXXX 24 | org: Acme 25 | role_name: sample_role_2 26 | role_rights: 27 | - "Organization vDC Distributed Firewall: View Rules" 28 | state: update 29 | register: output 30 | 31 | - name: update role output 32 | debug: 33 | msg: '{{ output }}' 34 | 35 | - name: list roles 36 | vcd_roles: 37 | user: acmeadmin 38 | password: XXXXXXXXXX 39 | org: Acme 40 | operation: list_roles 41 | register: output 42 | 43 | - name: list roles output 44 | debug: 45 | msg: '{{ output }}' 46 | 47 | - name: list rights 48 | vcd_roles: 49 | user: acmeadmin 50 | password: XXXXXXXXXX 51 | org: Acme 52 | operation: list_rights 53 | register: output 54 | 55 | - name: list rights output 56 | debug: 57 | msg: '{{ output }}' 58 | 59 | - name: delete role 60 | vcd_roles: 61 | user: acmeadmin 62 | password: XXXXXXXXXX 63 | org: Acme 64 | role_name: sample_role_2 65 | state: absent 66 | register: output 67 | 68 | - name: delete role output 69 | debug: 70 | msg: '{{ output }}' 71 | -------------------------------------------------------------------------------- /roles/vcd_roles/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_roles/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_roles -------------------------------------------------------------------------------- /roles/vcd_roles/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_roles -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | # Use the new container infrastructure 6 | sudo: false 7 | 8 | # Install ansible 9 | addons: 10 | apt: 11 | packages: 12 | - python-pip 13 | 14 | install: 15 | # Install ansible 16 | - pip install ansible 17 | 18 | # Check ansible version 19 | - ansible --version 20 | 21 | # Create ansible.cfg with correct roles_path 22 | - printf '[defaults]\nroles_path=../' >ansible.cfg 23 | 24 | script: 25 | # Basic role syntax check 26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check 27 | 28 | notifications: 29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_vapp_vm_nic -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_vapp_vm_nic -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your role description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.9 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for vcd_vapp_vm_nic 3 | 4 | - name: add vm nic 5 | vcd_vapp_vm_nic: 6 | user: acmeadmin 7 | password: XXXXXXXXXX 8 | org: Acme 9 | vapp: vApp_system_2 10 | vm_name: centos 11 | vdc: ACME_PAYG 12 | network: acme_internal_direct 13 | ip_allocation_mode: DHCP 14 | is_connected: True 15 | adapter_type: E1000 16 | state: present 17 | register: output 18 | 19 | 20 | - name: add vm nic output 21 | debug: 22 | msg: '{{ output }}' 23 | 24 | - name: update vm nic 25 | vcd_vapp_vm_nic: 26 | user: acmeadmin 27 | password: XXXXXXXXXX 28 | org: Acme 29 | vapp: vApp_system_2 30 | vm_name: centos 31 | vdc: ACME_PAYG 32 | network: acme_internal_direct 33 | is_primary: True 34 | state: update 35 | register: output 36 | 37 | 38 | - name: update vm nic output 39 | debug: 40 | msg: '{{ output }}' 41 | 42 | - name: power off vm 43 | vcd_vapp_vm: 44 | user: acmeadmin 45 | password: XXXXXXXXXX 46 | org: Acme 47 | target_vapp: vApp_system_2 48 | target_vm_name: centos 49 | target_vdc: ACME_PAYG 50 | operation: poweroff 51 | register: output 52 | 53 | - name: power off vm output 54 | debug: 55 | msg: '{{ output }}' 56 | 57 | 58 | - name: delete vm nic 59 | vcd_vapp_vm_nic: 60 | user: acmeadmin 61 | password: XXXXXXXXXX 62 | org: Acme 63 | vapp: vApp_system_2 64 | vm_name: centos 65 | vdc: ACME_PAYG 66 | nic_ids: 67 | - 1 68 | state: absent 69 | register: output 70 | 71 | 72 | - name: delete vm nic output 73 | debug: 74 | msg: '{{ output }}' 75 | 76 | - name: power on vm 77 | vcd_vapp_vm: 78 | user: acmeadmin 79 | password: XXXXXXXXXX 80 | org: Acme 81 | target_vapp: vApp_system_2 82 | target_vm_name: centos 83 | target_vdc: ACME_PAYG 84 | operation: poweron 85 | register: output 86 | 87 | - name: power on vm output 88 | debug: 89 | msg: '{{ output }}' 90 | 91 | - name: read vm nics 92 | vcd_vapp_vm_nic: 93 | user: acmeadmin 94 | password: XXXXXXXXXX 95 | org: Acme 96 | vapp: vApp_system_2 97 | vm_name: centos 98 | vdc: ACME_PAYG 99 | operation: read 100 | register: output 101 | 102 | 103 | - name: read vm nic output 104 | debug: 105 | msg: '{{ output }}' -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_vapp_vm_nic -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_nic/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_vapp_vm_nic -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for vcd_vapp_vm_snapshot -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for vcd_vapp_vm_snapshot -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/meta/main.yml: -------------------------------------------------------------------------------- 1 | galaxy_info: 2 | author: your name 3 | description: your description 4 | company: your company (optional) 5 | 6 | # If the issue tracker for your role is not on github, uncomment the 7 | # next line and provide a value 8 | # issue_tracker_url: http://example.com/issue/tracker 9 | 10 | # Choose a valid license ID from https://spdx.org - some suggested licenses: 11 | # - BSD-3-Clause (default) 12 | # - MIT 13 | # - GPL-2.0-or-later 14 | # - GPL-3.0-only 15 | # - Apache-2.0 16 | # - CC-BY-4.0 17 | license: license (GPL-2.0-or-later, MIT, etc) 18 | 19 | min_ansible_version: 2.4 20 | 21 | # If this a Container Enabled role, provide the minimum Ansible Container version. 22 | # min_ansible_container_version: 23 | 24 | # 25 | # Provide a list of supported platforms, and for each platform a list of versions. 26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'. 27 | # To view available platforms and versions (or releases), visit: 28 | # https://galaxy.ansible.com/api/v1/platforms/ 29 | # 30 | # platforms: 31 | # - name: Fedora 32 | # versions: 33 | # - all 34 | # - 25 35 | # - name: SomePlatform 36 | # versions: 37 | # - all 38 | # - 1.0 39 | # - 7 40 | # - 99.99 41 | 42 | galaxy_tags: [] 43 | # List tags for your role here, one per line. A tag is a keyword that describes 44 | # and categorizes the role. Users find roles by searching for tags. Be sure to 45 | # remove the '[]' above, if you add tags to this list. 46 | # 47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 48 | # Maximum 20 tags per role. 49 | 50 | dependencies: [] 51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 52 | # if you add dependencies to this list. 53 | -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for vcd_vapp_vm_snapshot 3 | # 4 | - name: create vm snapshot 5 | vcd_vapp_vm_snapshot: 6 | user: acmeadmin 7 | org: Acme 8 | password: XXXXXXXXXX 9 | vdc_name: ACME_PAYG 10 | vapp_name: acme_vapp 11 | vms: 12 | - name: sample-2 13 | mem_snapshot: true 14 | snapshot_name: snap_sample 15 | state: present 16 | register: output 17 | 18 | - name: create vm snapshot output 19 | debug: 20 | msg: '{{ output }}' 21 | 22 | - name: list vm snapshot 23 | vcd_vapp_vm_snapshot: 24 | user: acmeadmin 25 | org: Acme 26 | password: XXXXXXXXXX 27 | vdc_name: ACME_PAYG 28 | vapp_name: acme_vapp 29 | vms: 30 | - name: sample-2 31 | operation: list 32 | register: output 33 | 34 | - name: list vm snapshot output 35 | debug: 36 | msg: '{{ output }}' 37 | 38 | - name: revert vm snapshot 39 | vcd_vapp_vm_snapshot: 40 | user: acmeadmin 41 | org: Acme 42 | password: XXXXXXXXXX 43 | vdc_name: ACME_PAYG 44 | vapp_name: acme_vapp 45 | vms: 46 | - name: sample-2 47 | operation: revert 48 | register: output 49 | 50 | - name: revert vm snapshot output 51 | debug: 52 | msg: '{{ output }}' 53 | 54 | - name: list vm snapshot 55 | vcd_vapp_vm_snapshot: 56 | user: acmeadmin 57 | org: Acme 58 | password: XXXXXXXXXX 59 | vdc_name: ACME_PAYG 60 | vapp_name: acme_vapp 61 | vms: 62 | - name: sample-2 63 | operation: list 64 | register: output 65 | 66 | - name: list vm snapshot output 67 | debug: 68 | msg: '{{ output }}' 69 | 70 | - name: delete vm snapshot 71 | vcd_vapp_vm_snapshot: 72 | user: acmeadmin 73 | org: Acme 74 | password: XXXXXXXXXX 75 | vdc_name: ACME_PAYG 76 | vapp_name: acme_vapp 77 | vms: 78 | - name: sample-2 79 | state: absent 80 | register: output 81 | 82 | - name: delete vm snapshot output 83 | debug: 84 | msg: '{{ output }}' -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - vcd_vapp_vm_snapshot -------------------------------------------------------------------------------- /roles/vcd_vapp_vm_snapshot/vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for vcd_vapp_vm_snapshot -------------------------------------------------------------------------------- /roles/vdc/README.md: -------------------------------------------------------------------------------- 1 | Role Name 2 | ========= 3 | 4 | A brief description of the role goes here. 5 | 6 | Requirements 7 | ------------ 8 | 9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. 10 | 11 | Role Variables 12 | -------------- 13 | 14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. 15 | 16 | Dependencies 17 | ------------ 18 | 19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. 20 | 21 | Example Playbook 22 | ---------------- 23 | 24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 25 | 26 | - hosts: servers 27 | roles: 28 | - { role: username.rolename, x: 42 } 29 | 30 | License 31 | ------- 32 | 33 | BSD 2-Clause or GPLv3 34 | 35 | Author Information 36 | ------------------ 37 | 38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed). 39 | -------------------------------------------------------------------------------- /roles/vdc/defaults/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # defaults file for roles/vdc 5 | -------------------------------------------------------------------------------- /roles/vdc/handlers/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # handlers file for roles/vdc 5 | -------------------------------------------------------------------------------- /roles/vdc/meta/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | galaxy_info: 5 | author: your name 6 | description: your description 7 | company: your company (optional) 8 | 9 | # If the issue tracker for your role is not on github, uncomment the 10 | # next line and provide a value 11 | # issue_tracker_url: http://example.com/issue/tracker 12 | 13 | # Some suggested licenses: 14 | # - BSD (default) 15 | # - MIT 16 | # - GPLv2 17 | # - GPLv3 18 | # - Apache 19 | # - CC-BY 20 | license: license (BSD, GPLv3) 21 | 22 | min_ansible_version: 1.2 23 | 24 | # If this a Container Enabled role, provide the minimum Ansible Container version. 25 | # min_ansible_container_version: 26 | 27 | # Optionally specify the branch Galaxy will use when accessing the GitHub 28 | # repo for this role. During role install, if no tags are available, 29 | # Galaxy will use this branch. During import Galaxy will access files on 30 | # this branch. If Travis integration is configured, only notifications for this 31 | # branch will be accepted. Otherwise, in all cases, the repo's default branch 32 | # (usually master) will be used. 33 | #github_branch: 34 | 35 | # 36 | # platforms is a list of platforms, and each platform has a name and a list of versions. 37 | # 38 | # platforms: 39 | # - name: Fedora 40 | # versions: 41 | # - all 42 | # - 25 43 | # - name: SomePlatform 44 | # versions: 45 | # - all 46 | # - 1.0 47 | # - 7 48 | # - 99.99 49 | 50 | galaxy_tags: [] 51 | # List tags for your role here, one per line. A tag is a keyword that describes 52 | # and categorizes the role. Users find roles by searching for tags. Be sure to 53 | # remove the '[]' above, if you add tags to this list. 54 | # 55 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters. 56 | # Maximum 20 tags per role. 57 | 58 | dependencies: [] 59 | # List your role dependencies here, one per line. Be sure to remove the '[]' above, 60 | # if you add dependencies to this list. 61 | -------------------------------------------------------------------------------- /roles/vdc/tasks/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # tasks file for vdc 5 | 6 | - name: create org vdc 7 | vcd_org_vdc: 8 | vdc_org_name: Acme 9 | vdc_name: ACME_PAYGG 10 | provider_vdc_name: PVDC 11 | is_enabled: true 12 | storage_profiles: 13 | - name: "*" 14 | enabled: true 15 | units: MB 16 | limit: 100000 17 | default: true 18 | state: present 19 | register: output 20 | 21 | - name: create org vdc output 22 | debug: 23 | msg: '{{ output }}' 24 | 25 | 26 | - name: update org vdc 27 | vcd_org_vdc: 28 | vdc_org_name: Acme 29 | vdc_name: ACME_PAYGG 30 | resource_guaranteed_cpu: 0.2 31 | resource_guaranteed_memory: 0.2 32 | vcpu_in_mhz: 10000 33 | state: "update" 34 | register: output 35 | 36 | - name: update org vdc output 37 | debug: 38 | msg: '{{ output }}' 39 | 40 | - name: list storage profiles 41 | vcd_org_vdc: 42 | vdc_org_name: Acme 43 | vdc_name: ACME_PAYGG 44 | operation: list_storage_profiles 45 | register: output 46 | 47 | - name: list storage profiles output 48 | debug: 49 | msg: '{{ output }}' 50 | 51 | - name: add storage profiles 52 | vcd_org_vdc: 53 | vdc_org_name: Acme 54 | vdc_name: ACME_PAYGG 55 | storage_profiles: 56 | - name: 'VM Encryption Policy' 57 | enabled: true 58 | default: false 59 | limit: 1000 60 | operation: add_storage_profile 61 | register: output 62 | 63 | - name: add storage output 64 | debug: 65 | msg: '{{ output }}' 66 | 67 | - name: update storage profiles 68 | vcd_org_vdc: 69 | vdc_org_name: Acme 70 | vdc_name: ACME_PAYGG 71 | storage_profiles: 72 | - name: 'VM Encryption Policy' 73 | enabled: false 74 | operation: update_storage_profile 75 | register: output 76 | 77 | - name: update storage output 78 | debug: 79 | msg: '{{ output }}' 80 | 81 | - name: delete storage profiles 82 | vcd_org_vdc: 83 | vdc_org_name: Acme 84 | vdc_name: ACME_PAYGG 85 | storage_profiles: 86 | - name: 'VM Encryption Policy' 87 | operation: delete_storage_profile 88 | register: output 89 | 90 | - name: delete storage output 91 | debug: 92 | msg: '{{ output }}' 93 | 94 | - name: list storage profiles 95 | vcd_org_vdc: 96 | vdc_org_name: Acme 97 | vdc_name: ACME_PAYGG 98 | operation: list_storage_profiles 99 | register: output 100 | 101 | - name: list storage profiles output 102 | debug: 103 | msg: '{{ output }}' 104 | 105 | - name: delete vdc 106 | vcd_org_vdc: 107 | vdc_name: ACME_PAYGG 108 | provider_vdc_name: PVDC 109 | vdc_org_name: Acme 110 | state: absent 111 | register: output 112 | 113 | - name: delete vdc output 114 | debug: 115 | msg: '{{ output }}' 116 | -------------------------------------------------------------------------------- /roles/vdc/tests/inventory: -------------------------------------------------------------------------------- 1 | localhost 2 | 3 | -------------------------------------------------------------------------------- /roles/vdc/tests/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | - hosts: localhost 5 | remote_user: root 6 | roles: 7 | - roles/vdc 8 | -------------------------------------------------------------------------------- /roles/vdc/vars/main.yml: -------------------------------------------------------------------------------- 1 | # Copyright © 2018 VMware, Inc. All Rights Reserved. 2 | # SPDX-License-Identifier: BSD-2-Clause OR GPL-3.0-only 3 | --- 4 | # vars file for roles/vdc 5 | 6 | vdc_name: "test_vdc_110" 7 | --------------------------------------------------------------------------------