From 84d6bb226b2a3ebeb866ba7486512f2348020879 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Wed, 17 Apr 2019 11:37:03 -0400 Subject: [PATCH] ceph-iscsi-gw: Remove library directory The library directory that contain the custom ceph modules in present in the ceph-ansible root directory. All igw_* mocules are already present there so we don't need the one present in roles/ceph-iscsi-gw/library. Also remove the associated spec file. Signed-off-by: Dimitri Savineau (cherry picked from commit c8814d13310c67665da6d39058807f8b3e089d8d) --- roles/ceph-iscsi-gw/ceph-iscsi-ansible.spec | 109 ---------- roles/ceph-iscsi-gw/library/igw_client.py | 135 ------------ roles/ceph-iscsi-gw/library/igw_gateway.py | 135 ------------ roles/ceph-iscsi-gw/library/igw_lun.py | 168 --------------- roles/ceph-iscsi-gw/library/igw_purge.py | 216 -------------------- 5 files changed, 763 deletions(-) delete mode 100644 roles/ceph-iscsi-gw/ceph-iscsi-ansible.spec delete mode 100644 roles/ceph-iscsi-gw/library/igw_client.py delete mode 100644 roles/ceph-iscsi-gw/library/igw_gateway.py delete mode 100644 roles/ceph-iscsi-gw/library/igw_lun.py delete mode 100644 roles/ceph-iscsi-gw/library/igw_purge.py diff --git a/roles/ceph-iscsi-gw/ceph-iscsi-ansible.spec b/roles/ceph-iscsi-gw/ceph-iscsi-ansible.spec deleted file mode 100644 index c33d01865..000000000 --- a/roles/ceph-iscsi-gw/ceph-iscsi-ansible.spec +++ /dev/null @@ -1,109 +0,0 @@ -Name: ceph-iscsi-ansible -Version: 2.0 -Release: 1%{?dist} -Summary: Ansible playbooks for deploying LIO iscsi gateways in front of a Ceph cluster -License: ASL 2.0 -URL: https://github.com/pcuzner/ceph-iscsi-ansible -Source0: https://github.com/pcuzner/ceph-iscsi-ansible/archive/%{version}/%{name}-%{version}.tar.gz -BuildArch: noarch - -Requires: ansible >= 1.9 -Requires: ceph-ansible >= 1.0.5 - -%description -Ansible playbooks that define nodes as iSCSI gateways (LIO). Once complete, the -LIO instance on each node provides an ISCSI endpoint for clients to connect to. -The playbook defines the front-end iSCSI environment (target -> tpgN -> -NodeACLS/client), as well as the underlying rbd definition for the rbd images -to be exported over iSCSI. - -ceph-iscsi-gw.yml ......... defines the LIO configuration(defined by - group_vars/ceph-iscsi-gw.yml) -purge-iscsi-gateways.yml .. deletes the LIO configuration, and optionally rbd's - from the environment - -NB: The playbooks are dependent upon the ceph-iscsi-config package being -installed/available to the hosts that will become iSCSI gateways. - -%prep -%setup -q - -%build - -%install -mkdir -p %{buildroot}%{_datarootdir}/ceph-ansible - -for f in group_vars library roles ceph-iscsi-gw.yml purge-iscsi-gateways.yml; do - cp -a $f %{buildroot}%{_datarootdir}/ceph-ansible -done - -%files -%doc LICENSE -%doc README -%{_datarootdir}/ceph-ansible/ceph-iscsi-gw.yml -%{_datarootdir}/ceph-ansible/purge-iscsi-gateways.yml -%{_datarootdir}/ceph-ansible/group_vars/ceph-iscsi-gw.sample -%{_datarootdir}/ceph-ansible/roles/ceph-iscsi-gw -%{_datarootdir}/ceph-ansible/library/igw* -%exclude %{_datarootdir}/ceph-ansible/library/igw*.pyo -%exclude %{_datarootdir}/ceph-ansible/library/igw*.pyc - -%changelog -* Fri Jan 13 2017 Paul Cuzner - 2.0-1 -- converted from device-mapper/krbd to TCMU based rbd configurations -- renamed iscsi-gateway config file to use .cfg extension -- renamed purge playbook to match naming in ceph-ansible - -* Fri Nov 04 2016 Paul Cuzner - 1.5-1 -- playbook now seeds the configuration directory on ansible host (rhbz 1390026) -- resolve a 1.4 regression affecting the igw_purge module -- fail gracefully if bogus client name is given (rhbz 1390023) - -* Thu Oct 27 2016 Paul Cuzner - 1.4-1 -- clients can now be added without images or chap defined using null strings -- changed parameters for client definition to position for other auth mechanisms -- adapt purge module to use revised disk naming scheme within config object -- updated group_vars sample to reflect name changes -- added state= setting to LUN definitions (enabling disks to be add/removed) -- fix syntax issue during ceph.conf seed process -- documentation added to the Ansible modules - -* Fri Oct 21 2016 Paul Cuzner - 1.3-1 -- removed rsync rpm dependency (BZ 1386090) -- ceph.conf pulled from seed monitor, then pushed to gateways using copy task -- add a template based config file to each gateway for runtime info -- add additional variables allowing non-default ceph cluster names/keyrings (BZ 1386617) - -* Sat Oct 15 2016 Paul Cuzner - 1.2-1 -- documented the passwordless ssh requirement for the seed_monitor node -- fix BZ 1384505 mask the target service preventing manual start/stop -- fix BZ 1384858 when the admin updates ansible hosts but not the gateway_ip_list variable - -* Wed Oct 12 2016 Paul Cuzner - 1.1-1 -- updated playbook to modify lvm.conf to exclude the dm devices created for mapped rbds - -* Mon Oct 10 2016 Paul Cuzner - 1.0-1 -- fix : allow client_connections and rbd_devices to be be empty to skip those steps -- add usage guidelines to the group_vars/ceph-iscsi-gw.sample file -- added variable to allow pre-req checks to be bypassed during a run -- updated list of rpm pre-req that ansible checks for -- add synchronize task to the playbook to copy admin keyring to gateway node(s) -- updated igw_purge module to allow for the deletion of the alua port groups - -* Thu Oct 06 2016 Paul Cuzner - 0.8-1 -- fix : purge_gateways.yml was missing -- removed packages directory to clean up the source archive -- spec file updates (dependencies) - -* Wed Oct 05 2016 Paul Cuzner - 0.7-1 -- removed service dependencies for rbdmap/target (replaced by rbd-target-gw form ceph-iscsi-config rpm) -- removed target overrides files -- updated playbook to add skip_partx yes to multipath.conf - -* Mon Oct 03 2016 Paul Cuzner - 0.6-1 -- changed the main function to have an ansible prefix to allow the code to know where it is invoked from -- updated the purge module to support image names being prefixed by a pool i.e. pool/image - -* Tue Sep 27 2016 Paul Cuzner - 0.5-1 -- initial rpm package - diff --git a/roles/ceph-iscsi-gw/library/igw_client.py b/roles/ceph-iscsi-gw/library/igw_client.py deleted file mode 100644 index cb6051938..000000000 --- a/roles/ceph-iscsi-gw/library/igw_client.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python - -__author__ = 'pcuzner@redhat.com' - -DOCUMENTATION = """ ---- -module: igw_client -short_description: Manage iscsi gateway client definitions -description: - - This module calls the 'client' configuration management module installed - on the iscsi gateway node to handle the definition of iscsi clients on the - gateway(s). This definition will setup iscsi authentication (e.g. chap), - and mask the required rbd images to the client. - - The 'client' configuration module is provided by ceph-iscsi-config - rpm which is installed on the gateway nodes. - - To support module debugging, this module logs to - /var/log/ansible-module-igw_config.log on the target machine(s). - -option: - client_iqn: - description: - - iqn of the client machine which should be connected or removed from the - iscsi gateway environment - required: true - - image_list: - description: - - comma separated string providing the rbd images that this - client definition should have. The rbd images provided must use the - following format . - e.g. rbd.disk1,rbd.disk2 - required: true - - chap: - description: - - chap credentials for the client to authenticate to the gateways - to gain access to the exported rbds (LUNs). The credentials is a string - value of the form 'username/password'. The iscsi client must then use - these settings to gain access to any LUN resources. - required: true - - state: - description: - - desired state for this client - absent or present - required: true - -requirements: ['ceph-iscsi-config'] - -author: - - 'Paul Cuzner' - -""" - -import os # noqa E402 -import logging # noqa E402 -from logging.handlers import RotatingFileHandler # noqa E402 -from ansible.module_utils.basic import * # noqa E402 - -from ceph_iscsi_config.client import GWClient # noqa E402 -import ceph_iscsi_config.settings as settings # noqa E402 - - -# the main function is called ansible_main to allow the call stack -# to be checked to determine whether the call to the ceph_iscsi_config -# modules is from ansible or not -def ansible_main(): - - fields = { - "client_iqn": {"required": True, "type": "str"}, - "image_list": {"required": True, "type": "str"}, - "chap": {"required": True, "type": "str"}, - "state": { - "required": True, - "choices": ['present', 'absent'], - "type": "str" - }, - } - - module = AnsibleModule(argument_spec=fields, # noqa F405 - supports_check_mode=False) - - client_iqn = module.params['client_iqn'] - - if module.params['image_list']: - image_list = module.params['image_list'].split(',') - else: - image_list = [] - - chap = module.params['chap'] - desired_state = module.params['state'] - - logger.info("START - Client configuration started : {}".format(client_iqn)) - - # The client is defined using the GWClient class. This class handles - # client attribute updates, rados configuration object updates and LIO - # settings. Since the logic is external to this custom module, clients - # can be created/deleted by other methods in the same manner. - client = GWClient(logger, client_iqn, image_list, chap) - if client.error: - module.fail_json(msg=client.error_msg) - - client.manage(desired_state) - if client.error: - module.fail_json(msg=client.error_msg) - - logger.info("END - Client configuration complete - {} " - "changes made".format(client.change_count)) - - changes_made = True if client.change_count > 0 else False - - module.exit_json(changed=changes_made, - meta={"msg": "Client definition completed {} " - "changes made".format(client.change_count)}) - - -if __name__ == '__main__': - - module_name = os.path.basename(__file__).replace('ansible_module_', '') - logger = logging.getLogger(os.path.basename(module_name)) - logger.setLevel(logging.DEBUG) - handler = RotatingFileHandler('/var/log/ansible-module-igw_config.log', - maxBytes=5242880, - backupCount=7) - log_fmt = logging.Formatter('%(asctime)s %(name)s %(levelname)-8s : ' - '%(message)s') - handler.setFormatter(log_fmt) - logger.addHandler(handler) - - # initialise global variables used by all called modules - # e.g. ceph conffile, keyring etc - settings.init() - - ansible_main() diff --git a/roles/ceph-iscsi-gw/library/igw_gateway.py b/roles/ceph-iscsi-gw/library/igw_gateway.py deleted file mode 100644 index 2f7679447..000000000 --- a/roles/ceph-iscsi-gw/library/igw_gateway.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python -__author__ = 'pcuzner@redhat.com' - - -DOCUMENTATION = """ ---- -module: igw_gateway -short_description: Manage the iscsi gateway definition -description: - - This module calls the 'gateway' configuration management module installed - on the iscsi gateway node(s) to handle the definition of iscsi gateways. - The module will configure; - * the iscsi target and target portal group (TPG) - * rbd maps to the gateway and registration of those rbds as LUNs to the - kernels LIO subsystem - - The actual configuration modules are provided by ceph-iscsi-config rpm - which is installed on the gateway nodes. - - To support module debugging, this module logs to - /var/log/ansible-module-igw_config.log on the target machine(s). - -option: - gateway_iqn: - description: - - iqn that all gateway nodes will use to present a common system image - name to iscsi clients - required: true - - gateway_ip_list: - description: - - comma separated string providing the IP addresses that will be used - as iSCSI portal IPs to accept iscsi client connections. Each IP address - should equate to an IP on a gateway node - typically dedicated to iscsi - traffic. The order of the IP addresses determines the TPG sequence - within the target definition - so once defined, new gateways can be - added but *must* be added to the end of this list to preserve the tpg - sequence - - e.g. 192.168.122.101,192.168.122.103 - required: true - - mode: - description: - - mode in which to run the gateway module. Two modes are supported - target ... define the iscsi target iqn, tpg's and portals - map ...... map luns to the tpg's, and also define the ALUA path setting - for each LUN (activeOptimized/activenonoptimized) - required: true - - -requirements: ['ceph-iscsi-config'] - -author: - - 'Paul Cuzner' - -""" - -import os # noqa E402 -import logging # noqa E402 - -from logging.handlers import RotatingFileHandler # noqa E402 -from ansible.module_utils.basic import * # noqa E402 - -import ceph_iscsi_config.settings as settings # noqa E402 - -from ceph_iscsi_config.gateway import GWTarget # noqa E402 -from ceph_iscsi_config.utils import valid_ip # noqa E402 - - -# the main function is called ansible_main to allow the call stack -# to be checked to determine whether the call to the ceph_iscsi_config -# modules is from ansible or not -def ansible_main(): - # Configures the gateway on the host. All images defined are added to - # the default tpg for later allocation to clients - fields = {"gateway_iqn": {"required": True, "type": "str"}, - "gateway_ip_list": {"required": True}, # "type": "list"}, - "mode": { - "required": True, - "choices": ['target', 'map'] - } - } - - module = AnsibleModule(argument_spec=fields, # noqa F405 - supports_check_mode=False) - - gateway_iqn = module.params['gateway_iqn'] - gateway_ip_list = module.params['gateway_ip_list'].split(',') - mode = module.params['mode'] - - if not valid_ip(gateway_ip_list): - module.fail_json(msg="Invalid gateway IP address(es) provided - port " - "22 check failed ({})".format(gateway_ip_list)) - - logger.info("START - GATEWAY configuration started - mode {}".format(mode)) - - gateway = GWTarget(logger, gateway_iqn, gateway_ip_list) - if gateway.error: - logger.critical("(ansible_main) Gateway init failed - " - "{}".format(gateway.error_msg)) - module.fail_json(msg="iSCSI gateway initialisation failed " - "({})".format(gateway.error_msg)) - - gateway.manage(mode) - - if gateway.error: - logger.critical("(main) Gateway creation or load failed, " - "unable to continue") - module.fail_json(msg="iSCSI gateway creation/load failure " - "({})".format(gateway.error_msg)) - - logger.info("END - GATEWAY configuration complete") - module.exit_json(changed=gateway.changes_made, - meta={"msg": "Gateway setup complete"}) - - -if __name__ == '__main__': - - module_name = os.path.basename(__file__).replace('ansible_module_', '') - logger = logging.getLogger(os.path.basename(module_name)) - logger.setLevel(logging.DEBUG) - handler = RotatingFileHandler('/var/log/ansible-module-igw_config.log', - maxBytes=5242880, - backupCount=7) - log_fmt = logging.Formatter('%(asctime)s %(name)s %(levelname)-8s : ' - '%(message)s') - handler.setFormatter(log_fmt) - logger.addHandler(handler) - - # initialise global variables used by all called modules - # e.g. ceph conffile, keyring etc - settings.init() - - ansible_main() diff --git a/roles/ceph-iscsi-gw/library/igw_lun.py b/roles/ceph-iscsi-gw/library/igw_lun.py deleted file mode 100644 index 93d94b127..000000000 --- a/roles/ceph-iscsi-gw/library/igw_lun.py +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env python - -__author__ = 'pcuzner@redhat.com' - -DOCUMENTATION = """ ---- -module: igw_lun -short_description: Manage ceph rbd images to present as iscsi LUNs to clients -description: - - This module calls the 'lun' configuration management module installed - on the iscsi gateway node(s). The lun module handles the creation and resize # noqa E501 - of rbd images, and then maps these rbd devices to the gateway node(s) to be - exposed through the kernel's LIO target. - - To support module debugging, this module logs to /var/log/ansible-module-igw_config.log # noqa E501 - on the target machine(s). - -option: - pool: - description: - - The ceph pool where the image should exist or be created in. - - NOTE - The pool *must* exist prior to the Ansible run. - - required: true - - image: - description: - - this is the rbd image name to create/resize - if the rbd does not exist it - is created for you with the settings optimised for exporting over iscsi. - required: true - - size: - description: - - The size of the rbd image to create/resize. The size is numeric suffixed by - G or T (GB or TB). Increasing the size of a LUN is supported, but if a size - is provided that is smaller that the current size, the request is simply ignored. - - e.g. 100G - required: true - - host: - description: - - the host variable defines the name of the gateway node that will be - the allocation host for this rbd image. RBD creation and resize can - only be performed by one gateway, the other gateways in the - configuration will wait for the operation to complete. - required: true - - features: - description: - - placeholder to potentially allow different rbd features to be set at - allocation time by Ansible. NOT CURRENTLY USED - required: false - - state: - description: - - desired state for this LUN - absent or present. For a state='absent' - request, the lun module will verify that the rbd image is not allocated to - a client. As long as the rbd image is not in use, the LUN definition will be - removed from LIO, unmapped from all gateways AND DELETED. - - USE WITH CARE! - required: true - -requirements: ['ceph-iscsi-config'] - -author: - - 'Paul Cuzner' - -""" -import os # noqa E402 -import logging # noqa E402 -from logging.handlers import RotatingFileHandler # noqa E402 - -from ansible.module_utils.basic import * # noqa E402 - -from ceph_iscsi_config.lun import LUN # noqa E402 -from ceph_iscsi_config.utils import valid_size # noqa E402 -import ceph_iscsi_config.settings as settings # noqa E402 - -# the main function is called ansible_main to allow the call stack -# to be checked to determine whether the call to the ceph_iscsi_config -# modules is from ansible or not - - -def ansible_main(): - - # Define the fields needs to create/map rbd's the the host(s) - # NB. features and state are reserved/unused - fields = { - "pool": {"required": False, "default": "rbd", "type": "str"}, - "image": {"required": True, "type": "str"}, - "size": {"required": True, "type": "str"}, - "host": {"required": True, "type": "str"}, - "features": {"required": False, "type": "str"}, - "state": { - "required": False, - "default": "present", - "choices": ['present', 'absent'], - "type": "str" - }, - } - - # not supporting check mode currently - module = AnsibleModule(argument_spec=fields, # noqa F405 - supports_check_mode=False) - - pool = module.params["pool"] - image = module.params['image'] - size = module.params['size'] - allocating_host = module.params['host'] - desired_state = module.params['state'] - - ################################################ - # Validate the parameters passed from Ansible # - ################################################ - if not valid_size(size): - logger.critical("image '{}' has an invalid size specification '{}' " - "in the ansible configuration".format(image, - size)) - module.fail_json(msg="(main) Unable to use the size parameter '{}' " - "for image '{}' from the playbook - " - "must be a number suffixed by M,G " - "or T".format(size, - image)) - - # define a lun object and perform some initial parameter validation - lun = LUN(logger, pool, image, size, allocating_host) - if lun.error: - module.fail_json(msg=lun.error_msg) - - logger.info("START - LUN configuration started for {}/{}".format(pool, - image)) - - # attempt to create/allocate the LUN for LIO - lun.manage(desired_state) - if lun.error: - module.fail_json(msg=lun.error_msg) - - if lun.num_changes == 0: - logger.info("END - No changes needed") - else: - logger.info("END - {} configuration changes " - "made".format(lun.num_changes)) - - module.exit_json(changed=(lun.num_changes > 0), - meta={"msg": "Configuration updated"}) - - -if __name__ == '__main__': - - module_name = os.path.basename(__file__).replace('ansible_module_', '') - logger = logging.getLogger(os.path.basename(module_name)) - logger.setLevel(logging.DEBUG) - handler = RotatingFileHandler('/var/log/ansible-module-igw_config.log', - maxBytes=5242880, - backupCount=7) - log_fmt = logging.Formatter('%(asctime)s %(name)s %(levelname)-8s : ' - '%(message)s') - handler.setFormatter(log_fmt) - logger.addHandler(handler) - - # initialise global variables used by all called modules - # e.g. ceph conffile, keyring etc - settings.init() - - ansible_main() diff --git a/roles/ceph-iscsi-gw/library/igw_purge.py b/roles/ceph-iscsi-gw/library/igw_purge.py deleted file mode 100644 index ce125b497..000000000 --- a/roles/ceph-iscsi-gw/library/igw_purge.py +++ /dev/null @@ -1,216 +0,0 @@ -#!/usr/bin/env python - -DOCUMENTATION = """ ---- -module: igw_purge -short_description: Provide a purge capability to remove an iSCSI gateway -environment -description: - - This module handles the removal of a gateway configuration from a ceph - environment. - The playbook that calls this module prompts the user for the type of purge - to perform. - The purge options are; - all ... purge all LIO configuration *and* delete all defined rbd images - lio ... purge only the LIO configuration (rbd's are left intact) - - USE WITH CAUTION - - To support module debugging, this module logs to - /var/log/ansible-module-igw_config.log on each target machine(s). - -option: - mode: - description: - - the mode defines the type of purge requested - gateway ... remove the LIO configuration only - disks ... remove the rbd disks defined to the gateway - required: true - -requirements: ['ceph-iscsi-config', 'python-rtslib'] - -author: - - 'Paul Cuzner' - -""" - -import os # noqa E402 -import logging # noqa E402 -import socket # noqa E402 - -from logging.handlers import RotatingFileHandler # noqa E402 -from ansible.module_utils.basic import * # noqa E402 - -import ceph_iscsi_config.settings as settings # noqa E402 -from ceph_iscsi_config.common import Config # noqa E402 -from ceph_iscsi_config.lio import LIO, Gateway # noqa E402 -from ceph_iscsi_config.utils import ip_addresses, resolve_ip_addresses # noqa E402 - -__author__ = 'pcuzner@redhat.com' - - -def delete_group(module, image_list, cfg): - - logger.debug("RBD Images to delete are : {}".format(','.join(image_list))) - pending_list = list(image_list) - - for rbd_path in image_list: - delete_rbd(module, rbd_path) - disk_key = rbd_path.replace('/', '.', 1) - cfg.del_item('disks', disk_key) - pending_list.remove(rbd_path) - cfg.changed = True - - if cfg.changed: - cfg.commit() - - return pending_list - - -def delete_rbd(module, rbd_path): - - logger.debug("issuing delete for {}".format(rbd_path)) - rm_cmd = 'rbd --no-progress --conf {} rm {}'.format(settings.config.cephconf, # noqa E501 - rbd_path) - rc, rm_out, err = module.run_command(rm_cmd, use_unsafe_shell=True) - logger.debug("delete RC = {}, {}".format(rc, rm_out, err)) - if rc != 0: - logger.error("Could not fully cleanup image {}. Manually run the rbd " - "command line tool to remove.".format(rbd_path)) - - -def is_cleanup_host(config): - """ - decide which gateway host should be responsible for any non-specific - updates to the config object - :param config: configuration dict from the rados pool - :return: boolean indicating whether the addition cleanup should be - performed by the running host - """ - cleanup = False - - if 'ip_list' in config.config["gateways"]: - - gw_1 = config.config["gateways"]["ip_list"][0] - - local_ips = ip_addresses() - usable_ips = resolve_ip_addresses(gw_1) - for ip in usable_ips: - if ip in local_ips: - cleanup = True - break - - return cleanup - - -def ansible_main(): - - fields = {"mode": {"required": True, - "type": "str", - "choices": ["gateway", "disks"] - } - } - - module = AnsibleModule(argument_spec=fields, # noqa F405 - supports_check_mode=False) - - run_mode = module.params['mode'] - changes_made = False - - logger.info("START - GATEWAY configuration PURGE started, run mode " - "is {}".format(run_mode)) - cfg = Config(logger) - this_host = socket.gethostname().split('.')[0] - perform_cleanup_tasks = is_cleanup_host(cfg) - - # - # Purge gateway configuration, if the config has gateways - if run_mode == 'gateway' and len(cfg.config['gateways'].keys()) > 0: - - lio = LIO() - gateway = Gateway(cfg) - - if gateway.session_count() > 0: - module.fail_json(msg="Unable to purge - gateway still has active " - "sessions") - - gateway.drop_target(this_host) - if gateway.error: - module.fail_json(msg=gateway.error_msg) - - lio.drop_lun_maps(cfg, perform_cleanup_tasks) - if lio.error: - module.fail_json(msg=lio.error_msg) - - if gateway.changed or lio.changed: - - # each gateway removes it's own entry from the config - cfg.del_item("gateways", this_host) - - if perform_cleanup_tasks: - cfg.reset = True - - # drop all client definitions from the configuration object - client_names = cfg.config["clients"].keys() - for client in client_names: - cfg.del_item("clients", client) - - cfg.del_item("gateways", "iqn") - cfg.del_item("gateways", "created") - cfg.del_item("gateways", "ip_list") - - cfg.commit() - - changes_made = True - - elif run_mode == 'disks' and len(cfg.config['disks'].keys()) > 0: - # - # Remove the disks on this host, that have been registered in the - # config object - # - # if the owner field for a disk is set to this host, this host can - # safely delete it - # nb. owner gets set at rbd allocation and mapping time - images_left = [] - - # delete_list will contain a list of pool/image names where the owner - # is this host - delete_list = [key.replace('.', '/', 1) for key in cfg.config['disks'] - if cfg.config['disks'][key]['owner'] == this_host] - - if delete_list: - images_left = delete_group(module, delete_list, cfg) - - # if the delete list still has entries we had problems deleting the - # images - if images_left: - module.fail_json(msg="Problems deleting the following rbd's : " - "{}".format(','.join(images_left))) - - changes_made = cfg.changed - - logger.debug("ending lock state variable {}".format(cfg.config_locked)) - - logger.info("END - GATEWAY configuration PURGE complete") - - module.exit_json(changed=changes_made, - meta={"msg": "Purge of iSCSI settings ({}) " - "complete".format(run_mode)}) - - -if __name__ == '__main__': - - module_name = os.path.basename(__file__).replace('ansible_module_', '') - logger = logging.getLogger(os.path.basename(module_name)) - logger.setLevel(logging.DEBUG) - handler = RotatingFileHandler('/var/log/ansible-module-igw_config.log', - maxBytes=5242880, - backupCount=7) - log_fmt = logging.Formatter('%(asctime)s %(name)s %(levelname)-8s : ' - '%(message)s') - handler.setFormatter(log_fmt) - logger.addHandler(handler) - - settings.init() - - ansible_main()