def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( id=dict(), name=dict(required=True), gateway=dict(), netmask=dict(), start_ip=dict(), end_ip=dict(), zone=dict(), state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_pod = AnsibleCloudStackPod(module) state = module.params.get('state') if state in ['absent']: pod = acs_pod.absent_pod() else: pod = acs_pod.present_pod() result = acs_pod.get_result(pod) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( id=dict(required=True, type='int'), name=dict(), endpoint=dict(), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), required_if=[ ('state', 'present', ['name', 'endpoint']), ], supports_check_mode=True ) acs_region = AnsibleCloudStackRegion(module) state = module.params.get('state') if state == 'absent': region = acs_region.absent_region() else: region = acs_region.present_region() result = acs_region.get_result(region) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( ip_address=dict(required=False), state=dict(choices=['present', 'absent'], default='present'), vpc=dict(), network=dict(), zone=dict(), domain=dict(), account=dict(), project=dict(), tags=dict(type='list', aliases=['tag']), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), required_if=[ ('state', 'absent', ['ip_address', 'tags'], True), ], supports_check_mode=True ) acs_ip_address = AnsibleCloudStackIPAddress(module) state = module.params.get('state') if state in ['absent']: ip_address = acs_ip_address.disassociate_ip_address() else: ip_address = acs_ip_address.present_ip_address() result = acs_ip_address.get_result(ip_address) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), affinty_type=dict(removed_in_version='2.9'), affinity_type=dict(), description=dict(), state=dict(choices=['present', 'absent'], default='present'), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=( ['affinity_type', 'affinty_type'], ), supports_check_mode=True ) acs_ag = AnsibleCloudStackAffinityGroup(module) state = module.params.get('state') if state in ['absent']: affinity_group = acs_ag.remove_affinity_group() else: affinity_group = acs_ag.create_affinity_group() result = acs_ag.get_result(affinity_group) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), state=dict(default='present', choices=['present', 'absent']), domain=dict(), account=dict(), project=dict(), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_ig = AnsibleCloudStackInstanceGroup(module) state = module.params.get('state') if state in ['absent']: instance_group = acs_ig.absent_instance_group() else: instance_group = acs_ig.present_instance_group() result = acs_ig.get_result(instance_group) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( vpc=dict(required=True), state=dict(choices=['present', 'absent'], default='present'), domain=dict(), account=dict(), project=dict(), zone=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_vpn_gw = AnsibleCloudStackVpnGateway(module) state = module.params.get('state') if state == "absent": vpn_gateway = acs_vpn_gw.absent_vpn_gateway() else: vpn_gateway = acs_vpn_gw.present_vpn_gateway() result = acs_vpn_gw.get_result(vpn_gateway) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( uuid=dict(default=None, aliases=["id"]), name=dict(required=True), description=dict(default=None), role_type=dict(choices=["User", "DomainAdmin", "ResourceAdmin", "Admin"], default="User"), state=dict(choices=["present", "absent"], default="present"), ) ) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) try: acs_role = AnsibleCloudStackRole(module) state = module.params.get("state") if state == "absent": role = acs_role.absent_role() else: role = acs_role.present_role() result = acs_role.get_result(role) except CloudStackException as e: module.fail_json(msg="CloudStackException: %s" % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( path=dict(required=True), state=dict(choices=['present', 'absent'], default='present'), network_domain=dict(), clean_up=dict(type='bool', default=False), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_dom = AnsibleCloudStackDomain(module) state = module.params.get('state') if state in ['absent']: domain = acs_dom.absent_domain() else: domain = acs_dom.present_domain() result = acs_dom.get_result(domain) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( vm=dict(required=True, aliases=['name']), network=dict(required=True), vpc=dict(), ip_address=dict(), state=dict(choices=['present', 'absent'], default='present'), domain=dict(), account=dict(), project=dict(), zone=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True, ) acs_nic = AnsibleCloudStackInstanceNic(module) state = module.params.get('state') if state == 'absent': nic = acs_nic.absent_nic() else: nic = acs_nic.present_nic() result = acs_nic.get_result(nic) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True, aliases=['ip_address']), url=dict(), password=dict(no_log=True), username=dict(), hypervisor=dict(choices=CS_HYPERVISORS), allocation_state=dict(choices=['enabled', 'disabled', 'maintenance']), pod=dict(), cluster=dict(), host_tags=dict(type='list', aliases=['host_tag']), zone=dict(), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_host = AnsibleCloudStackHost(module) state = module.params.get('state') if state == 'absent': host = acs_host.absent_host() else: host = acs_host.present_host() result = acs_host.get_result(host) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), description=dict(), vpc=dict(required=True), state=dict(choices=['present', 'absent'], default='present'), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_network_acl = AnsibleCloudStackNetworkAcl(module) state = module.params.get('state') if state == 'absent': network_acl = acs_network_acl.absent_network_acl() else: network_acl = acs_network_acl.present_network_acl() result = acs_network_acl.get_result(network_acl) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True, aliases=['display_name']), vm=dict(required=True), description=dict(), zone=dict(), snapshot_memory=dict(type='bool', default=False), state=dict(choices=['present', 'absent', 'revert'], default='present'), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_vmsnapshot = AnsibleCloudStackVmSnapshot(module) state = module.params.get('state') if state in ['revert']: snapshot = acs_vmsnapshot.revert_vm_to_snapshot() elif state in ['absent']: snapshot = acs_vmsnapshot.remove_snapshot() else: snapshot = acs_vmsnapshot.create_snapshot() result = acs_vmsnapshot.get_result(snapshot) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), service_offering=dict(), state=dict(choices=['present', 'started', 'stopped', 'restarted', 'absent'], default="present"), domain=dict(), account=dict(), project=dict(), zone=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_router = AnsibleCloudStackRouter(module) state = module.params.get('state') if state in ['absent']: router = acs_router.absent_router() else: router = acs_router.present_router() result = acs_router.get_result(router) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), description=dict(), state=dict(choices=['present', 'absent'], default='present'), project=dict(), account=dict(), domain=dict(), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_sg = AnsibleCloudStackSecurityGroup(module) state = module.params.get('state') if state in ['absent']: sg = acs_sg.remove_security_group() else: sg = acs_sg.create_security_group() result = acs_sg.get_result(sg) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( ip_address=dict(required=True), vm=dict(), vm_guest_ip=dict(), network=dict(), vpc=dict(), state=dict(choices=['present', 'absent'], default='present'), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_static_nat = AnsibleCloudStackStaticNat(module) state = module.params.get('state') if state in ['absent']: ip_address = acs_static_nat.absent_static_nat() else: ip_address = acs_static_nat.present_static_nat() result = acs_static_nat.get_result(ip_address) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), display_text=dict(), state=dict(choices=['present', 'absent', 'active', 'suspended'], default='present'), domain=dict(), account=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_project = AnsibleCloudStackProject(module) state = module.params.get('state') if state in ['absent']: project = acs_project.absent_project() elif state in ['active', 'suspended']: project = acs_project.state_project(state=state) else: project = acs_project.present_project() result = acs_project.get_result(project) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( uuid=dict(aliases=['id']), name=dict(required=True), description=dict(), role_type=dict(choices=['User', 'DomainAdmin', 'ResourceAdmin', 'Admin'], default='User'), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_role = AnsibleCloudStackRole(module) state = module.params.get('state') if state == 'absent': role = acs_role.absent_role() else: role = acs_role.present_role() result = acs_role.get_result(role) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), ip_address=dict(aliases=['public_ip']), vms=dict(required=True, aliases=['vm'], type='list'), state=dict(choices=['present', 'absent'], default='present'), zone=dict(), domain=dict(), project=dict(), account=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_lb_rule_member = AnsibleCloudStackLBRuleMember(module) state = module.params.get('state') if state in ['absent']: rule = acs_lb_rule_member.remove_members() else: rule = acs_lb_rule_member.add_members() result = acs_lb_rule_member.get_result(rule) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( vm=dict(required=True, aliases=['name']), vm_guest_ip=dict(aliases=['secondary_ip']), network=dict(), vpc=dict(), state=dict(choices=['present', 'absent'], default='present'), domain=dict(), account=dict(), project=dict(), zone=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True, required_if=([ ('state', 'absent', ['vm_guest_ip']) ]) ) acs_instance_nic_secondaryip = AnsibleCloudStackInstanceNicSecondaryIp(module) state = module.params.get('state') if state == 'absent': nic = acs_instance_nic_secondaryip.absent_nic_ip() else: nic = acs_instance_nic_secondaryip.present_nic_ip() result = acs_instance_nic_secondaryip.get_result(nic) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), public_key=dict(), domain=dict(), account=dict(), project=dict(), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) if not HAS_LIB_SSHPUBKEYS: module.fail_json(msg="python library sshpubkeys required: pip install sshpubkeys") acs_sshkey = AnsibleCloudStackSshKey(module) state = module.params.get('state') if state in ['absent']: ssh_key = acs_sshkey.remove_ssh_key() else: public_key = module.params.get('public_key') if public_key: ssh_key = acs_sshkey.register_ssh_key(public_key) else: ssh_key = acs_sshkey.create_ssh_key() result = acs_sshkey.get_result(ssh_key) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), display_text=dict(), state=dict(choices=['enabled', 'present', 'disabled', 'absent'], default='present'), service_capabilities=dict(type='list', aliases=['service_capability']), service_offering=dict(), supported_services=dict(type='list', aliases=['supported_service']), service_providers=dict(type='list', aliases=['service_provider']), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_vpc_offering = AnsibleCloudStackVPCOffering(module) state = module.params.get('state') if state in ['absent']: vpc_offering = acs_vpc_offering.delete_vpc_offering() else: vpc_offering = acs_vpc_offering.create_or_update() result = acs_vpc_offering.get_result(vpc_offering) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), display_text=dict(), network_offering=dict(), zone=dict(), start_ip=dict(), end_ip=dict(), gateway=dict(), netmask=dict(), start_ipv6=dict(), end_ipv6=dict(), cidr_ipv6=dict(), gateway_ipv6=dict(), vlan=dict(), vpc=dict(), isolated_pvlan=dict(), clean_up=dict(type='bool', default=False), network_domain=dict(), subdomain_access=dict(type='bool'), state=dict(choices=['present', 'absent', 'restarted'], default='present'), acl=dict(), acl_type=dict(choices=['account', 'domain']), project=dict(), domain=dict(), account=dict(), poll_async=dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ ['netmask', 'gateway'], ]) module = AnsibleModule( argument_spec=argument_spec, required_together=required_together, supports_check_mode=True ) acs_network = AnsibleCloudStackNetwork(module) state = module.params.get('state') if state == 'absent': network = acs_network.absent_network() elif state == 'restarted': network = acs_network.restart_network() else: network = acs_network.present_network() result = acs_network.get_result(network) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( ip_address=dict(), network=dict(), cidrs=dict(type='list', default='0.0.0.0/0', aliases=['cidr']), protocol=dict(choices=['tcp', 'udp', 'icmp', 'all'], default='tcp'), type=dict(choices=['ingress', 'egress'], default='ingress'), icmp_type=dict(type='int'), icmp_code=dict(type='int'), start_port=dict(type='int', aliases=['port']), end_port=dict(type='int'), state=dict(choices=['present', 'absent'], default='present'), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag'], default=None), )) required_together = cs_required_together() required_together.extend([ ['icmp_type', 'icmp_code'], ]) module = AnsibleModule( argument_spec=argument_spec, required_together=required_together, required_one_of=( ['ip_address', 'network'], ), mutually_exclusive=( ['icmp_type', 'start_port'], ['icmp_type', 'end_port'], ['ip_address', 'network'], ), supports_check_mode=True ) acs_fw = AnsibleCloudStackFirewall(module) state = module.params.get('state') if state in ['absent']: fw_rule = acs_fw.remove_firewall_rule() else: fw_rule = acs_fw.create_firewall_rule() result = acs_fw.get_result(fw_rule) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( network_acl=dict(required=True, aliases=['acl']), rule_position=dict(required=True, type='int', aliases=['number']), vpc=dict(required=True), cidr=dict(default='0.0.0.0/0'), protocol=dict(choices=['tcp', 'udp', 'icmp', 'all', 'by_number'], default='tcp'), protocol_number=dict(type='int', choices=list(range(0, 256))), traffic_type=dict(choices=['ingress', 'egress'], aliases=['type'], default='ingress'), action_policy=dict(choices=['allow', 'deny'], aliases=['action'], default='allow'), icmp_type=dict(type='int'), icmp_code=dict(type='int'), start_port=dict(type='int', aliases=['port']), end_port=dict(type='int'), state=dict(choices=['present', 'absent'], default='present'), zone=dict(), domain=dict(), account=dict(), project=dict(), tags=dict(type='list', aliases=['tag']), poll_async=dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ ['icmp_type', 'icmp_code'], ]) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=( ['icmp_type', 'start_port'], ['icmp_type', 'end_port'], ), supports_check_mode=True ) acs_network_acl_rule = AnsibleCloudStackNetworkAclRule(module) state = module.params.get('state') if state == 'absent': network_acl_rule = acs_network_acl_rule.absent_network_acl_rule() else: network_acl_rule = acs_network_acl_rule.present_network_acl_rule() result = acs_network_acl_rule.get_result(network_acl_rule) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), display_text=dict(), cpu_number=dict(type='int'), cpu_speed=dict(type='int'), limit_cpu_usage=dict(type='bool'), deployment_planner=dict(), domain=dict(), host_tags=dict(type='list', aliases=['host_tag']), hypervisor_snapshot_reserve=dict(type='int'), disk_bytes_read_rate=dict(type='int'), disk_bytes_write_rate=dict(type='int'), disk_iops_customized=dict(type='bool'), disk_iops_read_rate=dict(type='int'), disk_iops_write_rate=dict(type='int'), disk_iops_max=dict(type='int'), disk_iops_min=dict(type='int'), is_system=dict(type='bool', default=False), is_volatile=dict(type='bool'), is_iops_customized=dict(type='bool'), memory=dict(type='int'), network_rate=dict(type='int'), offer_ha=dict(type='bool'), provisioning_type=dict(choices=['thin', 'sparse', 'fat']), service_offering_details=dict(type='bool'), storage_type=dict(choice=['local', 'shared']), system_vm_type=dict(choice=['domainrouter', 'consoleproxy', 'secondarystoragevm']), storage_tags=dict(type='list', aliases=['storage_tag']), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_so = AnsibleCloudStackServiceOffering(module) state = module.params.get('state') if state == "absent": service_offering = acs_so.absent_service_offering() else: service_offering = acs_so.present_service_offering() result = acs_so.get_result(service_offering) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), disk_offering=dict(), display_volume=dict(type='bool'), max_iops=dict(type='int'), min_iops=dict(type='int'), size=dict(type='int'), snapshot=dict(), vm=dict(), device_id=dict(type='int'), custom_id=dict(), force=dict(type='bool', default=False), shrink_ok=dict(type='bool', default=False), state=dict(choices=['present', 'absent', 'attached', 'detached'], default='present'), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=( ['snapshot', 'disk_offering'], ), supports_check_mode=True ) acs_vol = AnsibleCloudStackVolume(module) state = module.params.get('state') if state in ['absent']: volume = acs_vol.absent_volume() elif state in ['attached']: volume = acs_vol.attached_volume() elif state in ['detached']: volume = acs_vol.detached_volume() else: volume = acs_vol.present_volume() result = acs_vol.get_result(volume) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( zone=dict(required=True, aliases=['name']), )) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) cs_zone_facts = AnsibleCloudStackZoneFacts(module=module).run() cs_facts_result = dict(changed=False, ansible_facts=cs_zone_facts) module.exit_json(**cs_facts_result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), domain=dict(), account=dict(), project=dict(), )) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) cs_instance_facts = AnsibleCloudStackInstanceFacts(module=module).run() cs_facts_result = dict(changed=False, ansible_facts=cs_instance_facts) module.exit_json(**cs_facts_result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), state=dict(choices=['present', 'absent', 'enabled', 'disabled', 'locked', 'unlocked'], default='present'), account_type=dict(choices=['user', 'root_admin', 'domain_admin'], default='user'), network_domain=dict(), domain=dict(default='ROOT'), email=dict(), first_name=dict(), last_name=dict(), username=dict(), password=dict(no_log=True), timezone=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_acc = AnsibleCloudStackAccount(module) state = module.params.get('state') if state in ['absent']: account = acs_acc.absent_account() elif state in ['enabled', 'unlocked']: account = acs_acc.enable_account() elif state in ['disabled']: account = acs_acc.disable_account() elif state in ['locked']: account = acs_acc.lock_account() else: account = acs_acc.present_account() result = acs_acc.get_result(account) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), domain=dict(), account=dict(), project=dict(), )) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) acs_instance_facts = AnsibleCloudStackInstanceFacts(module=module) cs_instance_facts = acs_instance_facts.get_result_and_facts( facts_name='cloudstack_instance', resource=acs_instance_facts.run() ) module.exit_json(**cs_instance_facts)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( network=dict(type='str'), physical_network=dict(type='str'), zone=dict(type='str'), start_ip=dict(type='str', required=True), end_ip=dict(type='str'), gateway=dict(type='str'), netmask=dict(type='str'), start_ipv6=dict(type='str'), end_ipv6=dict(type='str'), gateway_ipv6=dict(type='str'), cidr_ipv6=dict(type='str'), vlan=dict(type='str'), state=dict(choices=['present', 'absent'], default='present'), domain=dict(type='str'), account=dict(type='str'), project=dict(type='str'), for_virtual_network=dict(type='bool', default=False), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=( ['account', 'project'], ), required_if=(("state", "present", ("gateway", "netmask")),), supports_check_mode=True, ) acs_vlan_ip_range = AnsibleCloudStackVlanIpRange(module) state = module.params.get('state') if state == 'absent': ipr = acs_vlan_ip_range.absent_vlan_ip_range() else: ipr = acs_vlan_ip_range.present_vlan_ip_range() result = acs_vlan_ip_range.get_result(ipr) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( security_group=dict(required=True), type=dict(choices=['ingress', 'egress'], default='ingress'), cidr=dict(default='0.0.0.0/0'), user_security_group=dict(), protocol=dict(choices=['tcp', 'udp', 'icmp', 'ah', 'esp', 'gre'], default='tcp'), icmp_type=dict(type='int'), icmp_code=dict(type='int'), start_port=dict(type='int', aliases=['port']), end_port=dict(type='int'), state=dict(choices=['present', 'absent'], default='present'), project=dict(), poll_async=dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ ['icmp_type', 'icmp_code'], ]) module = AnsibleModule(argument_spec=argument_spec, required_together=required_together, mutually_exclusive=( ['icmp_type', 'start_port'], ['icmp_type', 'end_port'], ['icmp_code', 'start_port'], ['icmp_code', 'end_port'], ), supports_check_mode=True) acs_sg_rule = AnsibleCloudStackSecurityGroupRule(module) state = module.params.get('state') if state in ['absent']: sg_rule = acs_sg_rule.remove_rule() else: sg_rule = acs_sg_rule.add_rule() result = acs_sg_rule.get_result(sg_rule) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( state=dict(choices=['enabled', 'present', 'disabled', 'absent'], default='present'), display_text=dict(), guest_ip_type=dict(choices=['Shared', 'Isolated']), name=dict(required=True), supported_services=dict(type='list', aliases=['supported_service']), traffic_type=dict(default='Guest'), availability=dict(), conserve_mode=dict(type='bool'), details=dict(type='list'), egress_default_policy=dict(choices=['allow', 'deny']), persistent=dict(type='bool'), keepalive_enabled=dict(type='bool'), max_connections=dict(type='int'), network_rate=dict(type='int'), service_capabilities=dict(type='list', aliases=['service_capability']), service_offering=dict(), service_providers=dict(type='list', aliases=['service_provider']), specify_ip_ranges=dict(type='bool'), specify_vlan=dict(type='bool'), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_network_offering = AnsibleCloudStackNetworkOffering(module) state = module.params.get('state') if state in ['absent']: network_offering = acs_network_offering.delete_network_offering() else: network_offering = acs_network_offering.create_or_update() result = acs_network_offering.get_result(network_offering) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), display_text=dict(), url=dict(), os_type=dict(), zone=dict(), cross_zones=dict(type='bool', default=False), iso_filter=dict(default='self', choices=[ 'featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community' ]), domain=dict(), account=dict(), project=dict(), checksum=dict(), is_ready=dict(type='bool', default=False), bootable=dict(type='bool'), is_featured=dict(type='bool'), is_dynamically_scalable=dict(type='bool'), state=dict(choices=['present', 'absent'], default='present'), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=(['zone', 'cross_zones'], ), supports_check_mode=True) acs_iso = AnsibleCloudStackIso(module) state = module.params.get('state') if state in ['absent']: iso = acs_iso.absent_iso() else: iso = acs_iso.present_iso() result = acs_iso.get_result(iso) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict(name=dict(required=True), value=dict(type='str', required=True), zone=dict(), storage=dict(), cluster=dict(), account=dict(), domain=dict(default='ROOT'))) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_configuration = AnsibleCloudStackConfiguration(module) configuration = acs_configuration.present_configuration() result = acs_configuration.get_result(configuration) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( ip_address = dict(required=True), protocol= dict(choices=['tcp', 'udp'], default='tcp'), public_port = dict(type='int', required=True), public_end_port = dict(type='int', default=None), private_port = dict(type='int', required=True), private_end_port = dict(type='int', default=None), state = dict(choices=['present', 'absent'], default='present'), open_firewall = dict(type='bool', default=False), vm_guest_ip = dict(default=None), vm = dict(default=None), vpc = dict(default=None), network = dict(default=None), zone = dict(default=None), domain = dict(default=None), account = dict(default=None), project = dict(default=None), poll_async = dict(type='bool', default=True), tags=dict(type='list', aliases=['tag'], default=None), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) try: acs_pf = AnsibleCloudStackPortforwarding(module) state = module.params.get('state') if state in ['absent']: pf_rule = acs_pf.absent_portforwarding_rule() else: pf_rule = acs_pf.present_portforwarding_rule() result = acs_pf.get_result(pf_rule) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( security_group=dict(required=True), type=dict(choices=['ingress', 'egress'], default='ingress'), cidr=dict(default='0.0.0.0/0'), user_security_group=dict(), protocol=dict(choices=['tcp', 'udp', 'icmp', 'ah', 'esp', 'gre'], default='tcp'), icmp_type=dict(type='int'), icmp_code=dict(type='int'), start_port=dict(type='int', aliases=['port']), end_port=dict(type='int'), state=dict(choices=['present', 'absent'], default='present'), project=dict(), poll_async=dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ ['icmp_type', 'icmp_code'], ]) module = AnsibleModule( argument_spec=argument_spec, required_together=required_together, mutually_exclusive=( ['icmp_type', 'start_port'], ['icmp_type', 'end_port'], ['icmp_code', 'start_port'], ['icmp_code', 'end_port'], ), supports_check_mode=True ) acs_sg_rule = AnsibleCloudStackSecurityGroupRule(module) state = module.params.get('state') if state in ['absent']: sg_rule = acs_sg_rule.remove_rule() else: sg_rule = acs_sg_rule.add_rule() result = acs_sg_rule.get_result(sg_rule) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), description=dict(), algorithm=dict(choices=['source', 'roundrobin', 'leastconn'], default='source'), private_port=dict(type='int'), public_port=dict(type='int'), protocol=dict(), state=dict(choices=['present', 'absent'], default='present'), ip_address=dict(required=True, aliases=['public_ip']), cidr=dict(), project=dict(), open_firewall=dict(type='bool', default=False), tags=dict(type='list', aliases=['tag']), zone=dict(), domain=dict(), account=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) try: acs_lb_rule = AnsibleCloudStackLBRule(module) state = module.params.get('state') if state in ['absent']: rule = acs_lb_rule.absent_lb_rule() else: rule = acs_lb_rule.present_lb_rule() result = acs_lb_rule.get_result(rule) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( volume=dict(default=None), volume_type=dict(choices=['DATADISK', 'ROOT'], default=None), vm=dict(default=None), device_id=dict(type='int', default=None), vpc=dict(default=None), interval_type=dict( default='daily', choices=['hourly', 'daily', 'weekly', 'monthly'], aliases=['interval']), schedule=dict(default=None), time_zone=dict(default='UTC', aliases=['timezone']), max_snaps=dict(type='int', default=8, aliases=['max']), state=dict(choices=['present', 'absent'], default='present'), domain=dict(default=None), account=dict(default=None), project=dict(default=None), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), required_one_of=(['vm', 'volume'], ), supports_check_mode=True) try: acs_snapshot_policy = AnsibleCloudStackSnapshotPolicy(module) state = module.params.get('state') if state in ['absent']: policy = acs_snapshot_policy.absent_snapshot_policy() else: policy = acs_snapshot_policy.present_snapshot_policy() result = acs_snapshot_policy.get_result(policy) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), storage_url=dict(), zone=dict(), pod=dict(), cluster=dict(), scope=dict(choices=['zone', 'cluster']), hypervisor=dict(), provider=dict(default='DefaultPrimary'), capacity_bytes=dict(type='int'), capacity_iops=dict(type='int'), managed=dict(type='bool'), storage_tags=dict(type='list', aliases=['storage_tag']), allocation_state=dict( choices=['enabled', 'disabled', 'maintenance']), state=dict(choices=['present', 'absent'], default='present'), )) required_together = cs_required_together() required_together.extend([ ['pod', 'cluster'], ]) module = AnsibleModule(argument_spec=argument_spec, required_together=required_together, required_if=[ ('state', 'present', ['storage_url']), ], supports_check_mode=True) acs_storage_pool = AnsibleCloudStackStoragePool(module) state = module.params.get('state') if state in ['absent']: pool = acs_storage_pool.absent_storage_pool() else: pool = acs_storage_pool.present_storage_pool() result = acs_storage_pool.get_result(pool) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), cidr=dict(), display_text=dict(), vpc_offering=dict(), network_domain=dict(), clean_up=dict(type='bool'), state=dict(choices=['present', 'absent', 'stopped', 'restarted'], default='present'), domain=dict(), account=dict(), project=dict(), zone=dict(), tags=dict(type='list', aliases=['tag']), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), required_if=[ ('state', 'present', ['cidr']), ], supports_check_mode=True, ) acs_vpc = AnsibleCloudStackVpc(module) state = module.params.get('state') if state == 'absent': vpc = acs_vpc.absent_vpc() elif state == 'restarted': vpc = acs_vpc.restart_vpc() else: vpc = acs_vpc.present_vpc() result = acs_vpc.get_result(vpc) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), zone=dict(), pod=dict(), cluster_type=dict(choices=['CloudManaged', 'ExternalManaged']), hypervisor=dict(choices=CS_HYPERVISORS), state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'), url=dict(), username=dict(), password=dict(no_log=True), guest_vswitch_name=dict(), guest_vswitch_type=dict(choices=['vmwaresvs', 'vmwaredvs']), public_vswitch_name=dict(), public_vswitch_type=dict(choices=['vmwaresvs', 'vmwaredvs']), vms_ip_address=dict(), vms_username=dict(), vms_password=dict(no_log=True), ovm3_cluster=dict(), ovm3_pool=dict(), ovm3_vip=dict(), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_cluster = AnsibleCloudStackCluster(module) state = module.params.get('state') if state in ['absent']: cluster = acs_cluster.absent_cluster() else: cluster = acs_cluster.present_cluster() result = acs_cluster.get_result(cluster) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( resource_type=dict(required=True, choices=RESOURCE_TYPES.keys(), aliases=['type']), limit=dict(default=-1, aliases=['max'], type='int'), domain=dict(), account=dict(), project=dict(), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_resource_limit = AnsibleCloudStackResourceLimit(module) resource_limit = acs_resource_limit.update_resource_limit() result = acs_resource_limit.get_result(resource_limit) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( vm=dict(required=True), domain=dict(), account=dict(), project=dict(), zone=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_password = AnsibleCloudStackPasswordReset(module) password = acs_password.reset_password() result = acs_password.get_result({'password': password}) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( vm=dict(type='str', required=True, aliases=['name']), vm_guest_ip=dict(type='str', aliases=['secondary_ip']), network=dict(type='str', ), vpc=dict(type='str'), state=dict(type='str', default='present', choices=['absent', 'present']), domain=dict(type='str'), account=dict(type='str'), project=dict(type='str'), zone=dict(type='str'), poll_async=dict(type='bool', default=True), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True, required_if=([('state', 'absent', ['vm_guest_ip']) ])) try: acs_nic = AnsibleCloudStackNic(module) state = module.params.get('state') if state == 'absent': nic = acs_nic.absent_nic() else: nic = acs_nic.present_nic() result = acs_nic.get_result(nic) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( id=dict(), name=dict(required=True), dns1=dict(), dns2=dict(), internal_dns1=dict(), internal_dns2=dict(), dns1_ipv6=dict(), dns2_ipv6=dict(), network_type=dict( default='basic', choices=['Basic', 'basic', 'Advanced', 'advanced']), network_domain=dict(), guest_cidr_address=dict(), dhcp_provider=dict(), local_storage_enabled=dict(type='bool'), securitygroups_enabled=dict(type='bool'), state=dict(choices=['present', 'enabled', 'disabled', 'absent'], default='present'), domain=dict(), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_zone = AnsibleCloudStackZone(module) state = module.params.get('state') if state in ['absent']: zone = acs_zone.absent_zone() else: zone = acs_zone.present_zone() result = acs_zone.get_result(zone) module.exit_json(**result)
def setup_module_object(): argument_spec = cs_argument_spec() argument_spec.update( dict(physical_network=dict(required=True), zone=dict(), state=dict(choices=['present', 'absent'], default='present'), traffic_type=dict( required=True, choices=['Management', 'Guest', 'Public', 'Storage']), hyperv_networklabel=dict(), isolation_method=dict(choices=['vlan', 'vxlan']), kvm_networklabel=dict(), ovm3_networklabel=dict(), vlan=dict(), vmware_networklabel=dict(), xen_networklabel=dict(), poll_async=dict(type='bool', default=True))) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) return module
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), public_key=dict(), domain=dict(), account=dict(), project=dict(), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) if not HAS_LIB_SSHPUBKEYS: module.fail_json( msg="python library sshpubkeys required: pip install sshpubkeys") try: acs_sshkey = AnsibleCloudStackSshKey(module) state = module.params.get('state') if state in ['absent']: ssh_key = acs_sshkey.remove_ssh_key() else: public_key = module.params.get('public_key') if public_key: ssh_key = acs_sshkey.register_ssh_key(public_key) else: ssh_key = acs_sshkey.create_ssh_key() result = acs_sshkey.get_result(ssh_key) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), display_text=dict(), state=dict(choices=['present', 'absent', 'active', 'suspended'], default='present'), domain=dict(), account=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) try: acs_project = AnsibleCloudStackProject(module) state = module.params.get('state') if state in ['absent']: project = acs_project.absent_project() elif state in ['active', 'suspended']: project = acs_project.state_project(state=state) else: project = acs_project.present_project() result = acs_project.get_result(project) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(required=True), display_text=dict(), domain=dict(), disk_size=dict(type='int'), display_offering=dict(type='bool'), hypervisor_snapshot_reserve=dict(type='int'), bytes_read_rate=dict(type='int'), bytes_write_rate=dict(type='int'), customized=dict(type='bool'), iops_read_rate=dict(type='int'), iops_write_rate=dict(type='int'), iops_max=dict(type='int'), iops_min=dict(type='int'), provisioning_type=dict(choices=['thin', 'sparse', 'fat']), storage_type=dict(choices=['local', 'shared']), storage_tags=dict(type='list', aliases=['storage_tag']), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True) acs_do = AnsibleCloudStackDiskOffering(module) state = module.params.get('state') if state == "absent": disk_offering = acs_do.absent_disk_offering() else: disk_offering = acs_do.present_disk_offering() result = acs_do.get_result(disk_offering) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( ip_address=dict(required=False), state=dict(choices=['present', 'absent'], default='present'), vpc=dict(), network=dict(), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), )) module = AnsibleModule(argument_spec=argument_spec, required_together=cs_required_together(), required_if=[ ('state', 'absent', ['ip_address']), ], supports_check_mode=True) try: acs_ip_address = AnsibleCloudStackIPAddress(module) state = module.params.get('state') if state in ['absent']: ip_address = acs_ip_address.disassociate_ip_address() else: ip_address = acs_ip_address.associate_ip_address() result = acs_ip_address.get_result(ip_address) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True, aliases=['ip_address']), url=dict(), password=dict(default=None, no_log=True), username=dict(default=None), hypervisor=dict(choices=CS_HYPERVISORS, default=None), allocation_state=dict(default=None), pod=dict(default=None), cluster=dict(default=None), host_tags=dict(default=None, type='list'), zone=dict(default=None), state=dict(choices=['present', 'absent'], default='present'), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) try: acs_host = AnsibleCloudStackHost(module) state = module.params.get('state') if state == 'absent': host = acs_host.absent_host() else: host = acs_host.present_host() result = acs_host.get_result(host) except CloudStackException as e: module.fail_json(msg='CloudStackException: %s' % str(e)) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), state=dict(choices=['present', 'absent'], default='present'), domain=dict(), account=dict(), project=dict(), cidrs=dict(type='list', aliases=['cidr']), esp_policy=dict(), esp_lifetime=dict(type='int'), gateway=dict(), ike_policy=dict(), ike_lifetime=dict(type='int'), ipsec_psk=dict(no_log=True), dpd=dict(type='bool'), force_encap=dict(type='bool'), poll_async=dict(type='bool', default=True), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), supports_check_mode=True ) acs_vpn_cgw = AnsibleCloudStackVpnCustomerGateway(module) state = module.params.get('state') if state == "absent": vpn_customer_gateway = acs_vpn_cgw.absent_vpn_customer_gateway() else: vpn_customer_gateway = acs_vpn_cgw.present_vpn_customer_gateway() result = acs_vpn_cgw.get_result(vpn_customer_gateway) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), disk_offering=dict(), display_volume=dict(type='bool'), max_iops=dict(type='int'), min_iops=dict(type='int'), size=dict(type='int'), snapshot=dict(), vm=dict(), device_id=dict(type='int'), custom_id=dict(), force=dict(type='bool', default=False), shrink_ok=dict(type='bool', default=False), state=dict(default='present', choices=[ 'present', 'absent', 'attached', 'detached', 'extracted', 'uploaded', ]), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), url=dict(), mode=dict(choices=['http_download', 'ftp_upload'], default='http_download'), format=dict(choices=['QCOW2', 'RAW', 'VHD', 'VHDX', 'OVA']), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=( ['snapshot', 'disk_offering'], ), required_if=[ ('state', 'uploaded', ['url', 'format']), ], supports_check_mode=True ) acs_vol = AnsibleCloudStackVolume(module) state = module.params.get('state') if state in ['absent']: volume = acs_vol.absent_volume() elif state in ['attached']: volume = acs_vol.attached_volume() elif state in ['detached']: volume = acs_vol.detached_volume() elif state == 'extracted': volume = acs_vol.extract_volume() elif state == 'uploaded': volume = acs_vol.upload_volume() else: volume = acs_vol.present_volume() result = acs_vol.get_result(volume) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update( dict( name=dict(), display_name=dict(), group=dict(), state=dict(choices=[ 'present', 'deployed', 'started', 'stopped', 'restarted', 'restored', 'absent', 'destroyed', 'expunged' ], default='present'), service_offering=dict(), cpu=dict(type='int'), cpu_speed=dict(type='int'), memory=dict(type='int'), template=dict(), iso=dict(), template_filter=dict(default="executable", aliases=['iso_filter'], choices=[ 'all', 'featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community' ]), networks=dict(type='list', aliases=['network']), ip_to_networks=dict(type='list', aliases=['ip_to_network']), ip_address=dict(defaul=None), ip6_address=dict(defaul=None), disk_offering=dict(), disk_size=dict(type='int'), root_disk_size=dict(type='int'), keyboard=dict(choices=[ 'de', 'de-ch', 'es', 'fi', 'fr', 'fr-be', 'fr-ch', 'is', 'it', 'jp', 'nl-be', 'no', 'pt', 'uk', 'us' ]), hypervisor=dict(choices=CS_HYPERVISORS), security_groups=dict(type='list', aliases=['security_group']), affinity_groups=dict(type='list', aliases=['affinity_group']), domain=dict(), account=dict(), project=dict(), user_data=dict(), zone=dict(), ssh_key=dict(), force=dict(type='bool', default=False), tags=dict(type='list', aliases=['tag']), poll_async=dict(type='bool', default=True), )) required_together = cs_required_together() required_together.extend([ ['cpu', 'cpu_speed', 'memory'], ]) module = AnsibleModule(argument_spec=argument_spec, required_together=required_together, required_one_of=(['display_name', 'name'], ), mutually_exclusive=(['template', 'iso'], ), supports_check_mode=True) acs_instance = AnsibleCloudStackInstance(module) state = module.params.get('state') if state in ['absent', 'destroyed']: instance = acs_instance.absent_instance() elif state in ['expunged']: instance = acs_instance.expunge_instance() elif state in ['restored']: acs_instance.present_instance() instance = acs_instance.restore_instance() elif state in ['present', 'deployed']: instance = acs_instance.present_instance() elif state in ['stopped']: acs_instance.present_instance(start_vm=False) instance = acs_instance.stop_instance() elif state in ['started']: acs_instance.present_instance() instance = acs_instance.start_instance() elif state in ['restarted']: acs_instance.present_instance() instance = acs_instance.restart_instance() if instance and 'state' in instance and instance['state'].lower( ) == 'error': module.fail_json(msg="Instance named '%s' in error state." % module.params.get('name')) result = acs_instance.get_result(instance) module.exit_json(**result)
def main(): argument_spec = cs_argument_spec() argument_spec.update(dict( name=dict(required=True), display_text=dict(), url=dict(), vm=dict(), snapshot=dict(), os_type=dict(), is_ready=dict(type='bool', default=False), is_public=dict(type='bool', default=True), is_featured=dict(type='bool', default=False), is_dynamically_scalable=dict(type='bool', default=False), is_extractable=dict(type='bool', default=False), is_routing=dict(type='bool'), checksum=dict(), template_filter=dict(default='self', choices=['featured', 'self', 'selfexecutable', 'sharedexecutable', 'executable', 'community']), hypervisor=dict(choices=CS_HYPERVISORS), requires_hvm=dict(type='bool', default=False), password_enabled=dict(type='bool', default=False), template_tag=dict(), sshkey_enabled=dict(type='bool', default=False), format=dict(choices=['QCOW2', 'RAW', 'VHD', 'OVA'], ), details=dict(), bits=dict(type='int', choices=[32, 64], default=64), state=dict(choices=['present', 'absent', 'extracted'], default='present'), cross_zones=dict(type='bool', default=False), mode=dict(choices=['http_download', 'ftp_upload'], default='http_download'), zone=dict(), domain=dict(), account=dict(), project=dict(), poll_async=dict(type='bool', default=True), tags=dict(type='list', aliases=['tag']), )) module = AnsibleModule( argument_spec=argument_spec, required_together=cs_required_together(), mutually_exclusive=( ['url', 'vm'], ['zone', 'cross_zones'], ), supports_check_mode=True ) acs_tpl = AnsibleCloudStackTemplate(module) state = module.params.get('state') if state in ['absent']: tpl = acs_tpl.remove_template() elif state in ['extracted']: tpl = acs_tpl.extract_template() else: if module.params.get('url'): tpl = acs_tpl.register_template() elif module.params.get('vm'): tpl = acs_tpl.create_template() else: module.fail_json(msg="one of the following is required on state=present: url,vm") result = acs_tpl.get_result(tpl) module.exit_json(**result)