mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-15 17:40:50 -07:00
Remove deprecated modules scheduled for removal in 3.0.0 (#1924)
* Remove deprecated modules scheduled for removal in 3.0.0. * Update BOTMETA. * Update ignore-2.12.txt. * Next release will be 3.0.0.
This commit is contained in:
parent
98af8161b2
commit
081c534d40
161 changed files with 167 additions and 10434 deletions
|
@ -1 +0,0 @@
|
|||
cloud/alicloud/ali_instance_facts.py
|
|
@ -1 +0,0 @@
|
|||
ali_instance_info.py
|
|
@ -383,9 +383,6 @@ def main():
|
|||
)
|
||||
)
|
||||
module = AnsibleModule(argument_spec=argument_spec)
|
||||
if module._name in ('ali_instance_facts', 'community.general.ali_instance_facts'):
|
||||
module.deprecate("The 'ali_instance_facts' module has been renamed to 'ali_instance_info'",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
if HAS_FOOTMARK is False:
|
||||
module.fail_json(msg=missing_required_lib('footmark'), exception=FOOTMARK_IMP_ERR)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
memset_memstore_info.py
|
|
@ -151,9 +151,6 @@ def main():
|
|||
),
|
||||
supports_check_mode=False
|
||||
)
|
||||
if module._name in ('memset_memstore_facts', 'community.general.memset_memstore_facts'):
|
||||
module.deprecate("The 'memset_memstore_facts' module has been renamed to 'memset_memstore_info'",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
# populate the dict with the user-provided vars.
|
||||
args = dict()
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
memset_server_info.py
|
|
@ -276,9 +276,6 @@ def main():
|
|||
),
|
||||
supports_check_mode=False
|
||||
)
|
||||
if module._name in ('memset_server_facts', 'community.general.memset_server_facts'):
|
||||
module.deprecate("The 'memset_server_facts' module has been renamed to 'memset_server_info'",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
# populate the dict with the user-provided vars.
|
||||
args = dict()
|
||||
|
|
|
@ -1,216 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# (c) 2016, Flavio Percoco <flavio@redhat.com>
|
||||
#
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.14
|
||||
why: For more details https://github.com/ansible/ansible/issues/61546.
|
||||
alternative: Use M(community.kubernetes.helm) instead.
|
||||
module: helm
|
||||
short_description: Manages Kubernetes packages with the Helm package manager
|
||||
author: "Flavio Percoco (@flaper87)"
|
||||
description:
|
||||
- Install, upgrade, delete and list packages with the Helm package manager.
|
||||
requirements:
|
||||
- "pyhelm"
|
||||
- "grpcio"
|
||||
options:
|
||||
host:
|
||||
description:
|
||||
- Tiller's server host.
|
||||
type: str
|
||||
default: "localhost"
|
||||
port:
|
||||
description:
|
||||
- Tiller's server port.
|
||||
type: int
|
||||
default: 44134
|
||||
namespace:
|
||||
description:
|
||||
- Kubernetes namespace where the chart should be installed.
|
||||
type: str
|
||||
default: "default"
|
||||
name:
|
||||
description:
|
||||
- Release name to manage.
|
||||
type: str
|
||||
state:
|
||||
description:
|
||||
- Whether to install C(present), remove C(absent), or purge C(purged) a package.
|
||||
choices: ['absent', 'purged', 'present']
|
||||
type: str
|
||||
default: "present"
|
||||
chart:
|
||||
description:
|
||||
- A map describing the chart to install. See examples for available options.
|
||||
type: dict
|
||||
default: {}
|
||||
values:
|
||||
description:
|
||||
- A map of value options for the chart.
|
||||
type: dict
|
||||
default: {}
|
||||
disable_hooks:
|
||||
description:
|
||||
- Whether to disable hooks during the uninstall process.
|
||||
type: bool
|
||||
default: 'no'
|
||||
'''
|
||||
|
||||
RETURN = ''' # '''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: Install helm chart
|
||||
community.general.helm:
|
||||
host: localhost
|
||||
chart:
|
||||
name: memcached
|
||||
version: 0.4.0
|
||||
source:
|
||||
type: repo
|
||||
location: https://kubernetes-charts.storage.googleapis.com
|
||||
state: present
|
||||
name: my-memcached
|
||||
namespace: default
|
||||
|
||||
- name: Uninstall helm chart
|
||||
community.general.helm:
|
||||
host: localhost
|
||||
state: absent
|
||||
name: my-memcached
|
||||
|
||||
- name: Install helm chart from a git repo
|
||||
community.general.helm:
|
||||
host: localhost
|
||||
chart:
|
||||
source:
|
||||
type: git
|
||||
location: https://github.com/user/helm-chart.git
|
||||
state: present
|
||||
name: my-example
|
||||
namespace: default
|
||||
values:
|
||||
foo: "bar"
|
||||
|
||||
- name: Install helm chart from a git repo specifying path
|
||||
community.general.helm:
|
||||
host: localhost
|
||||
chart:
|
||||
source:
|
||||
type: git
|
||||
location: https://github.com/helm/charts.git
|
||||
path: stable/memcached
|
||||
state: present
|
||||
name: my-memcached
|
||||
namespace: default
|
||||
values: "{{ lookup('file', '/path/to/file/values.yaml') | from_yaml }}"
|
||||
'''
|
||||
|
||||
import traceback
|
||||
HELM_IMPORT_ERR = None
|
||||
try:
|
||||
import grpc
|
||||
from pyhelm import tiller
|
||||
from pyhelm import chartbuilder
|
||||
except ImportError:
|
||||
HELM_IMPORT_ERR = traceback.format_exc()
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
|
||||
def install(module, tserver):
|
||||
changed = False
|
||||
params = module.params
|
||||
name = params['name']
|
||||
values = params['values']
|
||||
chart = module.params['chart']
|
||||
namespace = module.params['namespace']
|
||||
|
||||
chartb = chartbuilder.ChartBuilder(chart)
|
||||
r_matches = (x for x in tserver.list_releases()
|
||||
if x.name == name and x.namespace == namespace)
|
||||
installed_release = next(r_matches, None)
|
||||
if installed_release:
|
||||
if installed_release.chart.metadata.version != chart['version']:
|
||||
tserver.update_release(chartb.get_helm_chart(), False,
|
||||
namespace, name=name, values=values)
|
||||
changed = True
|
||||
else:
|
||||
tserver.install_release(chartb.get_helm_chart(), namespace,
|
||||
dry_run=False, name=name,
|
||||
values=values)
|
||||
changed = True
|
||||
|
||||
return dict(changed=changed)
|
||||
|
||||
|
||||
def delete(module, tserver, purge=False):
|
||||
changed = False
|
||||
params = module.params
|
||||
|
||||
if not module.params['name']:
|
||||
module.fail_json(msg='Missing required field name')
|
||||
|
||||
name = module.params['name']
|
||||
disable_hooks = params['disable_hooks']
|
||||
|
||||
try:
|
||||
tserver.uninstall_release(name, disable_hooks, purge)
|
||||
changed = True
|
||||
except grpc._channel._Rendezvous as exc:
|
||||
if 'not found' not in str(exc):
|
||||
raise exc
|
||||
|
||||
return dict(changed=changed)
|
||||
|
||||
|
||||
def main():
|
||||
"""The main function."""
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
host=dict(type='str', default='localhost'),
|
||||
port=dict(type='int', default=44134),
|
||||
name=dict(type='str', default=''),
|
||||
chart=dict(type='dict'),
|
||||
state=dict(
|
||||
choices=['absent', 'purged', 'present'],
|
||||
default='present'
|
||||
),
|
||||
# Install options
|
||||
values=dict(type='dict'),
|
||||
namespace=dict(type='str', default='default'),
|
||||
|
||||
# Uninstall options
|
||||
disable_hooks=dict(type='bool', default=False),
|
||||
),
|
||||
supports_check_mode=True)
|
||||
|
||||
if HELM_IMPORT_ERR:
|
||||
module.fail_json(msg=missing_required_lib('pyhelm'), exception=HELM_IMPORT_ERR)
|
||||
|
||||
host = module.params['host']
|
||||
port = module.params['port']
|
||||
state = module.params['state']
|
||||
tserver = tiller.Tiller(host, port)
|
||||
|
||||
if state == 'present':
|
||||
rst = install(module, tserver)
|
||||
|
||||
if state in 'absent':
|
||||
rst = delete(module, tserver)
|
||||
|
||||
if state in 'purged':
|
||||
rst = delete(module, tserver, True)
|
||||
|
||||
module.exit_json(**rst)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,503 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright: (c) 2013, Vincent Van der Kussen <vincent at vanderkussen.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt
|
||||
author:
|
||||
- Vincent Van der Kussen (@vincentvdk)
|
||||
short_description: oVirt/RHEV platform management
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.14
|
||||
why: This module is for deprecated version of ovirt.
|
||||
alternative: Use C(ovirt_vm) from the C(ovirt.ovirt) collection instead
|
||||
description:
|
||||
- This module only supports oVirt/RHEV version 3. A newer module M(ovirt.ovirt.ovirt_vm) supports oVirt/RHV version 4.
|
||||
- Allows you to create new instances, either from scratch or an image, in addition to deleting or stopping instances on the oVirt/RHEV platform.
|
||||
options:
|
||||
user:
|
||||
description:
|
||||
- The user to authenticate with.
|
||||
type: str
|
||||
required: true
|
||||
url:
|
||||
description:
|
||||
- The url of the oVirt instance.
|
||||
type: str
|
||||
required: true
|
||||
instance_name:
|
||||
description:
|
||||
- The name of the instance to use.
|
||||
type: str
|
||||
required: true
|
||||
aliases: [ vmname ]
|
||||
password:
|
||||
description:
|
||||
- Password of the user to authenticate with.
|
||||
type: str
|
||||
required: true
|
||||
image:
|
||||
description:
|
||||
- The template to use for the instance.
|
||||
type: str
|
||||
resource_type:
|
||||
description:
|
||||
- Whether you want to deploy an image or create an instance from scratch.
|
||||
type: str
|
||||
choices: [ new, template ]
|
||||
zone:
|
||||
description:
|
||||
- Deploy the image to this oVirt cluster.
|
||||
type: str
|
||||
instance_disksize:
|
||||
description:
|
||||
- Size of the instance's disk in GB.
|
||||
type: str
|
||||
aliases: [ vm_disksize]
|
||||
instance_cpus:
|
||||
description:
|
||||
- The instance's number of CPUs.
|
||||
type: str
|
||||
default: 1
|
||||
aliases: [ vmcpus ]
|
||||
instance_nic:
|
||||
description:
|
||||
- The name of the network interface in oVirt/RHEV.
|
||||
type: str
|
||||
aliases: [ vmnic ]
|
||||
instance_network:
|
||||
description:
|
||||
- The logical network the machine should belong to.
|
||||
type: str
|
||||
default: rhevm
|
||||
aliases: [ vmnetwork ]
|
||||
instance_mem:
|
||||
description:
|
||||
- The instance's amount of memory in MB.
|
||||
type: str
|
||||
aliases: [ vmmem ]
|
||||
instance_type:
|
||||
description:
|
||||
- Define whether the instance is a server, desktop or high_performance.
|
||||
- I(high_performance) is supported since Ansible 2.5 and oVirt/RHV 4.2.
|
||||
type: str
|
||||
choices: [ desktop, server, high_performance ]
|
||||
default: server
|
||||
aliases: [ vmtype ]
|
||||
disk_alloc:
|
||||
description:
|
||||
- Define whether disk is thin or preallocated.
|
||||
type: str
|
||||
choices: [ preallocated, thin ]
|
||||
default: thin
|
||||
disk_int:
|
||||
description:
|
||||
- Interface type of the disk.
|
||||
type: str
|
||||
choices: [ ide, virtio ]
|
||||
default: virtio
|
||||
instance_os:
|
||||
description:
|
||||
- Type of Operating System.
|
||||
type: str
|
||||
aliases: [ vmos ]
|
||||
instance_cores:
|
||||
description:
|
||||
- Define the instance's number of cores.
|
||||
type: str
|
||||
default: 1
|
||||
aliases: [ vmcores ]
|
||||
sdomain:
|
||||
description:
|
||||
- The Storage Domain where you want to create the instance's disk on.
|
||||
type: str
|
||||
region:
|
||||
description:
|
||||
- The oVirt/RHEV datacenter where you want to deploy to.
|
||||
type: str
|
||||
instance_dns:
|
||||
description:
|
||||
- Define the instance's Primary DNS server.
|
||||
type: str
|
||||
aliases: [ dns ]
|
||||
instance_domain:
|
||||
description:
|
||||
- Define the instance's Domain.
|
||||
type: str
|
||||
aliases: [ domain ]
|
||||
instance_hostname:
|
||||
description:
|
||||
- Define the instance's Hostname.
|
||||
type: str
|
||||
aliases: [ hostname ]
|
||||
instance_ip:
|
||||
description:
|
||||
- Define the instance's IP.
|
||||
type: str
|
||||
aliases: [ ip ]
|
||||
instance_netmask:
|
||||
description:
|
||||
- Define the instance's Netmask.
|
||||
type: str
|
||||
aliases: [ netmask ]
|
||||
instance_gateway:
|
||||
description:
|
||||
- Define the instance's Gateway.
|
||||
type: str
|
||||
aliases: [ gateway ]
|
||||
instance_rootpw:
|
||||
description:
|
||||
- Define the instance's Root password.
|
||||
type: str
|
||||
aliases: [ rootpw ]
|
||||
instance_key:
|
||||
description:
|
||||
- Define the instance's Authorized key.
|
||||
type: str
|
||||
aliases: [ key ]
|
||||
state:
|
||||
description:
|
||||
- Create, terminate or remove instances.
|
||||
type: str
|
||||
choices: [ absent, present, restart, shutdown, started ]
|
||||
default: present
|
||||
requirements:
|
||||
- ovirt-engine-sdk-python
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: Basic example to provision from image
|
||||
community.general.ovirt:
|
||||
user: admin@internal
|
||||
url: https://ovirt.example.com
|
||||
instance_name: ansiblevm04
|
||||
password: secret
|
||||
image: centos_64
|
||||
zone: cluster01
|
||||
resource_type: template
|
||||
|
||||
- name: Full example to create new instance from scratch
|
||||
community.general.ovirt:
|
||||
instance_name: testansible
|
||||
resource_type: new
|
||||
instance_type: server
|
||||
user: admin@internal
|
||||
password: secret
|
||||
url: https://ovirt.example.com
|
||||
instance_disksize: 10
|
||||
zone: cluster01
|
||||
region: datacenter1
|
||||
instance_cpus: 1
|
||||
instance_nic: nic1
|
||||
instance_network: rhevm
|
||||
instance_mem: 1000
|
||||
disk_alloc: thin
|
||||
sdomain: FIBER01
|
||||
instance_cores: 1
|
||||
instance_os: rhel_6x64
|
||||
disk_int: virtio
|
||||
|
||||
- name: Stopping an existing instance
|
||||
community.general.ovirt:
|
||||
instance_name: testansible
|
||||
state: stopped
|
||||
user: admin@internal
|
||||
password: secret
|
||||
url: https://ovirt.example.com
|
||||
|
||||
- name: Start an existing instance
|
||||
community.general.ovirt:
|
||||
instance_name: testansible
|
||||
state: started
|
||||
user: admin@internal
|
||||
password: secret
|
||||
url: https://ovirt.example.com
|
||||
|
||||
- name: Start an instance with cloud init information
|
||||
community.general.ovirt:
|
||||
instance_name: testansible
|
||||
state: started
|
||||
user: admin@internal
|
||||
password: secret
|
||||
url: https://ovirt.example.com
|
||||
hostname: testansible
|
||||
domain: ansible.local
|
||||
ip: 192.0.2.100
|
||||
netmask: 255.255.255.0
|
||||
gateway: 192.0.2.1
|
||||
rootpw: bigsecret
|
||||
'''
|
||||
|
||||
import time
|
||||
|
||||
try:
|
||||
from ovirtsdk.api import API
|
||||
from ovirtsdk.xml import params
|
||||
HAS_OVIRTSDK = True
|
||||
except ImportError:
|
||||
HAS_OVIRTSDK = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
|
||||
|
||||
# ------------------------------------------------------------------- #
|
||||
# create connection with API
|
||||
#
|
||||
def conn(url, user, password):
|
||||
api = API(url=url, username=user, password=password, insecure=True)
|
||||
try:
|
||||
value = api.test()
|
||||
except Exception:
|
||||
raise Exception("error connecting to the oVirt API")
|
||||
return api
|
||||
|
||||
|
||||
# ------------------------------------------------------------------- #
|
||||
# Create VM from scratch
|
||||
def create_vm(conn, vmtype, vmname, zone, vmdisk_size, vmcpus, vmnic, vmnetwork, vmmem, vmdisk_alloc, sdomain, vmcores, vmos, vmdisk_int):
|
||||
if vmdisk_alloc == 'thin':
|
||||
# define VM params
|
||||
vmparams = params.VM(name=vmname, cluster=conn.clusters.get(name=zone), os=params.OperatingSystem(type_=vmos),
|
||||
template=conn.templates.get(name="Blank"), memory=1024 * 1024 * int(vmmem),
|
||||
cpu=params.CPU(topology=params.CpuTopology(cores=int(vmcores), sockets=vmcpus)), type_=vmtype)
|
||||
# define disk params
|
||||
vmdisk = params.Disk(size=1024 * 1024 * 1024 * int(vmdisk_size), wipe_after_delete=True, sparse=True, interface=vmdisk_int, type_="System",
|
||||
format='cow',
|
||||
storage_domains=params.StorageDomains(storage_domain=[conn.storagedomains.get(name=sdomain)]))
|
||||
# define network parameters
|
||||
network_net = params.Network(name=vmnetwork)
|
||||
nic_net1 = params.NIC(name='nic1', network=network_net, interface='virtio')
|
||||
elif vmdisk_alloc == 'preallocated':
|
||||
# define VM params
|
||||
vmparams = params.VM(name=vmname, cluster=conn.clusters.get(name=zone), os=params.OperatingSystem(type_=vmos),
|
||||
template=conn.templates.get(name="Blank"), memory=1024 * 1024 * int(vmmem),
|
||||
cpu=params.CPU(topology=params.CpuTopology(cores=int(vmcores), sockets=vmcpus)), type_=vmtype)
|
||||
# define disk params
|
||||
vmdisk = params.Disk(size=1024 * 1024 * 1024 * int(vmdisk_size), wipe_after_delete=True, sparse=False, interface=vmdisk_int, type_="System",
|
||||
format='raw', storage_domains=params.StorageDomains(storage_domain=[conn.storagedomains.get(name=sdomain)]))
|
||||
# define network parameters
|
||||
network_net = params.Network(name=vmnetwork)
|
||||
nic_net1 = params.NIC(name=vmnic, network=network_net, interface='virtio')
|
||||
|
||||
try:
|
||||
conn.vms.add(vmparams)
|
||||
except Exception:
|
||||
raise Exception("Error creating VM with specified parameters")
|
||||
vm = conn.vms.get(name=vmname)
|
||||
try:
|
||||
vm.disks.add(vmdisk)
|
||||
except Exception:
|
||||
raise Exception("Error attaching disk")
|
||||
try:
|
||||
vm.nics.add(nic_net1)
|
||||
except Exception:
|
||||
raise Exception("Error adding nic")
|
||||
|
||||
|
||||
# create an instance from a template
|
||||
def create_vm_template(conn, vmname, image, zone):
|
||||
vmparams = params.VM(name=vmname, cluster=conn.clusters.get(name=zone), template=conn.templates.get(name=image), disks=params.Disks(clone=True))
|
||||
try:
|
||||
conn.vms.add(vmparams)
|
||||
except Exception:
|
||||
raise Exception('error adding template %s' % image)
|
||||
|
||||
|
||||
# start instance
|
||||
def vm_start(conn, vmname, hostname=None, ip=None, netmask=None, gateway=None,
|
||||
domain=None, dns=None, rootpw=None, key=None):
|
||||
vm = conn.vms.get(name=vmname)
|
||||
use_cloud_init = False
|
||||
nics = None
|
||||
nic = None
|
||||
if hostname or ip or netmask or gateway or domain or dns or rootpw or key:
|
||||
use_cloud_init = True
|
||||
if ip and netmask and gateway:
|
||||
ipinfo = params.IP(address=ip, netmask=netmask, gateway=gateway)
|
||||
nic = params.GuestNicConfiguration(name='eth0', boot_protocol='STATIC', ip=ipinfo, on_boot=True)
|
||||
nics = params.Nics()
|
||||
nics = params.GuestNicsConfiguration(nic_configuration=[nic])
|
||||
initialization = params.Initialization(regenerate_ssh_keys=True, host_name=hostname, domain=domain, user_name='root',
|
||||
root_password=rootpw, nic_configurations=nics, dns_servers=dns,
|
||||
authorized_ssh_keys=key)
|
||||
action = params.Action(use_cloud_init=use_cloud_init, vm=params.VM(initialization=initialization))
|
||||
vm.start(action=action)
|
||||
|
||||
|
||||
# Stop instance
|
||||
def vm_stop(conn, vmname):
|
||||
vm = conn.vms.get(name=vmname)
|
||||
vm.stop()
|
||||
|
||||
|
||||
# restart instance
|
||||
def vm_restart(conn, vmname):
|
||||
state = vm_status(conn, vmname)
|
||||
vm = conn.vms.get(name=vmname)
|
||||
vm.stop()
|
||||
while conn.vms.get(vmname).get_status().get_state() != 'down':
|
||||
time.sleep(5)
|
||||
vm.start()
|
||||
|
||||
|
||||
# remove an instance
|
||||
def vm_remove(conn, vmname):
|
||||
vm = conn.vms.get(name=vmname)
|
||||
vm.delete()
|
||||
|
||||
|
||||
# ------------------------------------------------------------------- #
|
||||
# VM statuses
|
||||
#
|
||||
# Get the VMs status
|
||||
def vm_status(conn, vmname):
|
||||
status = conn.vms.get(name=vmname).status.state
|
||||
return status
|
||||
|
||||
|
||||
# Get VM object and return it's name if object exists
|
||||
def get_vm(conn, vmname):
|
||||
vm = conn.vms.get(name=vmname)
|
||||
if vm is None:
|
||||
name = "empty"
|
||||
else:
|
||||
name = vm.get_name()
|
||||
return name
|
||||
|
||||
# ------------------------------------------------------------------- #
|
||||
# Hypervisor operations
|
||||
#
|
||||
# not available yet
|
||||
# ------------------------------------------------------------------- #
|
||||
# Main
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
state=dict(type='str', default='present', choices=['absent', 'present', 'restart', 'shutdown', 'started']),
|
||||
user=dict(type='str', required=True),
|
||||
url=dict(type='str', required=True),
|
||||
instance_name=dict(type='str', required=True, aliases=['vmname']),
|
||||
password=dict(type='str', required=True, no_log=True),
|
||||
image=dict(type='str'),
|
||||
resource_type=dict(type='str', choices=['new', 'template']),
|
||||
zone=dict(type='str'),
|
||||
instance_disksize=dict(type='str', aliases=['vm_disksize']),
|
||||
instance_cpus=dict(type='str', default=1, aliases=['vmcpus']),
|
||||
instance_nic=dict(type='str', aliases=['vmnic']),
|
||||
instance_network=dict(type='str', default='rhevm', aliases=['vmnetwork']),
|
||||
instance_mem=dict(type='str', aliases=['vmmem']),
|
||||
instance_type=dict(type='str', default='server', aliases=['vmtype'], choices=['desktop', 'server', 'high_performance']),
|
||||
disk_alloc=dict(type='str', default='thin', choices=['preallocated', 'thin']),
|
||||
disk_int=dict(type='str', default='virtio', choices=['ide', 'virtio']),
|
||||
instance_os=dict(type='str', aliases=['vmos']),
|
||||
instance_cores=dict(type='str', default=1, aliases=['vmcores']),
|
||||
instance_hostname=dict(type='str', aliases=['hostname']),
|
||||
instance_ip=dict(type='str', aliases=['ip']),
|
||||
instance_netmask=dict(type='str', aliases=['netmask']),
|
||||
instance_gateway=dict(type='str', aliases=['gateway']),
|
||||
instance_domain=dict(type='str', aliases=['domain']),
|
||||
instance_dns=dict(type='str', aliases=['dns']),
|
||||
instance_rootpw=dict(type='str', aliases=['rootpw'], no_log=True),
|
||||
instance_key=dict(type='str', aliases=['key'], no_log=True),
|
||||
sdomain=dict(type='str'),
|
||||
region=dict(type='str'),
|
||||
),
|
||||
)
|
||||
|
||||
if not HAS_OVIRTSDK:
|
||||
module.fail_json(msg='ovirtsdk required for this module')
|
||||
|
||||
state = module.params['state']
|
||||
user = module.params['user']
|
||||
url = module.params['url']
|
||||
vmname = module.params['instance_name']
|
||||
password = module.params['password']
|
||||
image = module.params['image'] # name of the image to deploy
|
||||
resource_type = module.params['resource_type'] # template or from scratch
|
||||
zone = module.params['zone'] # oVirt cluster
|
||||
vmdisk_size = module.params['instance_disksize'] # disksize
|
||||
vmcpus = module.params['instance_cpus'] # number of cpu
|
||||
vmnic = module.params['instance_nic'] # network interface
|
||||
vmnetwork = module.params['instance_network'] # logical network
|
||||
vmmem = module.params['instance_mem'] # mem size
|
||||
vmdisk_alloc = module.params['disk_alloc'] # thin, preallocated
|
||||
vmdisk_int = module.params['disk_int'] # disk interface virtio or ide
|
||||
vmos = module.params['instance_os'] # Operating System
|
||||
vmtype = module.params['instance_type'] # server, desktop or high_performance
|
||||
vmcores = module.params['instance_cores'] # number of cores
|
||||
sdomain = module.params['sdomain'] # storage domain to store disk on
|
||||
region = module.params['region'] # oVirt Datacenter
|
||||
hostname = module.params['instance_hostname']
|
||||
ip = module.params['instance_ip']
|
||||
netmask = module.params['instance_netmask']
|
||||
gateway = module.params['instance_gateway']
|
||||
domain = module.params['instance_domain']
|
||||
dns = module.params['instance_dns']
|
||||
rootpw = module.params['instance_rootpw']
|
||||
key = module.params['instance_key']
|
||||
# initialize connection
|
||||
try:
|
||||
c = conn(url + "/api", user, password)
|
||||
except Exception as e:
|
||||
module.fail_json(msg='%s' % e)
|
||||
|
||||
if state == 'present':
|
||||
if get_vm(c, vmname) == "empty":
|
||||
if resource_type == 'template':
|
||||
try:
|
||||
create_vm_template(c, vmname, image, zone)
|
||||
except Exception as e:
|
||||
module.fail_json(msg='%s' % e)
|
||||
module.exit_json(changed=True, msg="deployed VM %s from template %s" % (vmname, image))
|
||||
elif resource_type == 'new':
|
||||
# FIXME: refactor, use keyword args.
|
||||
try:
|
||||
create_vm(c, vmtype, vmname, zone, vmdisk_size, vmcpus, vmnic, vmnetwork, vmmem, vmdisk_alloc, sdomain, vmcores, vmos, vmdisk_int)
|
||||
except Exception as e:
|
||||
module.fail_json(msg='%s' % e)
|
||||
module.exit_json(changed=True, msg="deployed VM %s from scratch" % vmname)
|
||||
else:
|
||||
module.exit_json(changed=False, msg="You did not specify a resource type")
|
||||
else:
|
||||
module.exit_json(changed=False, msg="VM %s already exists" % vmname)
|
||||
|
||||
if state == 'started':
|
||||
if vm_status(c, vmname) == 'up':
|
||||
module.exit_json(changed=False, msg="VM %s is already running" % vmname)
|
||||
else:
|
||||
# vm_start(c, vmname)
|
||||
vm_start(c, vmname, hostname, ip, netmask, gateway, domain, dns, rootpw, key)
|
||||
module.exit_json(changed=True, msg="VM %s started" % vmname)
|
||||
|
||||
if state == 'shutdown':
|
||||
if vm_status(c, vmname) == 'down':
|
||||
module.exit_json(changed=False, msg="VM %s is already shutdown" % vmname)
|
||||
else:
|
||||
vm_stop(c, vmname)
|
||||
module.exit_json(changed=True, msg="VM %s is shutting down" % vmname)
|
||||
|
||||
if state == 'restart':
|
||||
if vm_status(c, vmname) == 'up':
|
||||
vm_restart(c, vmname)
|
||||
module.exit_json(changed=True, msg="VM %s is restarted" % vmname)
|
||||
else:
|
||||
module.exit_json(changed=False, msg="VM %s is not running" % vmname)
|
||||
|
||||
if state == 'absent':
|
||||
if get_vm(c, vmname) == "empty":
|
||||
module.exit_json(changed=False, msg="VM %s does not exist" % vmname)
|
||||
else:
|
||||
vm_remove(c, vmname)
|
||||
module.exit_json(changed=True, msg="VM %s removed" % vmname)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,175 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: online_server_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.online_server_info) instead.
|
||||
short_description: Gather facts about Online servers.
|
||||
description:
|
||||
- Gather facts about the servers.
|
||||
- U(https://www.online.net/en/dedicated-server)
|
||||
author:
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.online
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Online server facts
|
||||
community.general.online_server_facts:
|
||||
api_token: '0d1627e8-bbf0-44c5-a46f-5c4d3aef033f'
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
online_server_facts:
|
||||
description: Response from Online API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"online_server_facts": [
|
||||
{
|
||||
"abuse": "abuse@example.com",
|
||||
"anti_ddos": false,
|
||||
"bmc": {
|
||||
"session_key": null
|
||||
},
|
||||
"boot_mode": "normal",
|
||||
"contacts": {
|
||||
"owner": "foobar",
|
||||
"tech": "foobar"
|
||||
},
|
||||
"disks": [
|
||||
{
|
||||
"$ref": "/api/v1/server/hardware/disk/68452"
|
||||
},
|
||||
{
|
||||
"$ref": "/api/v1/server/hardware/disk/68453"
|
||||
}
|
||||
],
|
||||
"drive_arrays": [
|
||||
{
|
||||
"disks": [
|
||||
{
|
||||
"$ref": "/api/v1/server/hardware/disk/68452"
|
||||
},
|
||||
{
|
||||
"$ref": "/api/v1/server/hardware/disk/68453"
|
||||
}
|
||||
],
|
||||
"raid_controller": {
|
||||
"$ref": "/api/v1/server/hardware/raidController/9910"
|
||||
},
|
||||
"raid_level": "RAID1"
|
||||
}
|
||||
],
|
||||
"hardware_watch": true,
|
||||
"hostname": "sd-42",
|
||||
"id": 42,
|
||||
"ip": [
|
||||
{
|
||||
"address": "195.154.172.149",
|
||||
"mac": "28:92:4a:33:5e:c6",
|
||||
"reverse": "195-154-172-149.rev.poneytelecom.eu.",
|
||||
"switch_port_state": "up",
|
||||
"type": "public"
|
||||
},
|
||||
{
|
||||
"address": "10.90.53.212",
|
||||
"mac": "28:92:4a:33:5e:c7",
|
||||
"reverse": null,
|
||||
"switch_port_state": "up",
|
||||
"type": "private"
|
||||
}
|
||||
],
|
||||
"last_reboot": "2018-08-23T08:32:03.000Z",
|
||||
"location": {
|
||||
"block": "A",
|
||||
"datacenter": "DC3",
|
||||
"position": 19,
|
||||
"rack": "A23",
|
||||
"room": "4 4-4"
|
||||
},
|
||||
"network": {
|
||||
"ip": [
|
||||
"195.154.172.149"
|
||||
],
|
||||
"ipfo": [],
|
||||
"private": [
|
||||
"10.90.53.212"
|
||||
]
|
||||
},
|
||||
"offer": "Pro-1-S-SATA",
|
||||
"os": {
|
||||
"name": "FreeBSD",
|
||||
"version": "11.1-RELEASE"
|
||||
},
|
||||
"power": "ON",
|
||||
"proactive_monitoring": false,
|
||||
"raid_controllers": [
|
||||
{
|
||||
"$ref": "/api/v1/server/hardware/raidController/9910"
|
||||
}
|
||||
],
|
||||
"support": "Basic service level"
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.online import (
|
||||
Online, OnlineException, online_argument_spec
|
||||
)
|
||||
|
||||
|
||||
class OnlineServerFacts(Online):
|
||||
|
||||
def __init__(self, module):
|
||||
super(OnlineServerFacts, self).__init__(module)
|
||||
self.name = 'api/v1/server'
|
||||
|
||||
def _get_server_detail(self, server_path):
|
||||
try:
|
||||
return self.get(path=server_path).json
|
||||
except OnlineException as exc:
|
||||
self.module.fail_json(msg="A problem occurred while fetching: %s (%s)" % (server_path, exc))
|
||||
|
||||
def all_detailed_servers(self):
|
||||
servers_api_path = self.get_resources()
|
||||
|
||||
server_data = (
|
||||
self._get_server_detail(server_api_path)
|
||||
for server_api_path in servers_api_path
|
||||
)
|
||||
|
||||
return [s for s in server_data if s is not None]
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=online_argument_spec(),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
servers_facts = OnlineServerFacts(module).all_detailed_servers()
|
||||
module.exit_json(
|
||||
ansible_facts={'online_server_facts': servers_facts}
|
||||
)
|
||||
except OnlineException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,76 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: online_user_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.online_user_info) instead.
|
||||
short_description: Gather facts about Online user.
|
||||
description:
|
||||
- Gather facts about the user.
|
||||
author:
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.online
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Online user facts
|
||||
community.general.online_user_facts:
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
online_user_facts:
|
||||
description: Response from Online API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"online_user_facts": {
|
||||
"company": "foobar LLC",
|
||||
"email": "foobar@example.com",
|
||||
"first_name": "foo",
|
||||
"id": 42,
|
||||
"last_name": "bar",
|
||||
"login": "foobar"
|
||||
}
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.online import (
|
||||
Online, OnlineException, online_argument_spec
|
||||
)
|
||||
|
||||
|
||||
class OnlineUserFacts(Online):
|
||||
|
||||
def __init__(self, module):
|
||||
super(OnlineUserFacts, self).__init__(module)
|
||||
self.name = 'api/v1/user'
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=online_argument_spec(),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'online_user_facts': OnlineUserFacts(module).get_resources()}
|
||||
)
|
||||
except OnlineException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1 +0,0 @@
|
|||
one_image_info.py
|
|
@ -261,9 +261,6 @@ def main():
|
|||
module = AnsibleModule(argument_spec=fields,
|
||||
mutually_exclusive=[['ids', 'name']],
|
||||
supports_check_mode=True)
|
||||
if module._name in ('one_image_facts', 'community.general.one_image_facts'):
|
||||
module.deprecate("The 'one_image_facts' module has been renamed to 'one_image_info'",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
if not HAS_PYONE:
|
||||
module.fail_json(msg='This module requires pyone to work!')
|
||||
|
|
|
@ -1,196 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_affinity_label_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV affinity labels
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_affinity_label_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV affinity labels."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_affinity_labels), which
|
||||
contains a list of affinity labels. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
- "Name of the affinity labels which should be listed."
|
||||
vm:
|
||||
description:
|
||||
- "Name of the VM, which affinity labels should be listed."
|
||||
host:
|
||||
description:
|
||||
- "Name of the host, which affinity labels should be listed."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all affinity labels, which names start with label
|
||||
ovirt_affinity_label_info:
|
||||
name: label*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_affinity_labels }}"
|
||||
|
||||
- name: >
|
||||
Gather information about all affinity labels, which are assigned to VMs
|
||||
which names start with postgres
|
||||
ovirt_affinity_label_info:
|
||||
vm: postgres*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_affinity_labels }}"
|
||||
|
||||
- name: >
|
||||
Gather information about all affinity labels, which are assigned to hosts
|
||||
which names start with west
|
||||
ovirt_affinity_label_info:
|
||||
host: west*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_affinity_labels }}"
|
||||
|
||||
- name: >
|
||||
Gather information about all affinity labels, which are assigned to hosts
|
||||
which names start with west or VMs which names start with postgres
|
||||
ovirt_affinity_label_info:
|
||||
host: west*
|
||||
vm: postgres*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_affinity_labels }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_affinity_labels:
|
||||
description: "List of dictionaries describing the affinity labels. Affinity labels attributes are mapped to dictionary keys,
|
||||
all affinity labels attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/affinity_label."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
search_by_name,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
name=dict(default=None),
|
||||
host=dict(default=None),
|
||||
vm=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_affinity_label_facts', 'community.general.ovirt_affinity_label_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_affinity_label_facts' module has been renamed to 'ovirt_affinity_label_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
affinity_labels_service = connection.system_service().affinity_labels_service()
|
||||
labels = []
|
||||
all_labels = affinity_labels_service.list()
|
||||
if module.params['name']:
|
||||
labels.extend([
|
||||
l for l in all_labels
|
||||
if fnmatch.fnmatch(l.name, module.params['name'])
|
||||
])
|
||||
if module.params['host']:
|
||||
hosts_service = connection.system_service().hosts_service()
|
||||
if search_by_name(hosts_service, module.params['host']) is None:
|
||||
raise Exception("Host '%s' was not found." % module.params['host'])
|
||||
labels.extend([
|
||||
label
|
||||
for label in all_labels
|
||||
for host in connection.follow_link(label.hosts)
|
||||
if fnmatch.fnmatch(hosts_service.service(host.id).get().name, module.params['host'])
|
||||
])
|
||||
if module.params['vm']:
|
||||
vms_service = connection.system_service().vms_service()
|
||||
if search_by_name(vms_service, module.params['vm']) is None:
|
||||
raise Exception("Vm '%s' was not found." % module.params['vm'])
|
||||
labels.extend([
|
||||
label
|
||||
for label in all_labels
|
||||
for vm in connection.follow_link(label.vms)
|
||||
if fnmatch.fnmatch(vms_service.service(vm.id).get().name, module.params['vm'])
|
||||
])
|
||||
|
||||
if not (module.params['vm'] or module.params['host'] or module.params['name']):
|
||||
labels = all_labels
|
||||
|
||||
result = dict(
|
||||
ovirt_affinity_labels=[
|
||||
get_dict_of_struct(
|
||||
struct=l,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for l in labels
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,98 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2017 Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_api_facts
|
||||
short_description: Retrieve information about the oVirt/RHV API
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_api_info) instead.
|
||||
description:
|
||||
- "Retrieve information about the oVirt/RHV API."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_api),
|
||||
which contains a information about oVirt/RHV API. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information oVirt API
|
||||
ovirt_api_info:
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_api }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_api:
|
||||
description: "Dictionary describing the oVirt API information.
|
||||
Api attributes are mapped to dictionary keys,
|
||||
all API attributes can be found at following
|
||||
url: https://ovirt.example.com/ovirt-engine/api/model#types/api."
|
||||
returned: On success.
|
||||
type: dict
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec()
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_api_facts', 'community.general.ovirt_api_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_api_facts' module has been renamed to 'ovirt_api_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
api = connection.system_service().get()
|
||||
result = dict(
|
||||
ovirt_api=get_dict_of_struct(
|
||||
struct=api,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
)
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,125 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_cluster_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV clusters
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_cluster_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV clusters."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_clusters), which
|
||||
contains a list of clusters. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search cluster X from datacenter Y use following pattern:
|
||||
name=X and datacenter=Y"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all clusters which names start with production
|
||||
ovirt_cluster_info:
|
||||
pattern:
|
||||
name: 'production*'
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_clusters }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_clusters:
|
||||
description: "List of dictionaries describing the clusters. Cluster attributes are mapped to dictionary keys,
|
||||
all clusters attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/cluster."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_cluster_facts', 'community.general.ovirt_cluster_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_cluster_facts' module has been renamed to 'ovirt_cluster_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
clusters_service = connection.system_service().clusters_service()
|
||||
clusters = clusters_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_clusters=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in clusters
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,108 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_datacenter_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV datacenters
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_datacenter_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV datacenters."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_datacenters), which
|
||||
contains a list of datacenters. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search datacenter I(X) use following pattern: I(name=X)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all data centers which names start with production
|
||||
ovirt_datacenter_info:
|
||||
pattern: name=production*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_datacenters }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_datacenters:
|
||||
description: "List of dictionaries describing the datacenters. Datacenter attributes are mapped to dictionary keys,
|
||||
all datacenters attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/data_center."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_datacenter_facts', 'community.general.ovirt_datacenter_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_datacenter_facts' module has been renamed to 'ovirt_datacenter_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
datacenters_service = connection.system_service().data_centers_service()
|
||||
datacenters = datacenters_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_datacenters=[
|
||||
get_dict_of_struct(
|
||||
struct=d,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for d in datacenters
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,125 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_disk_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV disks
|
||||
author: "Katerina Koukiou (@KKoukiou)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_disk_info) instead
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV disks."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_disks), which
|
||||
contains a list of disks. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search Disk X from storage Y use following pattern:
|
||||
name=X and storage.name=Y"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all Disks which names start with centos
|
||||
ovirt_disk_info:
|
||||
pattern: name=centos*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_disks }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_disks:
|
||||
description: "List of dictionaries describing the Disks. Disk attributes are mapped to dictionary keys,
|
||||
all Disks attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/disk."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_disk_facts', 'community.general.ovirt_disk_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_disk_facts' module has been renamed to 'ovirt_disk_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
disks_service = connection.system_service().disks_service()
|
||||
disks = disks_service.list(
|
||||
search=module.params['pattern'],
|
||||
)
|
||||
result = dict(
|
||||
ovirt_disks=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in disks
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,170 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright: (c) 2019, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_event_facts
|
||||
short_description: This module can be used to retrieve information about one or more oVirt/RHV events
|
||||
author: "Chris Keller (@nasx)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_event_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV events."
|
||||
options:
|
||||
case_sensitive:
|
||||
description:
|
||||
- "Indicates if the search performed using the search parameter should be performed taking case
|
||||
into account. The default value is true, which means that case is taken into account. If you
|
||||
want to search ignoring case set it to false."
|
||||
required: false
|
||||
default: true
|
||||
type: bool
|
||||
|
||||
from_:
|
||||
description:
|
||||
- "Indicates the event index after which events should be returned. The indexes of events are
|
||||
strictly increasing, so when this parameter is used only the events with greater indexes
|
||||
will be returned."
|
||||
required: false
|
||||
type: int
|
||||
|
||||
max:
|
||||
description:
|
||||
- "Sets the maximum number of events to return. If not specified all the events are returned."
|
||||
required: false
|
||||
type: int
|
||||
|
||||
search:
|
||||
description:
|
||||
- "Search term which is accepted by the oVirt/RHV API."
|
||||
- "For example to search for events of severity alert use the following pattern: severity=alert"
|
||||
required: false
|
||||
type: str
|
||||
|
||||
headers:
|
||||
description:
|
||||
- "Additional HTTP headers."
|
||||
required: false
|
||||
type: str
|
||||
|
||||
query:
|
||||
description:
|
||||
- "Additional URL query parameters."
|
||||
required: false
|
||||
type: str
|
||||
|
||||
wait:
|
||||
description:
|
||||
- "If True wait for the response."
|
||||
required: false
|
||||
default: true
|
||||
type: bool
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain the auth parameter for simplicity,
|
||||
# look at the ovirt_auth module to see how to reuse authentication.
|
||||
|
||||
- name: Return all events
|
||||
ovirt_event_info:
|
||||
register: result
|
||||
|
||||
- name: Return the last 10 events
|
||||
ovirt_event_info:
|
||||
max: 10
|
||||
register: result
|
||||
|
||||
- name: Return all events of type alert
|
||||
ovirt_event_info:
|
||||
search: "severity=alert"
|
||||
register: result
|
||||
- ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_events }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_events:
|
||||
description: "List of dictionaries describing the events. Event attributes are mapped to dictionary keys.
|
||||
All event attributes can be found at the following url:
|
||||
http://ovirt.github.io/ovirt-engine-api-model/master/#types/event"
|
||||
returned: On success."
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
case_sensitive=dict(default=True, type='bool', required=False),
|
||||
from_=dict(default=None, type='int', required=False),
|
||||
max=dict(default=None, type='int', required=False),
|
||||
search=dict(default='', required=False),
|
||||
headers=dict(default='', required=False),
|
||||
query=dict(default='', required=False),
|
||||
wait=dict(default=True, type='bool', required=False)
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_event_facts', 'community.general.ovirt_event_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_event_facts' module has been renamed to 'ovirt_event_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
events_service = connection.system_service().events_service()
|
||||
events = events_service.list(
|
||||
case_sensitive=module.params['case_sensitive'],
|
||||
from_=module.params['from_'],
|
||||
max=module.params['max'],
|
||||
search=module.params['search'],
|
||||
headers=module.params['headers'],
|
||||
query=module.params['query'],
|
||||
wait=module.params['wait']
|
||||
)
|
||||
|
||||
result = dict(
|
||||
ovirt_events=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in events
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,165 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_external_provider_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV external providers
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_external_provider_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV external providers."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_external_providers), which
|
||||
contains a list of external_providers. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
type:
|
||||
description:
|
||||
- "Type of the external provider."
|
||||
choices: ['os_image', 'os_network', 'os_volume', 'foreman']
|
||||
required: true
|
||||
type: str
|
||||
name:
|
||||
description:
|
||||
- "Name of the external provider, can be used as glob expression."
|
||||
type: str
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all image external providers named glance
|
||||
ovirt_external_provider_info:
|
||||
type: os_image
|
||||
name: glance
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_external_providers }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_external_providers:
|
||||
description:
|
||||
- "List of dictionaries. Content depends on I(type)."
|
||||
- "For type C(foreman), attributes appearing in the dictionary can be found on your oVirt/RHV instance
|
||||
at the following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/external_host_provider."
|
||||
- "For type C(os_image), attributes appearing in the dictionary can be found on your oVirt/RHV instance
|
||||
at the following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/openstack_image_provider."
|
||||
- "For type C(os_volume), attributes appearing in the dictionary can be found on your oVirt/RHV instance
|
||||
at the following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/openstack_volume_provider."
|
||||
- "For type C(os_network), attributes appearing in the dictionary can be found on your oVirt/RHV instance
|
||||
at the following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/openstack_network_provider."
|
||||
returned: On success
|
||||
type: list
|
||||
'''
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def _external_provider_service(provider_type, system_service):
|
||||
if provider_type == 'os_image':
|
||||
return system_service.openstack_image_providers_service()
|
||||
elif provider_type == 'os_network':
|
||||
return system_service.openstack_network_providers_service()
|
||||
elif provider_type == 'os_volume':
|
||||
return system_service.openstack_volume_providers_service()
|
||||
elif provider_type == 'foreman':
|
||||
return system_service.external_host_providers_service()
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
name=dict(default=None, required=False),
|
||||
type=dict(
|
||||
required=True,
|
||||
choices=['os_image', 'os_network', 'os_volume', 'foreman'],
|
||||
aliases=['provider'],
|
||||
),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_external_provider_facts', 'community.general.ovirt_external_provider_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_external_provider_facts' module has been renamed to 'ovirt_external_provider_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
external_providers_service = _external_provider_service(
|
||||
provider_type=module.params.pop('type'),
|
||||
system_service=connection.system_service(),
|
||||
)
|
||||
if module.params['name']:
|
||||
external_providers = [
|
||||
e for e in external_providers_service.list()
|
||||
if fnmatch.fnmatch(e.name, module.params['name'])
|
||||
]
|
||||
else:
|
||||
external_providers = external_providers_service.list()
|
||||
|
||||
result = dict(
|
||||
ovirt_external_providers=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in external_providers
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,123 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_group_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV groups
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_group_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV groups."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_groups), which
|
||||
contains a list of groups. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search group X use following pattern: name=X"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all groups which names start with admin
|
||||
ovirt_group_info:
|
||||
pattern: name=admin*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_groups }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_groups:
|
||||
description: "List of dictionaries describing the groups. Group attributes are mapped to dictionary keys,
|
||||
all groups attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/group."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_group_facts', 'community.general.ovirt_group_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_group_facts' module has been renamed to 'ovirt_group_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
groups_service = connection.system_service().groups_service()
|
||||
groups = groups_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_groups=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in groups
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,149 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_host_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV hosts
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_host_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV hosts."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_hosts), which
|
||||
contains a list of hosts. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search host X from datacenter Y use following pattern:
|
||||
name=X and datacenter=Y"
|
||||
all_content:
|
||||
description:
|
||||
- "If I(true) all the attributes of the hosts should be
|
||||
included in the response."
|
||||
default: False
|
||||
type: bool
|
||||
cluster_version:
|
||||
description:
|
||||
- "Filter the hosts based on the cluster version."
|
||||
type: str
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all hosts which names start with host and belong to data center west
|
||||
ovirt_host_info:
|
||||
pattern: name=host* and datacenter=west
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_hosts }}"
|
||||
|
||||
- name: Gather information about all hosts with cluster version 4.2
|
||||
ovirt_host_info:
|
||||
pattern: name=host*
|
||||
cluster_version: "4.2"
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_hosts }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_hosts:
|
||||
description: "List of dictionaries describing the hosts. Host attributes are mapped to dictionary keys,
|
||||
all hosts attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/host."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def get_filtered_hosts(cluster_version, hosts, connection):
|
||||
# Filtering by cluster version returns only those which have same cluster version as input
|
||||
filtered_hosts = []
|
||||
for host in hosts:
|
||||
cluster = connection.follow_link(host.cluster)
|
||||
cluster_version_host = str(cluster.version.major) + '.' + str(cluster.version.minor)
|
||||
if cluster_version_host == cluster_version:
|
||||
filtered_hosts.append(host)
|
||||
return filtered_hosts
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
all_content=dict(default=False, type='bool'),
|
||||
cluster_version=dict(default=None, type='str'),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_host_facts', 'community.general.ovirt_host_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_host_facts' module has been renamed to 'ovirt_host_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
hosts_service = connection.system_service().hosts_service()
|
||||
hosts = hosts_service.list(
|
||||
search=module.params['pattern'],
|
||||
all_content=module.params['all_content']
|
||||
)
|
||||
cluster_version = module.params.get('cluster_version')
|
||||
if cluster_version is not None:
|
||||
hosts = get_filtered_hosts(cluster_version, hosts, connection)
|
||||
result = dict(
|
||||
ovirt_hosts=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in hosts
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,187 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_host_storage_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV HostStorages (applicable only for block storage)
|
||||
author: "Daniel Erez (@derez)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_host_storage_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV HostStorages (applicable only for block storage)."
|
||||
options:
|
||||
host:
|
||||
description:
|
||||
- "Host to get device list from."
|
||||
required: true
|
||||
iscsi:
|
||||
description:
|
||||
- "Dictionary with values for iSCSI storage type:"
|
||||
suboptions:
|
||||
address:
|
||||
description:
|
||||
- "Address of the iSCSI storage server."
|
||||
target:
|
||||
description:
|
||||
- "The target IQN for the storage device."
|
||||
username:
|
||||
description:
|
||||
- "A CHAP user name for logging into a target."
|
||||
password:
|
||||
description:
|
||||
- "A CHAP password for logging into a target."
|
||||
portal:
|
||||
description:
|
||||
- "The portal being used to connect with iscsi."
|
||||
fcp:
|
||||
description:
|
||||
- "Dictionary with values for fibre channel storage type:"
|
||||
suboptions:
|
||||
address:
|
||||
description:
|
||||
- "Address of the fibre channel storage server."
|
||||
port:
|
||||
description:
|
||||
- "Port of the fibre channel storage server."
|
||||
lun_id:
|
||||
description:
|
||||
- "LUN id."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about HostStorages with specified target and address
|
||||
ovirt_host_storage_info:
|
||||
host: myhost
|
||||
iscsi:
|
||||
target: iqn.2016-08-09.domain-01:nickname
|
||||
address: 10.34.63.204
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_host_storages }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_host_storages:
|
||||
description: "List of dictionaries describing the HostStorage. HostStorage attributes are mapped to dictionary keys,
|
||||
all HostStorage attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/host_storage."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
try:
|
||||
import ovirtsdk4.types as otypes
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
get_id_by_name,
|
||||
)
|
||||
|
||||
|
||||
def _login(host_service, iscsi):
|
||||
host_service.iscsi_login(
|
||||
iscsi=otypes.IscsiDetails(
|
||||
username=iscsi.get('username'),
|
||||
password=iscsi.get('password'),
|
||||
address=iscsi.get('address'),
|
||||
target=iscsi.get('target'),
|
||||
portal=iscsi.get('portal')
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _get_storage_type(params):
|
||||
for sd_type in ['iscsi', 'fcp']:
|
||||
if params.get(sd_type) is not None:
|
||||
return sd_type
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
host=dict(required=True),
|
||||
iscsi=dict(default=None, type='dict'),
|
||||
fcp=dict(default=None, type='dict'),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_host_storage_facts', 'community.general.ovirt_host_storage_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_host_storage_facts' module has been renamed to 'ovirt_host_storage_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
|
||||
# Get Host
|
||||
hosts_service = connection.system_service().hosts_service()
|
||||
host_id = get_id_by_name(hosts_service, module.params['host'])
|
||||
storage_type = _get_storage_type(module.params)
|
||||
host_service = hosts_service.host_service(host_id)
|
||||
|
||||
if storage_type == 'iscsi':
|
||||
# Login
|
||||
iscsi = module.params.get('iscsi')
|
||||
_login(host_service, iscsi)
|
||||
|
||||
# Get LUNs exposed from the specified target
|
||||
host_storages = host_service.storage_service().list()
|
||||
|
||||
if storage_type == 'iscsi':
|
||||
filterred_host_storages = [host_storage for host_storage in host_storages
|
||||
if host_storage.type == otypes.StorageType.ISCSI]
|
||||
if 'target' in iscsi:
|
||||
filterred_host_storages = [host_storage for host_storage in filterred_host_storages
|
||||
if iscsi.get('target') == host_storage.logical_units[0].target]
|
||||
elif storage_type == 'fcp':
|
||||
filterred_host_storages = [host_storage for host_storage in host_storages
|
||||
if host_storage.type == otypes.StorageType.FCP]
|
||||
|
||||
result = dict(
|
||||
ovirt_host_storages=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in filterred_host_storages
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,125 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_network_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV networks
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_network_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV networks."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_networks), which
|
||||
contains a list of networks. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search network starting with string vlan1 use: name=vlan1*"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all networks which names start with vlan1
|
||||
ovirt_network_info:
|
||||
pattern: name=vlan1*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_networks }}"
|
||||
'''
|
||||
|
||||
|
||||
RETURN = '''
|
||||
ovirt_networks:
|
||||
description: "List of dictionaries describing the networks. Network attributes are mapped to dictionary keys,
|
||||
all networks attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/network."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_network_facts', 'community.general.ovirt_network_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_network_facts' module has been renamed to 'ovirt_network_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
networks_service = connection.system_service().networks_service()
|
||||
networks = networks_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_networks=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in networks
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,143 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_nic_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV virtual machine network interfaces
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_nic_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV virtual machine network interfaces."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_nics), which
|
||||
contains a list of NICs. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
vm:
|
||||
description:
|
||||
- "Name of the VM where NIC is attached."
|
||||
required: true
|
||||
name:
|
||||
description:
|
||||
- "Name of the NIC, can be used as glob expression."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all NICs which names start with eth for VM named centos7
|
||||
ovirt_nic_info:
|
||||
vm: centos7
|
||||
name: eth*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_nics }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_nics:
|
||||
description: "List of dictionaries describing the network interfaces. NIC attributes are mapped to dictionary keys,
|
||||
all NICs attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/nic."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
search_by_name,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
vm=dict(required=True),
|
||||
name=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_nic_facts', 'community.general.ovirt_nic_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_nic_facts' module has been renamed to 'ovirt_nic_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
vms_service = connection.system_service().vms_service()
|
||||
vm_name = module.params['vm']
|
||||
vm = search_by_name(vms_service, vm_name)
|
||||
if vm is None:
|
||||
raise Exception("VM '%s' was not found." % vm_name)
|
||||
|
||||
nics_service = vms_service.service(vm.id).nics_service()
|
||||
if module.params['name']:
|
||||
nics = [
|
||||
e for e in nics_service.list()
|
||||
if fnmatch.fnmatch(e.name, module.params['name'])
|
||||
]
|
||||
else:
|
||||
nics = nics_service.list()
|
||||
|
||||
result = dict(
|
||||
ovirt_nics=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in nics
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,166 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_permission_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV permissions
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_permission_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV permissions."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_permissions), which
|
||||
contains a list of permissions. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
user_name:
|
||||
description:
|
||||
- "Username of the user to manage. In most LDAPs it's I(uid) of the user, but in Active Directory you must specify I(UPN) of the user."
|
||||
group_name:
|
||||
description:
|
||||
- "Name of the group to manage."
|
||||
authz_name:
|
||||
description:
|
||||
- "Authorization provider of the user/group. In previous versions of oVirt/RHV known as domain."
|
||||
required: true
|
||||
aliases: ['domain']
|
||||
namespace:
|
||||
description:
|
||||
- "Namespace of the authorization provider, where user/group resides."
|
||||
required: false
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all permissions of user with username john
|
||||
ovirt_permission_info:
|
||||
user_name: john
|
||||
authz_name: example.com-authz
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_permissions }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_permissions:
|
||||
description: "List of dictionaries describing the permissions. Permission attributes are mapped to dictionary keys,
|
||||
all permissions attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/permission."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
try:
|
||||
import ovirtsdk4 as sdk
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_link_name,
|
||||
ovirt_info_full_argument_spec,
|
||||
search_by_name,
|
||||
)
|
||||
|
||||
|
||||
def _permissions_service(connection, module):
|
||||
if module.params['user_name']:
|
||||
service = connection.system_service().users_service()
|
||||
entity = next(
|
||||
iter(
|
||||
service.list(
|
||||
search='usrname={0}'.format(
|
||||
'{0}@{1}'.format(module.params['user_name'], module.params['authz_name'])
|
||||
)
|
||||
)
|
||||
),
|
||||
None
|
||||
)
|
||||
else:
|
||||
service = connection.system_service().groups_service()
|
||||
entity = search_by_name(service, module.params['group_name'])
|
||||
|
||||
if entity is None:
|
||||
raise Exception("User/Group wasn't found.")
|
||||
|
||||
return service.service(entity.id).permissions_service()
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
authz_name=dict(required=True, aliases=['domain']),
|
||||
user_name=dict(default=None),
|
||||
group_name=dict(default=None),
|
||||
namespace=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_permission_facts', 'community.general.ovirt_permission_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_permission_facts' module has been renamed to 'ovirt_permission_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
permissions_service = _permissions_service(connection, module)
|
||||
permissions = []
|
||||
for p in permissions_service.list():
|
||||
newperm = dict()
|
||||
for key, value in p.__dict__.items():
|
||||
if value and isinstance(value, sdk.Struct):
|
||||
newperm[key[1:]] = get_link_name(connection, value)
|
||||
newperm['%s_id' % key[1:]] = value.id
|
||||
permissions.append(newperm)
|
||||
|
||||
result = dict(ovirt_permissions=permissions)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,143 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_quota_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV quotas
|
||||
author: "Maor Lipchuk (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_quota_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV quotas."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_quotas), which
|
||||
contains a list of quotas. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
data_center:
|
||||
description:
|
||||
- "Name of the datacenter where quota resides."
|
||||
required: true
|
||||
name:
|
||||
description:
|
||||
- "Name of the quota, can be used as glob expression."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about quota named C<myquota> in Default datacenter
|
||||
ovirt_quota_info:
|
||||
data_center: Default
|
||||
name: myquota
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_quotas }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_quotas:
|
||||
description: "List of dictionaries describing the quotas. Quota attributes are mapped to dictionary keys,
|
||||
all quotas attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/quota."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
search_by_name,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
data_center=dict(required=True),
|
||||
name=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_quota_facts', 'community.general.ovirt_quota_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_quota_facts' module has been renamed to 'ovirt_quota_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
datacenters_service = connection.system_service().data_centers_service()
|
||||
dc_name = module.params['data_center']
|
||||
dc = search_by_name(datacenters_service, dc_name)
|
||||
if dc is None:
|
||||
raise Exception("Datacenter '%s' was not found." % dc_name)
|
||||
|
||||
quotas_service = datacenters_service.service(dc.id).quotas_service()
|
||||
if module.params['name']:
|
||||
quotas = [
|
||||
e for e in quotas_service.list()
|
||||
if fnmatch.fnmatch(e.name, module.params['name'])
|
||||
]
|
||||
else:
|
||||
quotas = quotas_service.list()
|
||||
|
||||
result = dict(
|
||||
ovirt_quotas=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in quotas
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,140 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_scheduling_policy_facts
|
||||
short_description: Retrieve information about one or more oVirt scheduling policies
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_scheduling_policy_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt scheduling policies."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_scheduling_policies),
|
||||
which contains a list of scheduling policies. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
id:
|
||||
description:
|
||||
- "ID of the scheduling policy."
|
||||
name:
|
||||
description:
|
||||
- "Name of the scheduling policy, can be used as glob expression."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all scheduling policies with name InClusterUpgrade
|
||||
ovirt_scheduling_policy_info:
|
||||
name: InClusterUpgrade
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_scheduling_policies }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_scheduling_policies:
|
||||
description: "List of dictionaries describing the scheduling policies.
|
||||
Scheduling policies attributes are mapped to dictionary keys,
|
||||
all scheduling policies attributes can be found at following
|
||||
url: https://ovirt.example.com/ovirt-engine/api/model#types/scheduling_policy."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
id=dict(default=None),
|
||||
name=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_scheduling_policy_facts', 'community.general.ovirt_scheduling_policy_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_scheduling_policy_facts' module has been renamed to 'ovirt_scheduling_policy_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
system_service = connection.system_service()
|
||||
sched_policies_service = system_service.scheduling_policies_service()
|
||||
if module.params['name']:
|
||||
sched_policies = [
|
||||
e for e in sched_policies_service.list()
|
||||
if fnmatch.fnmatch(e.name, module.params['name'])
|
||||
]
|
||||
elif module.params['id']:
|
||||
sched_policies = [
|
||||
sched_policies_service.service(module.params['id']).get()
|
||||
]
|
||||
else:
|
||||
sched_policies = sched_policies_service.list()
|
||||
|
||||
result = dict(
|
||||
ovirt_scheduling_policies=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in sched_policies
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,137 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_snapshot_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV virtual machine snapshots
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_snapshot_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV virtual machine snapshots."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_snapshots), which
|
||||
contains a list of snapshots. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
vm:
|
||||
description:
|
||||
- "Name of the VM with snapshot."
|
||||
required: true
|
||||
description:
|
||||
description:
|
||||
- "Description of the snapshot, can be used as glob expression."
|
||||
snapshot_id:
|
||||
description:
|
||||
- "Id of the snapshot we want to retrieve information about."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all snapshots which description start with update for VM named centos7
|
||||
ovirt_snapshot_info:
|
||||
vm: centos7
|
||||
description: update*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_snapshots }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_snapshots:
|
||||
description: "List of dictionaries describing the snapshot. Snapshot attributes are mapped to dictionary keys,
|
||||
all snapshot attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/snapshot."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
search_by_name,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
vm=dict(required=True),
|
||||
description=dict(default=None),
|
||||
snapshot_id=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_snapshot_facts', 'community.general.ovirt_snapshot_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_snapshot_facts' module has been renamed to 'ovirt_snapshot_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
vms_service = connection.system_service().vms_service()
|
||||
vm_name = module.params['vm']
|
||||
vm = search_by_name(vms_service, vm_name)
|
||||
if vm is None:
|
||||
raise Exception("VM '%s' was not found." % vm_name)
|
||||
|
||||
snapshots_service = vms_service.service(vm.id).snapshots_service()
|
||||
if module.params['description']:
|
||||
snapshots = [
|
||||
e for e in snapshots_service.list()
|
||||
if fnmatch.fnmatch(e.description, module.params['description'])
|
||||
]
|
||||
elif module.params['snapshot_id']:
|
||||
snapshots = [
|
||||
snapshots_service.snapshot_service(module.params['snapshot_id']).get()
|
||||
]
|
||||
else:
|
||||
snapshots = snapshots_service.list()
|
||||
|
||||
result = dict(
|
||||
ovirt_snapshots=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in snapshots
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,126 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_storage_domain_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV storage domains
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_storage_domain_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV storage domains."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_storage_domains), which
|
||||
contains a list of storage domains. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search storage domain X from datacenter Y use following pattern:
|
||||
name=X and datacenter=Y"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: >
|
||||
Gather information about all storage domains which names
|
||||
start with data and belong to data center west
|
||||
ovirt_storage_domain_info:
|
||||
pattern: name=data* and datacenter=west
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_storage_domains }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_storage_domains:
|
||||
description: "List of dictionaries describing the storage domains. Storage_domain attributes are mapped to dictionary keys,
|
||||
all storage domains attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/storage_domain."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_storage_domain_facts', 'community.general.ovirt_storage_domain_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_storage_domain_facts' module has been renamed to 'ovirt_storage_domain_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
storage_domains_service = connection.system_service().storage_domains_service()
|
||||
storage_domains = storage_domains_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_storage_domains=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in storage_domains
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,142 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_storage_template_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV templates relate to a storage domain.
|
||||
author: "Maor Lipchuk (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_storage_template_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV templates relate to a storage domain."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_storage_templates), which
|
||||
contains a list of templates. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
unregistered:
|
||||
description:
|
||||
- "Flag which indicates whether to get unregistered templates which contain one or more
|
||||
disks which reside on a storage domain or diskless templates."
|
||||
type: bool
|
||||
default: false
|
||||
max:
|
||||
description:
|
||||
- "Sets the maximum number of templates to return. If not specified all the templates are returned."
|
||||
storage_domain:
|
||||
description:
|
||||
- "The storage domain name where the templates should be listed."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all templates which relate to a storage domain and are unregistered
|
||||
ovirt_storage_template_info:
|
||||
unregistered: yes
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_storage_templates }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_storage_templates:
|
||||
description: "List of dictionaries describing the Templates. Template attributes are mapped to dictionary keys,
|
||||
all Templates attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/template."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
get_id_by_name
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
storage_domain=dict(default=None),
|
||||
max=dict(default=None, type='int'),
|
||||
unregistered=dict(default=False, type='bool'),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_storage_template_facts', 'community.general.ovirt_storage_template_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_storage_template_facts' module has been renamed to 'ovirt_storage_template_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
storage_domains_service = connection.system_service().storage_domains_service()
|
||||
sd_id = get_id_by_name(storage_domains_service, module.params['storage_domain'])
|
||||
storage_domain_service = storage_domains_service.storage_domain_service(sd_id)
|
||||
templates_service = storage_domain_service.templates_service()
|
||||
|
||||
# Find the unregistered Template we want to register:
|
||||
if module.params.get('unregistered'):
|
||||
templates = templates_service.list(unregistered=True)
|
||||
else:
|
||||
templates = templates_service.list(max=module.params['max'])
|
||||
result = dict(
|
||||
ovirt_storage_templates=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in templates
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,142 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2017 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_storage_vm_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV virtual machines relate to a storage domain.
|
||||
author: "Maor Lipchuk (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_storage_vm_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV virtual machines relate to a storage domain."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_storage_vms), which
|
||||
contains a list of virtual machines. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
unregistered:
|
||||
description:
|
||||
- "Flag which indicates whether to get unregistered virtual machines which contain one or more
|
||||
disks which reside on a storage domain or diskless virtual machines."
|
||||
type: bool
|
||||
default: false
|
||||
max:
|
||||
description:
|
||||
- "Sets the maximum number of virtual machines to return. If not specified all the virtual machines are returned."
|
||||
storage_domain:
|
||||
description:
|
||||
- "The storage domain name where the virtual machines should be listed."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all VMs which relate to a storage domain and are unregistered
|
||||
ovirt_vms_info:
|
||||
unregistered: yes
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_storage_vms }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_storage_vms:
|
||||
description: "List of dictionaries describing the VMs. VM attributes are mapped to dictionary keys,
|
||||
all VMs attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/vm."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
get_id_by_name
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
storage_domain=dict(default=None),
|
||||
max=dict(default=None, type='int'),
|
||||
unregistered=dict(default=False, type='bool'),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_storage_vm_facts', 'community.general.ovirt_storage_vm_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_storage_vm_facts' module has been renamed to 'ovirt_storage_vm_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
storage_domains_service = connection.system_service().storage_domains_service()
|
||||
sd_id = get_id_by_name(storage_domains_service, module.params['storage_domain'])
|
||||
storage_domain_service = storage_domains_service.storage_domain_service(sd_id)
|
||||
vms_service = storage_domain_service.vms_service()
|
||||
|
||||
# Find the unregistered VM we want to register:
|
||||
if module.params.get('unregistered'):
|
||||
vms = vms_service.list(unregistered=True)
|
||||
else:
|
||||
vms = vms_service.list()
|
||||
result = dict(
|
||||
ovirt_storage_vms=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in vms
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_tag_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV tags
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_tag_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV tags."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_tags), which
|
||||
contains a list of tags. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
- "Name of the tag which should be listed."
|
||||
vm:
|
||||
description:
|
||||
- "Name of the VM, which tags should be listed."
|
||||
host:
|
||||
description:
|
||||
- "Name of the host, which tags should be listed."
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all tags, which names start with tag
|
||||
ovirt_tag_info:
|
||||
name: tag*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_tags }}"
|
||||
|
||||
- name: Gather information about all tags, which are assigned to VM postgres
|
||||
ovirt_tag_info:
|
||||
vm: postgres
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_tags }}"
|
||||
|
||||
- name: Gather information about all tags, which are assigned to host west
|
||||
ovirt_tag_info:
|
||||
host: west
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_tags }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_tags:
|
||||
description: "List of dictionaries describing the tags. Tags attributes are mapped to dictionary keys,
|
||||
all tags attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/tag."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import fnmatch
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
search_by_name,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
name=dict(default=None),
|
||||
host=dict(default=None),
|
||||
vm=dict(default=None),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_tag_facts', 'community.general.ovirt_tag_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_tag_facts' module has been renamed to 'ovirt_tag_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
tags_service = connection.system_service().tags_service()
|
||||
tags = []
|
||||
all_tags = tags_service.list()
|
||||
if module.params['name']:
|
||||
tags.extend([
|
||||
t for t in all_tags
|
||||
if fnmatch.fnmatch(t.name, module.params['name'])
|
||||
])
|
||||
if module.params['host']:
|
||||
hosts_service = connection.system_service().hosts_service()
|
||||
host = search_by_name(hosts_service, module.params['host'])
|
||||
if host is None:
|
||||
raise Exception("Host '%s' was not found." % module.params['host'])
|
||||
tags.extend(hosts_service.host_service(host.id).tags_service().list())
|
||||
if module.params['vm']:
|
||||
vms_service = connection.system_service().vms_service()
|
||||
vm = search_by_name(vms_service, module.params['vm'])
|
||||
if vm is None:
|
||||
raise Exception("Vm '%s' was not found." % module.params['vm'])
|
||||
tags.extend(vms_service.vm_service(vm.id).tags_service().list())
|
||||
|
||||
if not (module.params['vm'] or module.params['host'] or module.params['name']):
|
||||
tags = all_tags
|
||||
|
||||
result = dict(
|
||||
ovirt_tags=[
|
||||
get_dict_of_struct(
|
||||
struct=t,
|
||||
connection=connection,
|
||||
fetch_nested=module.params['fetch_nested'],
|
||||
attributes=module.params['nested_attributes'],
|
||||
) for t in tags
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,124 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_template_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV templates
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_template_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV templates."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_templates), which
|
||||
contains a list of templates. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search template X from datacenter Y use following pattern:
|
||||
name=X and datacenter=Y"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all templates which names start with centos and belongs to data center west
|
||||
ovirt_template_info:
|
||||
pattern: name=centos* and datacenter=west
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_templates }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_templates:
|
||||
description: "List of dictionaries describing the templates. Template attributes are mapped to dictionary keys,
|
||||
all templates attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/template."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_template_facts', 'community.general.ovirt_template_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_template_facts' module has been renamed to 'ovirt_template_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
templates_service = connection.system_service().templates_service()
|
||||
templates = templates_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_templates=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in templates
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,123 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_user_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV users
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_user_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV users."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_users), which
|
||||
contains a list of users. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search user X use following pattern: name=X"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all users which first names start with john
|
||||
ovirt_user_info:
|
||||
pattern: name=john*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_users }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_users:
|
||||
description: "List of dictionaries describing the users. User attributes are mapped to dictionary keys,
|
||||
all users attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/user."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_user_facts', 'community.general.ovirt_user_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_user_facts' module has been renamed to 'ovirt_user_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
users_service = connection.system_service().users_service()
|
||||
users = users_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_users=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in users
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,166 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_vm_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV virtual machines
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_vm_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV virtual machines."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_vms), which
|
||||
contains a list of virtual machines. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search VM X from cluster Y use following pattern:
|
||||
name=X and cluster=Y"
|
||||
all_content:
|
||||
description:
|
||||
- "If I(true) all the attributes of the virtual machines should be
|
||||
included in the response."
|
||||
type: bool
|
||||
default: false
|
||||
case_sensitive:
|
||||
description:
|
||||
- "If I(true) performed search will take case into account."
|
||||
type: bool
|
||||
default: true
|
||||
max:
|
||||
description:
|
||||
- "The maximum number of results to return."
|
||||
next_run:
|
||||
description:
|
||||
- "Indicates if the returned result describes the virtual machine as it is currently running or if describes
|
||||
the virtual machine with the modifications that have already been performed but that will only come into
|
||||
effect when the virtual machine is restarted. By default the value is set by engine."
|
||||
type: bool
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all VMs which names start with centos and belong to cluster west
|
||||
ovirt_vm_info:
|
||||
pattern: name=centos* and cluster=west
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_vms }}"
|
||||
|
||||
- name: Gather info about next run configuration of virtual machine named myvm
|
||||
ovirt_vm_info:
|
||||
pattern: name=myvm
|
||||
next_run: true
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_vms[0] }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_vms:
|
||||
description: "List of dictionaries describing the VMs. VM attributes are mapped to dictionary keys,
|
||||
all VMs attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/vm."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
all_content=dict(default=False, type='bool'),
|
||||
next_run=dict(default=None, type='bool'),
|
||||
case_sensitive=dict(default=True, type='bool'),
|
||||
max=dict(default=None, type='int'),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_vm_facts', 'community.general.ovirt_vm_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_vm_facts' module has been renamed to 'ovirt_vm_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
vms_service = connection.system_service().vms_service()
|
||||
vms = vms_service.list(
|
||||
search=module.params['pattern'],
|
||||
all_content=module.params['all_content'],
|
||||
case_sensitive=module.params['case_sensitive'],
|
||||
max=module.params['max'],
|
||||
)
|
||||
if module.params['next_run']:
|
||||
vms = [vms_service.vm_service(vm.id).get(next_run=True) for vm in vms]
|
||||
|
||||
result = dict(
|
||||
ovirt_vms=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in vms
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,123 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2016 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: ovirt_vmpool_facts
|
||||
short_description: Retrieve information about one or more oVirt/RHV vmpools
|
||||
author: "Ondra Machacek (@machacekondra)"
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: When migrating to collection we decided to use only _info modules.
|
||||
alternative: Use M(ovirt.ovirt.ovirt_vmpool_info) instead.
|
||||
description:
|
||||
- "Retrieve information about one or more oVirt/RHV vmpools."
|
||||
notes:
|
||||
- "This module returns a variable C(ovirt_vmpools), which
|
||||
contains a list of vmpools. You need to register the result with
|
||||
the I(register) keyword to use it."
|
||||
options:
|
||||
pattern:
|
||||
description:
|
||||
- "Search term which is accepted by oVirt/RHV search backend."
|
||||
- "For example to search vmpool X: name=X"
|
||||
extends_documentation_fragment:
|
||||
- community.general.ovirt_facts
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Examples don't contain auth parameter for simplicity,
|
||||
# look at ovirt_auth module to see how to reuse authentication:
|
||||
|
||||
- name: Gather information about all vm pools which names start with centos
|
||||
ovirt_vmpool_info:
|
||||
pattern: name=centos*
|
||||
register: result
|
||||
|
||||
- name: Print gathered information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ result.ovirt_vm_pools }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
ovirt_vm_pools:
|
||||
description: "List of dictionaries describing the vmpools. Vm pool attributes are mapped to dictionary keys,
|
||||
all vmpools attributes can be found at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/vm_pool."
|
||||
returned: On success.
|
||||
type: list
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.common.removed import removed_module
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils._ovirt import (
|
||||
check_sdk,
|
||||
create_connection,
|
||||
get_dict_of_struct,
|
||||
ovirt_info_full_argument_spec,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = ovirt_info_full_argument_spec(
|
||||
pattern=dict(default='', required=False),
|
||||
)
|
||||
module = AnsibleModule(argument_spec)
|
||||
is_old_facts = module._name in ('ovirt_vmpool_facts', 'community.general.ovirt_vmpool_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'ovirt_vmpool_facts' module has been renamed to 'ovirt_vmpool_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
check_sdk(module)
|
||||
|
||||
try:
|
||||
auth = module.params.pop('auth')
|
||||
connection = create_connection(auth)
|
||||
vmpools_service = connection.system_service().vm_pools_service()
|
||||
vmpools = vmpools_service.list(search=module.params['pattern'])
|
||||
result = dict(
|
||||
ovirt_vm_pools=[
|
||||
get_dict_of_struct(
|
||||
struct=c,
|
||||
connection=connection,
|
||||
fetch_nested=module.params.get('fetch_nested'),
|
||||
attributes=module.params.get('nested_attributes'),
|
||||
) for c in vmpools
|
||||
],
|
||||
)
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False, ansible_facts=result)
|
||||
else:
|
||||
module.exit_json(changed=False, **result)
|
||||
except Exception as e:
|
||||
module.fail_json(msg=str(e), exception=traceback.format_exc())
|
||||
finally:
|
||||
connection.close(logout=auth.get('token') is None)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,125 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_image_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_image_info) instead.
|
||||
short_description: Gather facts about the Scaleway images available.
|
||||
description:
|
||||
- Gather facts about the Scaleway images available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
|
||||
options:
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway compute zone
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway images facts
|
||||
community.general.scaleway_image_facts:
|
||||
region: par1
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_image_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_image_facts": [
|
||||
{
|
||||
"arch": "x86_64",
|
||||
"creation_date": "2018-07-17T16:18:49.276456+00:00",
|
||||
"default_bootscript": {
|
||||
"architecture": "x86_64",
|
||||
"bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
|
||||
"default": false,
|
||||
"dtb": "",
|
||||
"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8",
|
||||
"initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.5.gz",
|
||||
"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93",
|
||||
"organization": "11111111-1111-4111-8111-111111111111",
|
||||
"public": true,
|
||||
"title": "x86_64 mainline 4.9.93 rev1"
|
||||
},
|
||||
"extra_volumes": [],
|
||||
"from_server": null,
|
||||
"id": "00ae4a88-3252-4eda-9feb-5f6b56bf5ef0",
|
||||
"modification_date": "2018-07-17T16:42:06.319315+00:00",
|
||||
"name": "Debian Stretch",
|
||||
"organization": "51b656e3-4865-41e8-adbc-0c45bdd780db",
|
||||
"public": true,
|
||||
"root_volume": {
|
||||
"id": "da32dfbb-c5ff-476d-ae2d-c297dd09b7dd",
|
||||
"name": "snapshot-2a7229dc-d431-4dc5-b66e-95db08b773af-2018-07-17_16:18",
|
||||
"size": 25000000000,
|
||||
"volume_type": "l_ssd"
|
||||
},
|
||||
"state": "available"
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway, ScalewayException, scaleway_argument_spec, SCALEWAY_LOCATION)
|
||||
|
||||
|
||||
class ScalewayImageFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewayImageFacts, self).__init__(module)
|
||||
self.name = 'images'
|
||||
|
||||
region = module.params["region"]
|
||||
self.module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_image_facts': ScalewayImageFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,108 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_ip_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_ip_info) instead.
|
||||
short_description: Gather facts about the Scaleway ips available.
|
||||
description:
|
||||
- Gather facts about the Scaleway ips available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
options:
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway region to use (for example par1).
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway ips facts
|
||||
community.general.scaleway_ip_facts:
|
||||
region: par1
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_ip_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_ip_facts": [
|
||||
{
|
||||
"address": "163.172.170.243",
|
||||
"id": "ea081794-a581-8899-8451-386ddaf0a451",
|
||||
"organization": "3f709602-5e6c-4619-b80c-e324324324af",
|
||||
"reverse": null,
|
||||
"server": {
|
||||
"id": "12f19bc7-109c-4517-954c-e6b3d0311363",
|
||||
"name": "scw-e0d158"
|
||||
}
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway,
|
||||
ScalewayException,
|
||||
scaleway_argument_spec,
|
||||
SCALEWAY_LOCATION,
|
||||
)
|
||||
|
||||
|
||||
class ScalewayIpFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewayIpFacts, self).__init__(module)
|
||||
self.name = 'ips'
|
||||
|
||||
region = module.params["region"]
|
||||
self.module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_ip_facts': ScalewayIpFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,104 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_organization_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_organization_info) instead.
|
||||
short_description: Gather facts about the Scaleway organizations available.
|
||||
description:
|
||||
- Gather facts about the Scaleway organizations available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
options:
|
||||
api_url:
|
||||
description:
|
||||
- Scaleway API URL
|
||||
default: 'https://account.scaleway.com'
|
||||
aliases: ['base_url']
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway organizations facts
|
||||
community.general.scaleway_organization_facts:
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_organization_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_organization_facts": [
|
||||
{
|
||||
"address_city_name": "Paris",
|
||||
"address_country_code": "FR",
|
||||
"address_line1": "42 Rue de l'univers",
|
||||
"address_line2": null,
|
||||
"address_postal_code": "75042",
|
||||
"address_subdivision_code": "FR-75",
|
||||
"creation_date": "2018-08-06T13:43:28.508575+00:00",
|
||||
"currency": "EUR",
|
||||
"customer_class": "individual",
|
||||
"id": "3f709602-5e6c-4619-b80c-e8432ferewtr",
|
||||
"locale": "fr_FR",
|
||||
"modification_date": "2018-08-06T14:56:41.401685+00:00",
|
||||
"name": "James Bond",
|
||||
"support_id": "694324",
|
||||
"support_level": "basic",
|
||||
"support_pin": "9324",
|
||||
"users": [],
|
||||
"vat_number": null,
|
||||
"warnings": []
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway, ScalewayException, scaleway_argument_spec
|
||||
)
|
||||
|
||||
|
||||
class ScalewayOrganizationFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewayOrganizationFacts, self).__init__(module)
|
||||
self.name = 'organizations'
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
api_url=dict(fallback=(env_fallback, ['SCW_API_URL']), default='https://account.scaleway.com', aliases=['base_url']),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_organization_facts': ScalewayOrganizationFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,112 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_security_group_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_security_group_info) instead.
|
||||
short_description: Gather facts about the Scaleway security groups available.
|
||||
description:
|
||||
- Gather facts about the Scaleway security groups available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
options:
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway region to use (for example par1).
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway security groups facts
|
||||
community.general.scaleway_security_group_facts:
|
||||
region: par1
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_security_group_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_security_group_facts": [
|
||||
{
|
||||
"description": "test-ams",
|
||||
"enable_default_security": true,
|
||||
"id": "7fcde327-8bed-43a6-95c4-6dfbc56d8b51",
|
||||
"name": "test-ams",
|
||||
"organization": "3f709602-5e6c-4619-b80c-e841c89734af",
|
||||
"organization_default": false,
|
||||
"servers": [
|
||||
{
|
||||
"id": "12f19bc7-108c-4517-954c-e6b3d0311363",
|
||||
"name": "scw-e0d158"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway,
|
||||
ScalewayException,
|
||||
scaleway_argument_spec,
|
||||
SCALEWAY_LOCATION,
|
||||
)
|
||||
|
||||
|
||||
class ScalewaySecurityGroupFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewaySecurityGroupFacts, self).__init__(module)
|
||||
self.name = 'security_groups'
|
||||
|
||||
region = module.params["region"]
|
||||
self.module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_security_group_facts': ScalewaySecurityGroupFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,195 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_server_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_server_info) instead.
|
||||
short_description: Gather facts about the Scaleway servers available.
|
||||
description:
|
||||
- Gather facts about the Scaleway servers available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
options:
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway region to use (for example par1).
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway servers facts
|
||||
community.general.scaleway_server_facts:
|
||||
region: par1
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_server_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_server_facts": [
|
||||
{
|
||||
"arch": "x86_64",
|
||||
"boot_type": "local",
|
||||
"bootscript": {
|
||||
"architecture": "x86_64",
|
||||
"bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
|
||||
"default": true,
|
||||
"dtb": "",
|
||||
"id": "b1e68c26-a19c-4eac-9222-498b22bd7ad9",
|
||||
"initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.5.gz",
|
||||
"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.127-rev1/vmlinuz-4.4.127",
|
||||
"organization": "11111111-1111-4111-8111-111111111111",
|
||||
"public": true,
|
||||
"title": "x86_64 mainline 4.4.127 rev1"
|
||||
},
|
||||
"commercial_type": "START1-XS",
|
||||
"creation_date": "2018-08-14T21:36:56.271545+00:00",
|
||||
"dynamic_ip_required": false,
|
||||
"enable_ipv6": false,
|
||||
"extra_networks": [],
|
||||
"hostname": "scw-e0d256",
|
||||
"id": "12f19bc7-108c-4517-954c-e6b3d0311363",
|
||||
"image": {
|
||||
"arch": "x86_64",
|
||||
"creation_date": "2018-04-26T12:42:21.619844+00:00",
|
||||
"default_bootscript": {
|
||||
"architecture": "x86_64",
|
||||
"bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16",
|
||||
"default": true,
|
||||
"dtb": "",
|
||||
"id": "b1e68c26-a19c-4eac-9222-498b22bd7ad9",
|
||||
"initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.5.gz",
|
||||
"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.127-rev1/vmlinuz-4.4.127",
|
||||
"organization": "11111111-1111-4111-8111-111111111111",
|
||||
"public": true,
|
||||
"title": "x86_64 mainline 4.4.127 rev1"
|
||||
},
|
||||
"extra_volumes": [],
|
||||
"from_server": null,
|
||||
"id": "67375eb1-f14d-4f02-bb42-6119cecbde51",
|
||||
"modification_date": "2018-04-26T12:49:07.573004+00:00",
|
||||
"name": "Ubuntu Xenial",
|
||||
"organization": "51b656e3-4865-41e8-adbc-0c45bdd780db",
|
||||
"public": true,
|
||||
"root_volume": {
|
||||
"id": "020b8d61-3867-4a0e-84a4-445c5393e05d",
|
||||
"name": "snapshot-87fc282d-f252-4262-adad-86979d9074cf-2018-04-26_12:42",
|
||||
"size": 25000000000,
|
||||
"volume_type": "l_ssd"
|
||||
},
|
||||
"state": "available"
|
||||
},
|
||||
"ipv6": null,
|
||||
"location": {
|
||||
"cluster_id": "5",
|
||||
"hypervisor_id": "412",
|
||||
"node_id": "2",
|
||||
"platform_id": "13",
|
||||
"zone_id": "par1"
|
||||
},
|
||||
"maintenances": [],
|
||||
"modification_date": "2018-08-14T21:37:28.630882+00:00",
|
||||
"name": "scw-e0d256",
|
||||
"organization": "3f709602-5e6c-4619-b80c-e841c89734af",
|
||||
"private_ip": "10.14.222.131",
|
||||
"protected": false,
|
||||
"public_ip": {
|
||||
"address": "163.172.170.197",
|
||||
"dynamic": false,
|
||||
"id": "ea081794-a581-4495-8451-386ddaf0a451"
|
||||
},
|
||||
"security_group": {
|
||||
"id": "a37379d2-d8b0-4668-9cfb-1233fc436f7e",
|
||||
"name": "Default security group"
|
||||
},
|
||||
"state": "running",
|
||||
"state_detail": "booted",
|
||||
"tags": [],
|
||||
"volumes": {
|
||||
"0": {
|
||||
"creation_date": "2018-08-14T21:36:56.271545+00:00",
|
||||
"export_uri": "device://dev/vda",
|
||||
"id": "68386fae-4f55-4fbf-aabb-953036a85872",
|
||||
"modification_date": "2018-08-14T21:36:56.271545+00:00",
|
||||
"name": "snapshot-87fc282d-f252-4262-adad-86979d9074cf-2018-04-26_12:42",
|
||||
"organization": "3f709602-5e6c-4619-b80c-e841c89734af",
|
||||
"server": {
|
||||
"id": "12f19bc7-108c-4517-954c-e6b3d0311363",
|
||||
"name": "scw-e0d256"
|
||||
},
|
||||
"size": 25000000000,
|
||||
"state": "available",
|
||||
"volume_type": "l_ssd"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway,
|
||||
ScalewayException,
|
||||
scaleway_argument_spec,
|
||||
SCALEWAY_LOCATION,
|
||||
)
|
||||
|
||||
|
||||
class ScalewayServerFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewayServerFacts, self).__init__(module)
|
||||
self.name = 'servers'
|
||||
|
||||
region = module.params["region"]
|
||||
self.module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_server_facts': ScalewayServerFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,113 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_snapshot_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_snapshot_info) instead.
|
||||
short_description: Gather facts about the Scaleway snapshots available.
|
||||
description:
|
||||
- Gather facts about the Scaleway snapshot available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
options:
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway region to use (for example par1).
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway snapshots facts
|
||||
community.general.scaleway_snapshot_facts:
|
||||
region: par1
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_snapshot_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_snapshot_facts": [
|
||||
{
|
||||
"base_volume": {
|
||||
"id": "68386fae-4f55-4fbf-aabb-953036a85872",
|
||||
"name": "snapshot-87fc282d-f252-4262-adad-86979d9074cf-2018-04-26_12:42"
|
||||
},
|
||||
"creation_date": "2018-08-14T22:34:35.299461+00:00",
|
||||
"id": "b61b4b03-a2e9-4da5-b5ea-e462ac0662d2",
|
||||
"modification_date": "2018-08-14T22:34:54.520560+00:00",
|
||||
"name": "snapshot-87fc282d-f252-4262-adad-86979d9074cf-2018-04-26_12:42 snapshot",
|
||||
"organization": "3f709602-5e6c-4619-b80c-e841c89734af",
|
||||
"size": 25000000000,
|
||||
"state": "available",
|
||||
"volume_type": "l_ssd"
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway,
|
||||
ScalewayException,
|
||||
scaleway_argument_spec,
|
||||
SCALEWAY_LOCATION
|
||||
)
|
||||
|
||||
|
||||
class ScalewaySnapshotFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewaySnapshotFacts, self).__init__(module)
|
||||
self.name = 'snapshots'
|
||||
|
||||
region = module.params["region"]
|
||||
self.module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_snapshot_facts': ScalewaySnapshotFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,108 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: scaleway_volume_facts
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.13
|
||||
why: Deprecated in favour of C(_info) module.
|
||||
alternative: Use M(community.general.scaleway_volume_info) instead.
|
||||
short_description: Gather facts about the Scaleway volumes available.
|
||||
description:
|
||||
- Gather facts about the Scaleway volumes available.
|
||||
author:
|
||||
- "Yanis Guenane (@Spredzy)"
|
||||
- "Remy Leone (@sieben)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.scaleway
|
||||
|
||||
options:
|
||||
region:
|
||||
type: str
|
||||
description:
|
||||
- Scaleway region to use (for example par1).
|
||||
required: true
|
||||
choices:
|
||||
- ams1
|
||||
- EMEA-NL-EVS
|
||||
- par1
|
||||
- EMEA-FR-PAR1
|
||||
- par2
|
||||
- EMEA-FR-PAR2
|
||||
- waw1
|
||||
- EMEA-PL-WAW1
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Scaleway volumes facts
|
||||
community.general.scaleway_volume_facts:
|
||||
region: par1
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
---
|
||||
scaleway_volume_facts:
|
||||
description: Response from Scaleway API
|
||||
returned: success
|
||||
type: complex
|
||||
sample:
|
||||
"scaleway_volume_facts": [
|
||||
{
|
||||
"creation_date": "2018-08-14T20:56:24.949660+00:00",
|
||||
"export_uri": null,
|
||||
"id": "b8d51a06-daeb-4fef-9539-a8aea016c1ba",
|
||||
"modification_date": "2018-08-14T20:56:24.949660+00:00",
|
||||
"name": "test-volume",
|
||||
"organization": "3f709602-5e6c-4619-b80c-e841c89734af",
|
||||
"server": null,
|
||||
"size": 50000000000,
|
||||
"state": "available",
|
||||
"volume_type": "l_ssd"
|
||||
}
|
||||
]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.general.plugins.module_utils.scaleway import (
|
||||
Scaleway, ScalewayException, scaleway_argument_spec,
|
||||
SCALEWAY_LOCATION)
|
||||
|
||||
|
||||
class ScalewayVolumeFacts(Scaleway):
|
||||
|
||||
def __init__(self, module):
|
||||
super(ScalewayVolumeFacts, self).__init__(module)
|
||||
self.name = 'volumes'
|
||||
|
||||
region = module.params["region"]
|
||||
self.module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
try:
|
||||
module.exit_json(
|
||||
ansible_facts={'scaleway_volume_facts': ScalewayVolumeFacts(module).get_resources()}
|
||||
)
|
||||
except ScalewayException as exc:
|
||||
module.fail_json(msg=exc.message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1 +0,0 @@
|
|||
smartos_image_info.py
|
|
@ -47,9 +47,6 @@ EXAMPLES = '''
|
|||
has {{ result.smartos_images[item]['clones'] }} VM(s)"
|
||||
with_items: "{{ result.smartos_images.keys() | list }}"
|
||||
|
||||
# When the module is called as smartos_image_facts, return values are published
|
||||
# in ansible_facts['smartos_images'] and can be used as follows.
|
||||
# Note that this is deprecated and will stop working in community.general 3.0.0.
|
||||
- name: Print information
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ smartos_images[item]['name'] }}-{{ smartos_images[item]['version'] }}
|
||||
|
@ -102,20 +99,12 @@ def main():
|
|||
),
|
||||
supports_check_mode=False,
|
||||
)
|
||||
is_old_facts = module._name in ('smartos_image_facts', 'community.general.smartos_image_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'smartos_image_facts' module has been renamed to 'smartos_image_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
image_facts = ImageFacts(module)
|
||||
|
||||
data = dict(smartos_images=image_facts.return_all_installed_images())
|
||||
|
||||
if is_old_facts:
|
||||
module.exit_json(ansible_facts=data)
|
||||
else:
|
||||
module.exit_json(**data)
|
||||
module.exit_json(**data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
xenserver_guest_info.py
|
|
@ -204,10 +204,6 @@ def main():
|
|||
],
|
||||
)
|
||||
|
||||
if module._name in ('xenserver_guest_facts', 'community.general.xenserver_guest_facts'):
|
||||
module.deprecate("The 'xenserver_guest_facts' module has been renamed to 'xenserver_guest_info'",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
result = {'failed': False, 'changed': False}
|
||||
|
||||
# Module will exit with an error message if no VM is found.
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
vertica_info.py
|
|
@ -233,11 +233,6 @@ def main():
|
|||
login_user=dict(default='dbadmin'),
|
||||
login_password=dict(default=None, no_log=True),
|
||||
), supports_check_mode=True)
|
||||
is_old_facts = module._name in ('vertica_facts', 'community.general.vertica_facts')
|
||||
if is_old_facts:
|
||||
module.deprecate("The 'vertica_facts' module has been renamed to 'vertica_info', "
|
||||
"and the renamed one no longer returns ansible_facts",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
|
||||
if not pyodbc_found:
|
||||
module.fail_json(msg=missing_required_lib('pyodbc'), exception=PYODBC_IMP_ERR)
|
||||
|
@ -269,20 +264,12 @@ def main():
|
|||
configuration_facts = get_configuration_facts(cursor)
|
||||
node_facts = get_node_facts(cursor)
|
||||
|
||||
if is_old_facts:
|
||||
module.exit_json(changed=False,
|
||||
ansible_facts={'vertica_schemas': schema_facts,
|
||||
'vertica_users': user_facts,
|
||||
'vertica_roles': role_facts,
|
||||
'vertica_configuration': configuration_facts,
|
||||
'vertica_nodes': node_facts})
|
||||
else:
|
||||
module.exit_json(changed=False,
|
||||
vertica_schemas=schema_facts,
|
||||
vertica_users=user_facts,
|
||||
vertica_roles=role_facts,
|
||||
vertica_configuration=configuration_facts,
|
||||
vertica_nodes=node_facts)
|
||||
module.exit_json(changed=False,
|
||||
vertica_schemas=schema_facts,
|
||||
vertica_users=user_facts,
|
||||
vertica_roles=role_facts,
|
||||
vertica_configuration=configuration_facts,
|
||||
vertica_nodes=node_facts)
|
||||
except NotSupportedError as e:
|
||||
module.fail_json(msg=to_native(e), exception=traceback.format_exc())
|
||||
except SystemExit:
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
./storage/glusterfs/gluster_heal_info.py
|
|
@ -1 +0,0 @@
|
|||
./storage/glusterfs/gluster_peer.py
|
|
@ -1 +0,0 @@
|
|||
./storage/glusterfs/gluster_volume.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/misc/helm.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/hpilo/hpilo_facts.py
|
|
@ -1 +0,0 @@
|
|||
onepassword_info.py
|
|
@ -20,9 +20,6 @@ requirements:
|
|||
notes:
|
||||
- Tested with C(op) version 0.5.5
|
||||
- "Based on the C(onepassword) lookup plugin by Scott Buchanan <sbuchanan@ri.pn>."
|
||||
- When this module is called with the deprecated C(onepassword_facts) name, potentially sensitive data
|
||||
from 1Password is returned as Ansible facts. Facts are subject to caching if enabled, which means this
|
||||
data could be stored in clear text on disk or in a database.
|
||||
short_description: Gather items from 1Password
|
||||
description:
|
||||
- M(community.general.onepassword_info) wraps the C(op) command line utility to fetch data about one or more 1Password items.
|
||||
|
@ -380,13 +377,7 @@ def main():
|
|||
|
||||
results = {'onepassword': OnePasswordInfo().run()}
|
||||
|
||||
if module._name in ('onepassword_facts', 'community.general.onepassword_facts'):
|
||||
module.deprecate("The 'onepassword_facts' module has been renamed to 'onepassword_info'. "
|
||||
"When called with the new name it no longer returns 'ansible_facts'",
|
||||
version='3.0.0', collection_name='community.general') # was Ansible 2.13
|
||||
module.exit_json(changed=False, ansible_facts=results)
|
||||
else:
|
||||
module.exit_json(changed=False, **results)
|
||||
module.exit_json(changed=False, **results)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
remote_management/redfish/idrac_redfish_facts.py
|
|
@ -1 +0,0 @@
|
|||
web_infrastructure/jenkins_job_facts.py
|
|
@ -1 +0,0 @@
|
|||
./net_tools/ldap/ldap_attr.py
|
|
@ -1 +0,0 @@
|
|||
cloud/memset/memset_memstore_facts.py
|
|
@ -1 +0,0 @@
|
|||
cloud/memset/memset_server_facts.py
|
|
@ -1 +0,0 @@
|
|||
./storage/netapp/na_ontap_gather_facts.py
|
|
@ -1,284 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2016, Peter Sagerson <psagers@ignorare.net>
|
||||
# Copyright: (c) 2016, Jiri Tyr <jiri.tyr@gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r'''
|
||||
---
|
||||
module: ldap_attr
|
||||
short_description: Add or remove LDAP attribute values
|
||||
description:
|
||||
- Add or remove LDAP attribute values.
|
||||
notes:
|
||||
- This only deals with attributes on existing entries. To add or remove
|
||||
whole entries, see M(community.general.ldap_entry).
|
||||
- The default authentication settings will attempt to use a SASL EXTERNAL
|
||||
bind over a UNIX domain socket. This works well with the default Ubuntu
|
||||
install for example, which includes a cn=peercred,cn=external,cn=auth ACL
|
||||
rule allowing root to modify the server configuration. If you need to use
|
||||
a simple bind to access your server, pass the credentials in I(bind_dn)
|
||||
and I(bind_pw).
|
||||
- For I(state=present) and I(state=absent), all value comparisons are
|
||||
performed on the server for maximum accuracy. For I(state=exact), values
|
||||
have to be compared in Python, which obviously ignores LDAP matching
|
||||
rules. This should work out in most cases, but it is theoretically
|
||||
possible to see spurious changes when target and actual values are
|
||||
semantically identical but lexically distinct.
|
||||
- "The I(params) parameter was removed due to circumventing Ansible's parameter
|
||||
handling. The I(params) parameter started disallowing setting the I(bind_pw) parameter in
|
||||
Ansible-2.7 as it was insecure to set the parameter that way."
|
||||
deprecated:
|
||||
removed_in: 3.0.0 # was Ansible 2.14
|
||||
why: 'The current "ldap_attr" module does not support LDAP attribute insertions or deletions with objectClass dependencies.'
|
||||
alternative: 'Use M(community.general.ldap_attrs) instead. Deprecated in community.general 0.2.0.'
|
||||
author:
|
||||
- Jiri Tyr (@jtyr)
|
||||
requirements:
|
||||
- python-ldap
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
- The name of the attribute to modify.
|
||||
type: str
|
||||
required: true
|
||||
state:
|
||||
description:
|
||||
- The state of the attribute values.
|
||||
- If C(present), all given values will be added if they're missing.
|
||||
- If C(absent), all given values will be removed if present.
|
||||
- If C(exact), the set of values will be forced to exactly those provided and no others.
|
||||
- If I(state=exact) and I(value) is an empty list, all values for this attribute will be removed.
|
||||
type: str
|
||||
choices: [ absent, exact, present ]
|
||||
default: present
|
||||
values:
|
||||
description:
|
||||
- The value(s) to add or remove. This can be a string or a list of
|
||||
strings. The complex argument format is required in order to pass
|
||||
a list of strings (see examples).
|
||||
type: raw
|
||||
required: true
|
||||
extends_documentation_fragment:
|
||||
- community.general.ldap.documentation
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Configure directory number 1 for example.com
|
||||
community.general.ldap_attr:
|
||||
dn: olcDatabase={1}hdb,cn=config
|
||||
name: olcSuffix
|
||||
values: dc=example,dc=com
|
||||
state: exact
|
||||
|
||||
# The complex argument format is required here to pass a list of ACL strings.
|
||||
- name: Set up the ACL
|
||||
community.general.ldap_attr:
|
||||
dn: olcDatabase={1}hdb,cn=config
|
||||
name: olcAccess
|
||||
values:
|
||||
- >-
|
||||
{0}to attrs=userPassword,shadowLastChange
|
||||
by self write
|
||||
by anonymous auth
|
||||
by dn="cn=admin,dc=example,dc=com" write
|
||||
by * none'
|
||||
- >-
|
||||
{1}to dn.base="dc=example,dc=com"
|
||||
by dn="cn=admin,dc=example,dc=com" write
|
||||
by * read
|
||||
state: exact
|
||||
|
||||
- name: Declare some indexes
|
||||
community.general.ldap_attr:
|
||||
dn: olcDatabase={1}hdb,cn=config
|
||||
name: olcDbIndex
|
||||
values: "{{ item }}"
|
||||
with_items:
|
||||
- objectClass eq
|
||||
- uid eq
|
||||
|
||||
- name: Set up a root user, which we can use later to bootstrap the directory
|
||||
community.general.ldap_attr:
|
||||
dn: olcDatabase={1}hdb,cn=config
|
||||
name: "{{ item.key }}"
|
||||
values: "{{ item.value }}"
|
||||
state: exact
|
||||
with_dict:
|
||||
olcRootDN: cn=root,dc=example,dc=com
|
||||
olcRootPW: "{SSHA}tabyipcHzhwESzRaGA7oQ/SDoBZQOGND"
|
||||
|
||||
- name: Get rid of an unneeded attribute
|
||||
community.general.ldap_attr:
|
||||
dn: uid=jdoe,ou=people,dc=example,dc=com
|
||||
name: shadowExpire
|
||||
values: []
|
||||
state: exact
|
||||
server_uri: ldap://localhost/
|
||||
bind_dn: cn=admin,dc=example,dc=com
|
||||
bind_pw: password
|
||||
|
||||
#
|
||||
# The same as in the previous example but with the authentication details
|
||||
# stored in the ldap_auth variable:
|
||||
#
|
||||
# ldap_auth:
|
||||
# server_uri: ldap://localhost/
|
||||
# bind_dn: cn=admin,dc=example,dc=com
|
||||
# bind_pw: password
|
||||
#
|
||||
# In the example below, 'args' is a task keyword, passed at the same level as the module
|
||||
- name: Get rid of an unneeded attribute
|
||||
community.general.ldap_attr:
|
||||
dn: uid=jdoe,ou=people,dc=example,dc=com
|
||||
name: shadowExpire
|
||||
values: []
|
||||
state: exact
|
||||
args: "{{ ldap_auth }}"
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
modlist:
|
||||
description: list of modified parameters
|
||||
returned: success
|
||||
type: list
|
||||
sample: '[[2, "olcRootDN", ["cn=root,dc=example,dc=com"]]]'
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils._text import to_native, to_bytes
|
||||
from ansible_collections.community.general.plugins.module_utils.ldap import LdapGeneric, gen_specs
|
||||
|
||||
LDAP_IMP_ERR = None
|
||||
try:
|
||||
import ldap
|
||||
|
||||
HAS_LDAP = True
|
||||
except ImportError:
|
||||
LDAP_IMP_ERR = traceback.format_exc()
|
||||
HAS_LDAP = False
|
||||
|
||||
|
||||
class LdapAttr(LdapGeneric):
|
||||
def __init__(self, module):
|
||||
LdapGeneric.__init__(self, module)
|
||||
|
||||
# Shortcuts
|
||||
self.name = self.module.params['name']
|
||||
self.state = self.module.params['state']
|
||||
|
||||
# Normalize values
|
||||
if isinstance(self.module.params['values'], list):
|
||||
self.values = list(map(to_bytes, self.module.params['values']))
|
||||
else:
|
||||
self.values = [to_bytes(self.module.params['values'])]
|
||||
|
||||
def add(self):
|
||||
values_to_add = list(filter(self._is_value_absent, self.values))
|
||||
|
||||
if len(values_to_add) > 0:
|
||||
modlist = [(ldap.MOD_ADD, self.name, values_to_add)]
|
||||
else:
|
||||
modlist = []
|
||||
|
||||
return modlist
|
||||
|
||||
def delete(self):
|
||||
values_to_delete = list(filter(self._is_value_present, self.values))
|
||||
|
||||
if len(values_to_delete) > 0:
|
||||
modlist = [(ldap.MOD_DELETE, self.name, values_to_delete)]
|
||||
else:
|
||||
modlist = []
|
||||
|
||||
return modlist
|
||||
|
||||
def exact(self):
|
||||
try:
|
||||
results = self.connection.search_s(
|
||||
self.dn, ldap.SCOPE_BASE, attrlist=[self.name])
|
||||
except ldap.LDAPError as e:
|
||||
self.fail("Cannot search for attribute %s" % self.name, e)
|
||||
|
||||
current = results[0][1].get(self.name, [])
|
||||
modlist = []
|
||||
|
||||
if frozenset(self.values) != frozenset(current):
|
||||
if len(current) == 0:
|
||||
modlist = [(ldap.MOD_ADD, self.name, self.values)]
|
||||
elif len(self.values) == 0:
|
||||
modlist = [(ldap.MOD_DELETE, self.name, None)]
|
||||
else:
|
||||
modlist = [(ldap.MOD_REPLACE, self.name, self.values)]
|
||||
|
||||
return modlist
|
||||
|
||||
def _is_value_present(self, value):
|
||||
""" True if the target attribute has the given value. """
|
||||
try:
|
||||
is_present = bool(
|
||||
self.connection.compare_s(self.dn, self.name, value))
|
||||
except ldap.NO_SUCH_ATTRIBUTE:
|
||||
is_present = False
|
||||
|
||||
return is_present
|
||||
|
||||
def _is_value_absent(self, value):
|
||||
""" True if the target attribute doesn't have the given value. """
|
||||
return not self._is_value_present(value)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=gen_specs(
|
||||
name=dict(type='str', required=True),
|
||||
params=dict(type='dict'),
|
||||
state=dict(type='str', default='present', choices=['absent', 'exact', 'present']),
|
||||
values=dict(type='raw', required=True),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
if not HAS_LDAP:
|
||||
module.fail_json(msg=missing_required_lib('python-ldap'),
|
||||
exception=LDAP_IMP_ERR)
|
||||
|
||||
if module.params['params']:
|
||||
module.fail_json(msg="The `params` option to ldap_attr was removed in since it circumvents Ansible's option handling")
|
||||
|
||||
# Instantiate the LdapAttr object
|
||||
ldap = LdapAttr(module)
|
||||
|
||||
state = module.params['state']
|
||||
|
||||
# Perform action
|
||||
if state == 'present':
|
||||
modlist = ldap.add()
|
||||
elif state == 'absent':
|
||||
modlist = ldap.delete()
|
||||
elif state == 'exact':
|
||||
modlist = ldap.exact()
|
||||
|
||||
changed = False
|
||||
|
||||
if len(modlist) > 0:
|
||||
changed = True
|
||||
|
||||
if not module.check_mode:
|
||||
try:
|
||||
ldap.connection.modify_s(ldap.dn, modlist)
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Attribute action failed.", details=to_native(e))
|
||||
|
||||
module.exit_json(changed=changed, modlist=modlist)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -17,7 +17,7 @@ short_description: Add or remove LDAP entries.
|
|||
description:
|
||||
- Add or remove LDAP entries. This module only asserts the existence or
|
||||
non-existence of an LDAP entry, not its attributes. To assert the
|
||||
attribute values of an entry, see M(community.general.ldap_attr).
|
||||
attribute values of an entry, see M(community.general.ldap_attrs).
|
||||
notes:
|
||||
- The default authentication settings will attempt to use a SASL EXTERNAL
|
||||
bind over a UNIX domain socket. This works well with the default Ubuntu
|
||||
|
@ -37,7 +37,7 @@ options:
|
|||
description:
|
||||
- If I(state=present), attributes necessary to create an entry. Existing
|
||||
entries are never modified. To assert specific attribute values on an
|
||||
existing entry, use M(community.general.ldap_attr) module instead.
|
||||
existing entry, use M(community.general.ldap_attrs) module instead.
|
||||
type: dict
|
||||
objectClass:
|
||||
description:
|
||||
|
@ -199,7 +199,7 @@ def main():
|
|||
exception=LDAP_IMP_ERR)
|
||||
|
||||
if module.params['params']:
|
||||
module.fail_json(msg="The `params` option to ldap_attr was removed since it circumvents Ansible's option handling")
|
||||
module.fail_json(msg="The `params` option to ldap_entry was removed since it circumvents Ansible's option handling")
|
||||
|
||||
state = module.params['state']
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
./web_infrastructure/nginx_status_facts.py
|
|
@ -1 +0,0 @@
|
|||
cloud/opennebula/one_image_facts.py
|
|
@ -1 +0,0 @@
|
|||
identity/onepassword_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_datacenter_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_enclosure_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_ethernet_network_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_fc_network_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_fcoe_network_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_logical_interconnect_group_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_network_set_facts.py
|
|
@ -1 +0,0 @@
|
|||
remote_management/oneview/oneview_san_manager_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/online/online_server_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/online/online_user_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/misc/ovirt.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_affinity_label_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_api_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_cluster_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_datacenter_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_disk_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_event_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_external_provider_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_group_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_host_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_host_storage_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_network_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_nic_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_permission_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_quota_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_scheduling_policy_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_snapshot_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_storage_domain_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_storage_template_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_storage_vm_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_tag_facts.py
|
|
@ -1 +0,0 @@
|
|||
./cloud/ovirt/ovirt_template_facts.py
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue