commit eee4bc54fe29b2ff37440fd0bcde3682768b2934 Author: Gael Chamoulaud (Strider) Date: Mon Oct 5 15:07:42 2020 +0200 Retire containerized_undercloud_docker validation This patch removes this validation because it is now obsolete and should be replaced by the container_status validation which is doing the same. Change-Id: I8815528c70c1894cf3c7542647467a9f50fd6d21 Signed-off-by: Gael Chamoulaud (Strider) diff --git a/doc/source/modules/modules-docker_facts.rst b/doc/source/modules/modules-docker_facts.rst deleted file mode 100644 index 840fb81..0000000 --- a/doc/source/modules/modules-docker_facts.rst +++ /dev/null @@ -1,15 +0,0 @@ -===================== -Module - docker_facts -===================== - - -This module provides for the following ansible plugin: - - * docker_facts - - -.. ansibleautoplugin:: - :module: library/docker_facts.py - :documentation: true - :examples: true - diff --git a/doc/source/roles/role-containerized_undercloud_docker.rst b/doc/source/roles/role-containerized_undercloud_docker.rst deleted file mode 100644 index a150542..0000000 --- a/doc/source/roles/role-containerized_undercloud_docker.rst +++ /dev/null @@ -1,7 +0,0 @@ -=============================== -containerized_undercloud_docker -=============================== - -.. ansibleautoplugin:: - :role: roles/containerized_undercloud_docker - diff --git a/library/docker_facts.py b/library/docker_facts.py deleted file mode 100644 index fd5bcaf..0000000 --- a/library/docker_facts.py +++ /dev/null @@ -1,245 +0,0 @@ -#!/usr/bin/env python -# Copyright 2018 Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -import itertools - -from ansible.module_utils.basic import AnsibleModule - -import six -six.add_metaclass(type) - - -ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], - 'supported_by': 'community'} - -DOCUMENTATION = """ ---- -module: docker_facts -version_added: '2.6' -short_description: Gather list of volumes, images, containers -notes: - - When specifying mulitple filters, only assets matching B(all) filters - will be returned. -description: - - Gather a list of volumes, images, and containers on a running system - - Return both filtered and unfiltered lists of volumes, images, - and containers. -options: - image_filter: - description: - - List of k=v pairs to use as a filter for images. - type: list - required: false - volume_filter: - description: - - List of k=v pairs to use as a filter for volumes. - type: list - required: false - container_filter: - description: - - List of k=v pairs to use as a filter for containers. - type: list - required: false - -""" - -EXAMPLES = """ -- name: Gather Docker facts - docker_facts: - -- name: Gather filtered Docker facts - docker_facts: - image_filter: - - dangling=true - volume_filter: - - dangling=true - container_filter: - - status=exited - - status=dead - -- name: Remove containers that matched filters - docker_container: - name: "{{ item }}" - state: absent - loop: "{{ docker.containers_filtered | map(attribute='id') | list }}" - -""" - -RETURN = """ -docker: - description: > - Lists of container, volume, and image UUIDs, - both filtered and unfiltered. - returned: always - type: complex - contains: - containers: - description: List of dictionaries of container name, state, and ID - returned: always - type: complex - containers_filtered: - description: > - List of dictionaries of container name, state, and ID - that matched the filter(s) - returned: always - type: complex - images: - description: List of image UUIDs - returned: always - type: list - images_filtered: - description: List of UUIDs that matched the filter(s) - returned: always - type: list - volumes: - description: List of volume UUIDs - returned: always - type: list - volumes_filtered: - description: List of UUIDs that matched the filter(s) - returned: always - type: list -""" - -DOCKER_SUBCOMMAND_LOOKUP = [ - ('images', 'images', '-q'), - ('volumes', 'volume ls', '-q'), - ('containers', 'ps -a', '--format {{.Names}}##{{.ID}}##{{.Status}}') -] - - -def run_docker_command( - module, - docker_bin, - sub_command=[], - opts='-q', - filters=[]): - - for item in docker_bin, sub_command, opts, filters: - if not isinstance(item, list): - item = item.split('\n') - - if not isinstance(docker_bin, list): - docker_bin = docker_bin.split() - - if not isinstance(sub_command, list): - sub_command = sub_command.split() - - if not isinstance(opts, list): - opts = opts.split() - - if not isinstance(filters, list): - filters = filters.split() - - filters = ['-f ' + i for i in filters] - command = list(itertools.chain(docker_bin, sub_command, opts, filters)) - rc, out, err = module.run_command(command) - - if rc != 0: - module.fail_json( - msg='Error running command {}.\n\n \ - Original error:\n\n{}'.format(command, err)) - - if out == '': - out = [] - else: - out = out.strip().split('\n') - - return rc, out, err - - -def main(): - module = AnsibleModule( - argument_spec=dict( - image_filter=dict(type='list', default=[]), - volume_filter=dict(type='list', default=[]), - container_filter=dict(type='list', default=[]), - ), - - supports_check_mode=True - ) - - docker_bin = [module.get_bin_path('docker')] - - docker_facts = {} - - for item in DOCKER_SUBCOMMAND_LOOKUP: - docker_facts[item[0]] = [] - docker_facts[item[0] + '_filtered'] = [] - - if docker_bin[0]: - - docker_facts[item[0]] = [] - - # Run each Docker command - for item in DOCKER_SUBCOMMAND_LOOKUP: - rc, out, err = run_docker_command( - module, - docker_bin, - sub_command=item[1], - opts=item[2]) - - # For everything but containers, return just the UIDs - if item[0] != 'containers': - docker_facts[item[0]] = out - elif item[0] == 'containers': - - # For containers, use a custom format to get name, id, - # and status - for line in out: - container_name, container_id, container_status = \ - line.split('##') - container_status = container_status.split()[0] - docker_facts[item[0]].append({ - 'name': container_name, - 'id': container_id, - 'status': container_status - }) - - # Get filtered facts - rc, out, err = run_docker_command( - module, - docker_bin, - sub_command=item[1], - opts=item[2], - filters=module.params[item[0].rstrip('s') + '_filter'] - ) - - if item[0] != 'containers': - docker_facts[item[0] + '_filtered'] = out - elif item[0] == 'containers': - - for line in out: - container_name, container_id, container_status = \ - line.split('##') - container_status = container_status.split()[0] - docker_facts[item[0] + '_filtered'].append({ - 'name': container_name, - 'id': container_id, - 'status': container_status - }) - - results = dict( - ansible_facts=dict( - docker=docker_facts - ) - ) - - module.exit_json(**results) - - -if __name__ == '__main__': - main() diff --git a/playbooks/containerized-undercloud-docker.yaml b/playbooks/containerized-undercloud-docker.yaml deleted file mode 100644 index 5aad472..0000000 --- a/playbooks/containerized-undercloud-docker.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- -- hosts: undercloud - vars: - metadata: - name: Verify docker containers are up and ports are open - description: > - Ensure relevant docker containers are up and running, with ports - open to listen. - - We iterate through a list of container names and ports provided in - defaults, and ensure the system has those available. - groups: - - post-deployment - - pre-upgrade - open_ports: - - 111 - - 873 - - 3000 - - 3306 - - 4369 - - 5000 - - 5050 - - 5672 - - 6000 - - 6001 - - 6002 - - 6379 - - 6385 - - 8000 - - 8004 - - 8080 - - 8088 - - 8774 - - 8775 - - 8778 - - 8787 - - 8888 - - 8989 - - 9000 - - 9292 - - 9696 - - 11211 - - 15672 - - 25672 - - 35357 - - 39422 - - port: 22 - search_regex: OpenSSH - running_containers: - - glance_api - - heat_api - - heat_api_cfn - - heat_api_cron - - heat_engine - - ironic_api - - ironic_conductor - - ironic_inspector - - ironic_inspector_dnsmasq - - ironic_neutron_agent - - ironic_pxe_http - - ironic_pxe_tftp - - iscsid - - keystone - - keystone_cron - - logrotate_crond - - memcached - - mistral_api - - mistral_engine - - mistral_event_engine - - mistral_executor - - mysql - - neutron_api - - neutron_dhcp - - neutron_l3_agent - - neutron_ovs_agent - - nova_api - - nova_api_cron - - nova_compute - - nova_conductor - - nova_metadata - - nova_placement - - nova_scheduler - - rabbitmq - - swift_account_auditor - - swift_account_reaper - - swift_account_replicator - - swift_account_server - - swift_container_auditor - - swift_container_replicator - - swift_container_server - - swift_container_updater - - swift_object_auditor - - swift_object_expirer - - swift_object_replicator - - swift_object_server - - swift_object_updater - - swift_proxy - - swift_rsync - - tripleo_ui - - zaqar - - zaqar_websocket - roles: - - containerized_undercloud_docker diff --git a/roles/containerized_undercloud_docker/defaults/main.yml b/roles/containerized_undercloud_docker/defaults/main.yml deleted file mode 100644 index 906d4ac..0000000 --- a/roles/containerized_undercloud_docker/defaults/main.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- -listening_ip: "{{ ctlplane_ip }}" -open_ports: - - 111 - - 873 - - 3000 - - 3306 - - 4369 - - 5000 - - 5050 - - 5672 - - 6000 - - 6001 - - 6002 - - 6379 - - 6385 - - 8000 - - 8004 - - 8080 - - 8088 - - 8774 - - 8775 - - 8778 - - 8787 - - 8888 - - 8989 - - 9000 - - 9292 - - 9696 - - 11211 - - 15672 - - 25672 - - 35357 - - 39422 - - port: 22 - search_regex: OpenSSH -running_containers: - - glance_api - - heat_api - - heat_api_cfn - - heat_api_cron - - heat_engine - - ironic_api - - ironic_conductor - - ironic_inspector - - ironic_inspector_dnsmasq - - ironic_neutron_agent - - ironic_pxe_http - - ironic_pxe_tftp - - iscsid - - keystone - - keystone_cron - - logrotate_crond - - memcached - - mistral_api - - mistral_engine - - mistral_event_engine - - mistral_executor - - mysql - - neutron_api - - neutron_dhcp - - neutron_l3_agent - - neutron_ovs_agent - - nova_api - - nova_api_cron - - nova_compute - - nova_conductor - - nova_metadata - - nova_placement - - nova_scheduler - - rabbitmq - - swift_account_auditor - - swift_account_reaper - - swift_account_replicator - - swift_account_server - - swift_container_auditor - - swift_container_replicator - - swift_container_server - - swift_container_updater - - swift_object_auditor - - swift_object_expirer - - swift_object_replicator - - swift_object_server - - swift_object_updater - - swift_proxy - - swift_rsync - - tripleo_ui - - zaqar - - zaqar_websocket diff --git a/roles/containerized_undercloud_docker/tasks/main.yml b/roles/containerized_undercloud_docker/tasks/main.yml deleted file mode 100644 index 8d3f24f..0000000 --- a/roles/containerized_undercloud_docker/tasks/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- name: gather docker facts - docker_facts: - container_filter: status=running - become: true - -- name: compare running containers to list - set_fact: - container_difference: "{{ running_containers | difference(docker.containers_filtered | map(attribute='name') | list) }}" - -- block: - - name: check appropriate running containers against list - if FAILED, check next task - assert: - that: "{{ container_difference | length == 0 }}" - rescue: - - name: following containers found to be NOT running - debug: - var: container_difference - -- name: check appropriate ports are listening - wait_for: - host: "{{ listening_ip }}" - port: "{{ item.port | default(item) }}" - search_regex: "{{ item.search_regex | default(omit) }}" - state: started # Port should be open - delay: 0 # No wait before first check (sec) - timeout: 3 # Stop checking after timeout (sec) - ignore_errors: true - loop: "{{ open_ports }}" - when: ctlplane_ip is defined diff --git a/roles/containerized_undercloud_docker/vars/main.yml b/roles/containerized_undercloud_docker/vars/main.yml deleted file mode 100644 index 4fb877c..0000000 --- a/roles/containerized_undercloud_docker/vars/main.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -metadata: - name: Verify docker containers are up and ports are open - description: > - Ensure relevant docker containers are up and running, with ports - open to listen. - - We iterate through a list of container names and ports provided in - defaults, and ensure the system has those available. - groups: - - post-deployment - - pre-upgrade