diff options
Diffstat (limited to 'roles')
58 files changed, 492 insertions, 412 deletions
diff --git a/roles/docker/handlers/main.yml b/roles/docker/handlers/main.yml index 591367467..866ed0452 100644 --- a/roles/docker/handlers/main.yml +++ b/roles/docker/handlers/main.yml @@ -4,6 +4,7 @@ systemd: name: "{{ openshift.docker.service_name }}" state: restarted + daemon_reload: yes register: r_docker_restart_docker_result until: not r_docker_restart_docker_result | failed retries: 3 diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index dae17c3ce..f73f90686 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -10,14 +10,6 @@ l_use_crio: "{{ openshift_use_crio | default(False) }}" l_use_crio_only: "{{ openshift_use_crio_only | default(False) }}" -- when: - - openshift_deployment_type == 'openshift-enterprise' - assert: - that: - - "openshift_image_tag is defined" - msg: > - openshift_image_tag is a required inventory variable when installing openshift-enterprise - - name: Use Package Docker if Requested include: package_docker.yml when: diff --git a/roles/docker/tasks/package_docker.yml b/roles/docker/tasks/package_docker.yml index eab5c3bb1..dbe0b0d28 100644 --- a/roles/docker/tasks/package_docker.yml +++ b/roles/docker/tasks/package_docker.yml @@ -48,7 +48,9 @@ template: dest: "{{ docker_systemd_dir }}/custom.conf" src: custom.conf.j2 - when: not os_firewall_use_firewalld | default(False) | bool + notify: + - restart docker + when: not (os_firewall_use_firewalld | default(False)) | bool - name: Add enterprise registry, if necessary set_fact: diff --git a/roles/docker/tasks/systemcontainer_crio.yml b/roles/docker/tasks/systemcontainer_crio.yml index 386369d26..fdc6cd24a 100644 --- a/roles/docker/tasks/systemcontainer_crio.yml +++ b/roles/docker/tasks/systemcontainer_crio.yml @@ -14,6 +14,22 @@ l_additional_crio_registries: "{{ '\"{}\"'.format('\", \"'.join(l_crio_registries)) }}" when: l2_docker_additional_registries +- set_fact: + l_openshift_image_tag: "{{ openshift_image_tag | string }}" + when: openshift_image_tag is defined + +- set_fact: + l_openshift_image_tag: "latest" + when: + - openshift_image_tag is not defined + - openshift_release == "latest" + +- set_fact: + l_openshift_image_tag: "{{ openshift_release | string }}" + when: + - openshift_image_tag is not defined + - openshift_release != "latest" + - name: Ensure container-selinux is installed package: name: container-selinux @@ -106,10 +122,9 @@ - name: Set CRI-O image tag set_fact: - l_crio_image_tag: "{{ openshift_image_tag }}" + l_crio_image_tag: "{{ l_openshift_image_tag }}" when: - openshift_deployment_type == 'openshift-enterprise' - - openshift_image_tag is defined - name: Use RHEL based image when distribution is Red Hat set_fact: @@ -147,7 +162,7 @@ image: "{{ l_crio_image }}" state: latest -- name: Remove CRI-o default configuration files +- name: Remove CRI-O default configuration files file: path: "{{ item }}" state: absent diff --git a/roles/docker/tasks/systemcontainer_docker.yml b/roles/docker/tasks/systemcontainer_docker.yml index 5b1605b58..15c6a55db 100644 --- a/roles/docker/tasks/systemcontainer_docker.yml +++ b/roles/docker/tasks/systemcontainer_docker.yml @@ -1,5 +1,21 @@ --- +- set_fact: + l_openshift_image_tag: "{{ openshift_image_tag | string }}" + when: openshift_image_tag is defined + +- set_fact: + l_openshift_image_tag: "latest" + when: + - openshift_image_tag is not defined + - openshift_release == "latest" + +- set_fact: + l_openshift_image_tag: "{{ openshift_release | string }}" + when: + - openshift_image_tag is not defined + - openshift_release != "latest" + # If docker_options are provided we should fail. We should not install docker and ignore # the users configuration. NOTE: docker_options == inventory:openshift_docker_options - name: Fail quickly if openshift_docker_options are set @@ -94,10 +110,9 @@ - name: Set container engine image tag set_fact: - l_docker_image_tag: "{{ openshift_image_tag }}" + l_docker_image_tag: "{{ l_openshift_image_tag }}" when: - openshift_deployment_type == 'openshift-enterprise' - - openshift_image_tag is defined - name: Use Red Hat Registry for image when distribution is Red Hat set_fact: diff --git a/roles/docker/templates/crio.conf.j2 b/roles/docker/templates/crio.conf.j2 index b4ee84fd0..b715c2ffa 100644 --- a/roles/docker/templates/crio.conf.j2 +++ b/roles/docker/templates/crio.conf.j2 @@ -13,12 +13,12 @@ runroot = "/var/run/containers/storage" # storage_driver select which storage driver is used to manage storage # of images and containers. -storage_driver = "overlay2" +storage_driver = "overlay" # storage_option is used to pass an option to the storage driver. storage_option = [ {% if ansible_distribution in ['RedHat', 'CentOS'] %} - "overlay2.override_kernel_check=1" + "overlay.override_kernel_check=1" {% endif %} ] @@ -35,6 +35,10 @@ stream_address = "" # stream_port is the port on which the stream server will listen stream_port = "10010" +# file_locking is whether file-based locking will be used instead of +# in-memory locking +file_locking = true + # The "crio.runtime" table contains settings pertaining to the OCI # runtime used and options for how to set up and manage the OCI runtime. [crio.runtime] @@ -67,6 +71,9 @@ runtime_untrusted_workload = "" # container runtime for all containers. default_workload_trust = "trusted" +# no_pivot instructs the runtime to not use pivot_root, but instead use MS_MOVE +no_pivot = false + # conmon is the path to conmon binary, used for managing the runtime. conmon = "/usr/libexec/crio/conmon" @@ -93,6 +100,16 @@ apparmor_profile = "crio-default" # for the runtime. cgroup_manager = "systemd" +# hooks_dir_path is the oci hooks directory for automatically executed hooks +hooks_dir_path = "/usr/share/containers/oci/hooks.d" + +# pids_limit is the number of processes allowed in a container +pids_limit = 1024 + +# log_size_max is the max limit for the container log size in bytes. +# Negative values indicate that no limit is imposed. +log_size_max = -1 + # The "crio.image" table contains settings pertaining to the # management of OCI images. [crio.image] @@ -115,6 +132,10 @@ pause_command = "/pause" # unspecified so that the default system-wide policy will be used. signature_policy = "" +# image_volumes controls how image volumes are handled. +# The valid values are mkdir and ignore. +image_volumes = "mkdir" + # insecure_registries is used to skip TLS verification when pulling images. insecure_registries = [ {{ l_insecure_crio_registries|default("") }} @@ -125,6 +146,7 @@ insecure_registries = [ registries = [ {{ l_additional_crio_registries|default("") }} ] + # The "crio.network" table contains settings pertaining to the # management of CNI plugins. [crio.network] diff --git a/roles/docker/templates/custom.conf.j2 b/roles/docker/templates/custom.conf.j2 index 9b47cb6ab..713412473 100644 --- a/roles/docker/templates/custom.conf.j2 +++ b/roles/docker/templates/custom.conf.j2 @@ -3,3 +3,9 @@ [Unit] Wants=iptables.service After=iptables.service + +# The following line is a work-around to ensure docker is restarted whenever +# iptables is restarted. This ensures the proper iptables rules will be in +# place for docker. +# Note: This will also cause docker to be stopped if iptables is stopped. +PartOf=iptables.service diff --git a/roles/flannel/handlers/main.yml b/roles/flannel/handlers/main.yml index 02f5a5f64..889069485 100644 --- a/roles/flannel/handlers/main.yml +++ b/roles/flannel/handlers/main.yml @@ -12,3 +12,12 @@ until: not l_docker_restart_docker_in_flannel_result | failed retries: 3 delay: 30 + +- name: restart node + systemd: + name: "{{ openshift.common.service_type }}-node" + state: restarted + register: l_restart_node_result + until: not l_restart_node_result | failed + retries: 3 + delay: 30 diff --git a/roles/installer_checkpoint/callback_plugins/installer_checkpoint.py b/roles/installer_checkpoint/callback_plugins/installer_checkpoint.py index 033240e62..ac369b882 100644 --- a/roles/installer_checkpoint/callback_plugins/installer_checkpoint.py +++ b/roles/installer_checkpoint/callback_plugins/installer_checkpoint.py @@ -81,6 +81,7 @@ class CallbackModule(CallbackBase): 'installer_phase_metrics', 'installer_phase_logging', 'installer_phase_servicecatalog', + 'installer_phase_management', ] # Define the attributes of the installer phases @@ -133,6 +134,10 @@ class CallbackModule(CallbackBase): 'title': 'Service Catalog Install', 'playbook': 'playbooks/byo/openshift-cluster/service-catalog.yml' }, + 'installer_phase_management': { + 'title': 'Management Install', + 'playbook': 'playbooks/common/openshift-cluster/openshift_management.yml' + }, } # Find the longest phase title diff --git a/roles/openshift_cfme/tasks/storage/create_nfs_pvs.yml b/roles/openshift_cfme/tasks/storage/create_nfs_pvs.yml deleted file mode 100644 index d5252464e..000000000 --- a/roles/openshift_cfme/tasks/storage/create_nfs_pvs.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -# Create the required PVs for the App and the DB -- name: Note the App PV Size from Template Parameters - set_fact: - openshift_cfme_app_pv_size: "{{ openshift_cfme_template_parameters.APPLICATION_VOLUME_CAPACITY }}" - when: - - openshift_cfme_template_parameters.APPLICATION_VOLUME_CAPACITY is defined - -- name: Note the App PV Size from defaults - set_fact: - openshift_cfme_app_pv_size: "{{ __openshift_cfme_app_pv_size }}" - when: - - openshift_cfme_template_parameters.APPLICATION_VOLUME_CAPACITY is not defined - -- when: openshift_cfme_app_template in ['miq-template', 'cfme-template'] - block: - - name: Note the DB PV Size from Template Parameters - set_fact: - openshift_cfme_db_pv_size: "{{ openshift_cfme_template_parameters.DATABASE_VOLUME_CAPACITY }}" - when: - - openshift_cfme_template_parameters.DATABASE_VOLUME_CAPACITY is defined - - - name: Note the DB PV Size from defaults - set_fact: - openshift_cfme_db_pv_size: "{{ __openshift_cfme_db_pv_size }}" - when: - - openshift_cfme_template_parameters.DATABASE_VOLUME_CAPACITY is not defined - -- name: Check if the CFME App PV has been created - oc_obj: - namespace: "{{ openshift_cfme_project }}" - state: list - kind: pv - name: "{{ openshift_cfme_flavor_short }}-app" - register: miq_app_pv_check - -- name: Check if the CFME DB PV has been created - oc_obj: - namespace: "{{ openshift_cfme_project }}" - state: list - kind: pv - name: "{{ openshift_cfme_flavor_short }}-db" - register: miq_db_pv_check - when: - - openshift_cfme_app_template in ['miq-template', 'cfme-template'] - -- name: Ensure the CFME App PV is created - oc_process: - namespace: "{{ openshift_cfme_project }}" - template_name: "{{ openshift_cfme_flavor }}-app-pv" - create: True - params: - PV_SIZE: "{{ openshift_cfme_app_pv_size }}" - BASE_PATH: "{{ openshift_cfme_storage_nfs_base_dir }}" - NFS_HOST: "{{ openshift_cfme_nfs_server }}" - when: miq_app_pv_check.results.results == [{}] - -- name: Ensure the CFME DB PV is created - oc_process: - namespace: "{{ openshift_cfme_project }}" - template_name: "{{ openshift_cfme_flavor }}-db-pv" - create: True - params: - PV_SIZE: "{{ openshift_cfme_db_pv_size }}" - BASE_PATH: "{{ openshift_cfme_storage_nfs_base_dir }}" - NFS_HOST: "{{ openshift_cfme_nfs_server }}" - when: - - openshift_cfme_app_template in ['miq-template', 'cfme-template'] - - miq_db_pv_check.results.results == [{}] diff --git a/roles/openshift_cfme/tasks/storage/nfs.yml b/roles/openshift_cfme/tasks/storage/nfs.yml deleted file mode 100644 index c17544480..000000000 --- a/roles/openshift_cfme/tasks/storage/nfs.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- -# Tasks to statically provision NFS volumes -# Include if not using dynamic volume provisioning - -- name: Ensure we save the local NFS server if one is provided - set_fact: - openshift_cfme_nfs_server: "{{ openshift_cfme_storage_nfs_local_hostname }}" - when: - - openshift_cfme_storage_nfs_local_hostname is defined - - openshift_cfme_storage_nfs_local_hostname != False - - openshift_cfme_storage_class == "nfs" - -- name: Ensure we save the local NFS server - set_fact: - openshift_cfme_nfs_server: "{{ groups['oo_nfs_to_config'].0 }}" - when: - - openshift_cfme_nfs_server is not defined - - openshift_cfme_storage_class == "nfs" - -- name: Ensure we save the external NFS server - set_fact: - openshift_cfme_nfs_server: "{{ openshift_cfme_storage_nfs_external_hostname }}" - when: - - openshift_cfme_storage_class == "nfs_external" - -- name: Failed NFS server detection - assert: - that: - - openshift_cfme_nfs_server is defined - msg: | - "Unable to detect an NFS server. The 'nfs_external' - openshift_cfme_storage_class option requires that you set - openshift_cfme_storage_nfs_external_hostname. NFS hosts detected - for local nfs services: {{ groups['oo_nfs_to_config'] | join(', ') }}" - -- name: Setting up NFS storage - block: - - name: Include the NFS Setup role tasks - include_role: - role: openshift_nfs - tasks_from: setup - vars: - l_nfs_base_dir: "{{ openshift_cfme_storage_nfs_base_dir }}" - - - name: Create the App export - include_role: - role: openshift_nfs - tasks_from: create_export - vars: - l_nfs_base_dir: "{{ openshift_cfme_storage_nfs_base_dir }}" - l_nfs_export_config: "{{ openshift_cfme_flavor_short }}" - l_nfs_export_name: "{{ openshift_cfme_flavor_short }}-app" - l_nfs_options: "*(rw,no_root_squash,no_wdelay)" - - - name: Create the DB export - include_role: - role: openshift_nfs - tasks_from: create_export - vars: - l_nfs_base_dir: "{{ openshift_cfme_storage_nfs_base_dir }}" - l_nfs_export_config: "{{ openshift_cfme_flavor_short }}" - l_nfs_export_name: "{{ openshift_cfme_flavor_short }}-db" - l_nfs_options: "*(rw,no_root_squash,no_wdelay)" - when: - - openshift_cfme_app_template in ['miq-template', 'cfme-template'] - - delegate_to: "{{ openshift_cfme_nfs_server }}" diff --git a/roles/openshift_cfme/templates/openshift_cfme-miq-template-ext-db.exports.j2 b/roles/openshift_cfme/templates/openshift_cfme-miq-template-ext-db.exports.j2 deleted file mode 100644 index f43a93ba0..000000000 --- a/roles/openshift_cfme/templates/openshift_cfme-miq-template-ext-db.exports.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ openshift_cfme_storage_nfs_base_dir }}/{{ openshift_cfme_flavor_short }}-app *(rw,no_root_squash,no_wdelay) diff --git a/roles/openshift_cfme/templates/openshift_cfme-miq-template.exports.j2 b/roles/openshift_cfme/templates/openshift_cfme-miq-template.exports.j2 deleted file mode 100644 index 4a4d85a23..000000000 --- a/roles/openshift_cfme/templates/openshift_cfme-miq-template.exports.j2 +++ /dev/null @@ -1,2 +0,0 @@ -{{ openshift_cfme_storage_nfs_base_dir }}/{{ openshift_cfme_flavor_short }}-app *(rw,no_root_squash,no_wdelay) -{{ openshift_cfme_storage_nfs_base_dir }}/{{ openshift_cfme_flavor_short }}-db *(rw,no_root_squash,no_wdelay) diff --git a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py index 63ccadcd1..7c8ac78fe 100644 --- a/roles/openshift_health_checker/openshift_checks/docker_image_availability.py +++ b/roles/openshift_health_checker/openshift_checks/docker_image_availability.py @@ -1,5 +1,6 @@ """Check that required Docker images are available.""" +from pipes import quote from ansible.module_utils import six from openshift_checks import OpenShiftCheck from openshift_checks.mixins import DockerHostMixin @@ -33,10 +34,39 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): # we use python-docker-py to check local docker for images, and skopeo # to look for images available remotely without waiting to pull them. dependencies = ["python-docker-py", "skopeo"] - skopeo_img_check_command = "timeout 10 skopeo inspect --tls-verify=false docker://{registry}/{image}" + # command for checking if remote registries have an image, without docker pull + skopeo_command = "timeout 10 skopeo inspect --tls-verify={tls} {creds} docker://{registry}/{image}" + skopeo_example_command = "skopeo inspect [--tls-verify=false] [--creds=<user>:<pass>] docker://<registry>/<image>" def __init__(self, *args, **kwargs): super(DockerImageAvailability, self).__init__(*args, **kwargs) + + self.registries = dict( + # set of registries that need to be checked insecurely (note: not accounting for CIDR entries) + insecure=set(self.ensure_list("openshift_docker_insecure_registries")), + # set of registries that should never be queried even if given in the image + blocked=set(self.ensure_list("openshift_docker_blocked_registries")), + ) + + # ordered list of registries (according to inventory vars) that docker will try for unscoped images + regs = self.ensure_list("openshift_docker_additional_registries") + # currently one of these registries is added whether the user wants it or not. + deployment_type = self.get_var("openshift_deployment_type") + if deployment_type == "origin" and "docker.io" not in regs: + regs.append("docker.io") + elif deployment_type == 'openshift-enterprise' and "registry.access.redhat.com" not in regs: + regs.append("registry.access.redhat.com") + self.registries["configured"] = regs + + # for the oreg_url registry there may be credentials specified + components = self.get_var("oreg_url", default="").split('/') + self.registries["oreg"] = "" if len(components) < 3 else components[0] + self.skopeo_command_creds = "" + oreg_auth_user = self.get_var('oreg_auth_user', default='') + oreg_auth_password = self.get_var('oreg_auth_password', default='') + if oreg_auth_user != '' and oreg_auth_password != '': + self.skopeo_command_creds = "--creds={}:{}".format(quote(oreg_auth_user), quote(oreg_auth_password)) + # record whether we could reach a registry or not (and remember results) self.reachable_registries = {} @@ -62,26 +92,25 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): if not missing_images: return {} - registries = self.known_docker_registries() - if not registries: - return {"failed": True, "msg": "Unable to retrieve any docker registries."} - - available_images = self.available_images(missing_images, registries) + available_images = self.available_images(missing_images) unavailable_images = set(missing_images) - set(available_images) if unavailable_images: - registries = [ - reg if self.reachable_registries.get(reg, True) else reg + " (unreachable)" - for reg in registries - ] + unreachable = [reg for reg, reachable in self.reachable_registries.items() if not reachable] + unreachable_msg = "Failed connecting to: {}\n".format(", ".join(unreachable)) + blocked_msg = "Blocked registries: {}\n".format(", ".join(self.registries["blocked"])) msg = ( - "One or more required Docker images are not available:\n {}\n" - "Configured registries: {}\n" - "Checked by: {}" + "One or more required container images are not available:\n {missing}\n" + "Checked with: {cmd}\n" + "Default registries searched: {registries}\n" + "{blocked}" + "{unreachable}" ).format( - ",\n ".join(sorted(unavailable_images)), - ", ".join(registries), - self.skopeo_img_check_command + missing=",\n ".join(sorted(unavailable_images)), + cmd=self.skopeo_example_command, + registries=", ".join(self.registries["configured"]), + blocked=blocked_msg if self.registries["blocked"] else "", + unreachable=unreachable_msg if unreachable else "", ) return dict(failed=True, msg=msg) @@ -138,11 +167,10 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): def local_images(self, images): """Filter a list of images and return those available locally.""" - registries = self.known_docker_registries() found_images = [] for image in images: # docker could have the image name as-is or prefixed with any registry - imglist = [image] + [reg + "/" + image for reg in registries] + imglist = [image] + [reg + "/" + image for reg in self.registries["configured"]] if self.is_image_local(imglist): found_images.append(image) return found_images @@ -152,37 +180,27 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): result = self.execute_module("docker_image_facts", {"name": image}) return bool(result.get("images")) and not result.get("failed") - def known_docker_registries(self): - """Build a list of docker registries available according to inventory vars.""" - regs = self.get_var("openshift_docker_additional_registries", default=[]) + def ensure_list(self, registry_param): + """Return the task var as a list.""" # https://bugzilla.redhat.com/show_bug.cgi?id=1497274 - # if the result was a string type, place it into a list. We must do this + # If the result was a string type, place it into a list. We must do this # as using list() on a string will split the string into its characters. - if isinstance(regs, six.string_types): - regs = [regs] - else: - # Otherwise cast to a list as was done previously - regs = list(regs) + # Otherwise cast to a list as was done previously. + registry = self.get_var(registry_param, default=[]) + if not isinstance(registry, six.string_types): + return list(registry) + return self.normalize(registry) - deployment_type = self.get_var("openshift_deployment_type") - if deployment_type == "origin" and "docker.io" not in regs: - regs.append("docker.io") - elif deployment_type == 'openshift-enterprise' and "registry.access.redhat.com" not in regs: - regs.append("registry.access.redhat.com") - - return regs - - def available_images(self, images, default_registries): + def available_images(self, images): """Search remotely for images. Returns: list of images found.""" return [ image for image in images - if self.is_available_skopeo_image(image, default_registries) + if self.is_available_skopeo_image(image) ] - def is_available_skopeo_image(self, image, default_registries): + def is_available_skopeo_image(self, image): """Use Skopeo to determine if required image exists in known registry(s).""" - registries = default_registries - + registries = self.registries["configured"] # If image already includes a registry, only use that. # NOTE: This logic would incorrectly identify images that do not use a namespace, e.g. # registry.access.redhat.com/rhel7 as if the registry were a namespace. @@ -193,13 +211,18 @@ class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): registries = [registry] for registry in registries: + if registry in self.registries["blocked"]: + continue # blocked will never be consulted if registry not in self.reachable_registries: self.reachable_registries[registry] = self.connect_to_registry(registry) if not self.reachable_registries[registry]: - continue + continue # do not keep trying unreachable registries + + args = dict(registry=registry, image=image) + args["tls"] = "false" if registry in self.registries["insecure"] else "true" + args["creds"] = self.skopeo_command_creds if registry == self.registries["oreg"] else "" - args = {"_raw_params": self.skopeo_img_check_command.format(registry=registry, image=image)} - result = self.execute_module_with_retries("command", args) + result = self.execute_module_with_retries("command", {"_raw_params": self.skopeo_command.format(**args)}) if result.get("rc", 0) == 0 and not result.get("failed"): return True if result.get("rc") == 124: # RC 124 == timed out; mark unreachable diff --git a/roles/openshift_health_checker/test/action_plugin_test.py b/roles/openshift_health_checker/test/action_plugin_test.py index f14887303..40ad27d5d 100644 --- a/roles/openshift_health_checker/test/action_plugin_test.py +++ b/roles/openshift_health_checker/test/action_plugin_test.py @@ -94,6 +94,7 @@ def skipped(result): {}, ]) def test_action_plugin_missing_openshift_facts(plugin, task_vars, monkeypatch): + monkeypatch.setattr(plugin, 'load_known_checks', lambda *_: {}) monkeypatch.setattr('openshift_health_check.resolve_checks', lambda *args: ['fake_check']) result = plugin.run(tmp=None, task_vars=task_vars) diff --git a/roles/openshift_health_checker/test/docker_image_availability_test.py b/roles/openshift_health_checker/test/docker_image_availability_test.py index 43dcf0c9a..dec99e5db 100644 --- a/roles/openshift_health_checker/test/docker_image_availability_test.py +++ b/roles/openshift_health_checker/test/docker_image_availability_test.py @@ -98,40 +98,7 @@ def test_all_images_unavailable(task_vars): actual = check.run() assert actual['failed'] - assert "required Docker images are not available" in actual['msg'] - - -def test_no_known_registries(): - def execute_module(module_name=None, *_): - if module_name == "command": - return { - 'failed': True, - } - - return { - 'changed': False, - } - - def mock_known_docker_registries(): - return [] - - dia = DockerImageAvailability(execute_module, task_vars=dict( - openshift=dict( - common=dict( - service_type='origin', - is_containerized=False, - is_atomic=False, - ) - ), - openshift_docker_additional_registries=["docker.io"], - openshift_deployment_type="openshift-enterprise", - openshift_image_tag='latest', - group_names=['oo_nodes_to_config', 'oo_masters_to_config'], - )) - dia.known_docker_registries = mock_known_docker_registries - actual = dia.run() - assert actual['failed'] - assert "Unable to retrieve any docker registries." in actual['msg'] + assert "required container images are not available" in actual['msg'] @pytest.mark.parametrize("message,extra_words", [ @@ -172,13 +139,13 @@ def test_skopeo_update_failure(task_vars, message, extra_words): "spam/eggs:v1", ["test.reg"], True, True, False, - {"test.reg": False}, + {"test.reg": False, "docker.io": False}, ), ( "spam/eggs:v1", ["test.reg"], False, True, False, - {"test.reg": True}, + {"test.reg": True, "docker.io": True}, ), ( "eggs.reg/spam/eggs:v1", ["test.reg"], @@ -195,17 +162,19 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo elif module_name == "command": return dict(msg="msg", failed=skopeo_failed) - check = DockerImageAvailability(execute_module, task_vars()) + tv = task_vars() + tv.update({"openshift_docker_additional_registries": registries}) + check = DockerImageAvailability(execute_module, tv) check._module_retry_interval = 0 - available = check.is_available_skopeo_image(image, registries) + available = check.is_available_skopeo_image(image) assert available == expect_success assert expect_registries_reached == check.reachable_registries @pytest.mark.parametrize("deployment_type, is_containerized, groups, oreg_url, expected", [ ( # standard set of stuff required on nodes - "origin", False, ['oo_nodes_to_config'], None, + "origin", False, ['oo_nodes_to_config'], "", set([ 'openshift/origin-pod:vtest', 'openshift/origin-deployer:vtest', @@ -225,7 +194,7 @@ def test_registry_availability(image, registries, connection_test_failed, skopeo ]) ), ( - "origin", True, ['oo_nodes_to_config', 'oo_masters_to_config', 'oo_etcd_to_config'], None, + "origin", True, ['oo_nodes_to_config', 'oo_masters_to_config', 'oo_etcd_to_config'], "", set([ # images running on top of openshift 'openshift/origin-pod:vtest', diff --git a/roles/openshift_hosted/templates/registry_config.j2 b/roles/openshift_hosted/templates/registry_config.j2 index eae8b328e..222b63b8a 100644 --- a/roles/openshift_hosted/templates/registry_config.j2 +++ b/roles/openshift_hosted/templates/registry_config.j2 @@ -53,7 +53,7 @@ storage: {% if openshift_hosted_registry_storage_swift_domain is defined %} domain: {{ openshift_hosted_registry_storage_swift_domain }} {% endif -%} -{% if openshift_hosted_registry_storage_swift_domainid %} +{% if openshift_hosted_registry_storage_swift_domainid is defined %} domainid: {{ openshift_hosted_registry_storage_swift_domainid }} {% endif -%} {% elif openshift_hosted_registry_storage_provider | default('') == 'gcs' %} @@ -63,7 +63,7 @@ storage: keyfile: /etc/registry/gcs.json {% endif -%} {% if openshift_hosted_registry_storage_gcs_rootdirectory is defined %} - rootdirectory: {{ openshift_hosted_registry_storage_gcs_rootdirectory }} + rootdirectory: {{ openshift_hosted_registry_storage_gcs_rootdirectory | default('/registry') }} {% endif -%} {% endif -%} auth: diff --git a/roles/openshift_logging_fluentd/templates/fluentd.j2 b/roles/openshift_logging_fluentd/templates/fluentd.j2 index b5f27b60d..f286b0656 100644 --- a/roles/openshift_logging_fluentd/templates/fluentd.j2 +++ b/roles/openshift_logging_fluentd/templates/fluentd.j2 @@ -66,7 +66,9 @@ spec: readOnly: true - name: filebufferstorage mountPath: /var/lib/fluentd -{% if openshift_logging_mux_client_mode is defined %} +{% if openshift_logging_mux_client_mode is defined and + ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or + (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %} - name: muxcerts mountPath: /etc/fluent/muxkeys readOnly: true @@ -114,7 +116,9 @@ spec: resource: limits.memory - name: "FILE_BUFFER_LIMIT" value: "{{ openshift_logging_fluentd_file_buffer_limit | default('1Gi') }}" -{% if openshift_logging_mux_client_mode is defined %} +{% if openshift_logging_mux_client_mode is defined and + ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or + (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %} - name: "MUX_CLIENT_MODE" value: "{{ openshift_logging_mux_client_mode }}" {% endif %} @@ -196,7 +200,9 @@ spec: - name: dockerdaemoncfg hostPath: path: /etc/docker -{% if openshift_logging_mux_client_mode is defined %} +{% if openshift_logging_mux_client_mode is defined and + ((openshift_logging_mux_allow_external is defined and openshift_logging_mux_allow_external | bool) or + (openshift_logging_use_mux is defined and openshift_logging_use_mux | bool)) %} - name: muxcerts secret: secretName: logging-mux diff --git a/roles/openshift_cfme/README.md b/roles/openshift_management/README.md index 26618ffb8..3a71d9211 100644 --- a/roles/openshift_cfme/README.md +++ b/roles/openshift_management/README.md @@ -38,6 +38,7 @@ deployment type (`openshift_deployment_type`): * [Cloud Provider](#cloud-provider) * [Preconfigured (Expert Configuration Only)](#preconfigured-expert-configuration-only) * [Customization](#customization) + * [Uninstall](#uninstall) * [Additional Information](#additional-information) # Introduction @@ -141,18 +142,18 @@ installer. | Variable | Required | Default | Description | |------------------------------------------------|:--------:|:------------------------------:|-------------------------------------| -| `openshift_cfme_project` | **No** | `openshift-cfme` | Namespace for the installation. | -| `openshift_cfme_project_description` | **No** | *CloudForms Management Engine* | Namespace/project description. | -| `openshift_cfme_install_cfme` | **No** | `false` | Boolean, set to `true` to install the application | +| `openshift_management_project` | **No** | `openshift-management` | Namespace for the installation. | +| `openshift_management_project_description` | **No** | *CloudForms Management Engine* | Namespace/project description. | +| `openshift_management_install_management` | **No** | `false` | Boolean, set to `true` to install the application | | **PRODUCT CHOICE** | | | | | -| `openshift_cfme_app_template` | **No** | `miq-template` | The project flavor to install. Choices: <ul><li>`miq-template`: ManageIQ using a podified database</li> <li> `miq-template-ext-db`: ManageIQ using an external database</li> <li>`cfme-template`: CloudForms using a podified database<sup>[1]</sup></li> <li> `cfme-template-ext-db`: CloudForms using an external database.<sup>[1]</sup></li></ul> | +| `openshift_management_app_template` | **No** | `miq-template` | The project flavor to install. Choices: <ul><li>`miq-template`: ManageIQ using a podified database</li> <li> `miq-template-ext-db`: ManageIQ using an external database</li> <li>`cfme-template`: CloudForms using a podified database<sup>[1]</sup></li> <li> `cfme-template-ext-db`: CloudForms using an external database.<sup>[1]</sup></li></ul> | | **STORAGE CLASSES** | | | | | -| `openshift_cfme_storage_class` | **No** | `nfs` | Storage type to use, choices: <ul><li>`nfs` - Best used for proof-of-concept installs. Will setup NFS on a cluster host (defaults to your first master in the inventory file) to back the required PVCs. The application requires a PVC and the database (which may be hosted externally) may require a second. PVC minimum required sizes are 5GiB for the MIQ application, and 15GiB for the PostgreSQL database (20GiB minimum available space on a volume/partition if used specifically for NFS purposes)</li> <li>`nfs_external` - You are using an external NFS server, such as a netapp appliance. See the [Configuration - Storage Classes](#storage-classes) section below for required information.</li> <li>`preconfigured` - This CFME role will do NOTHING to modify storage settings. This option assumes expert knowledge and that you have done everything required ahead of time.</li> <li>`cloudprovider` - You are using an OCP cloudprovider integration for your storage class. For this to work you must have already configured the required inventory parameters for your cloud provider. Ensure `openshift_cloudprovider_kind` is defined (aws or gce) and that the applicable cloudprovider parameters are provided. | -| `openshift_cfme_storage_nfs_external_hostname` | **No** | `false` | If you are using an *external NFS server*, such as a netapp appliance, then you must set the hostname here. Leave the value as `false` if you are not using external NFS. <br /> *Additionally*: **External NFS REQUIRES** that you create the NFS exports that will back the application PV and optionally the database PV. -| `openshift_cfme_storage_nfs_base_dir` | **No** | `/exports/` | If you are using **External NFS** then you may set the base path to the exports location here. <br />**Local NFS Note**: You *may* also change this value if you want to change the default path used for local NFS exports. | -| `openshift_cfme_storage_nfs_local_hostname` | **No** | `false` | If you do not have an `[nfs]` group in your inventory, or want to simply manually define the local NFS host in your cluster, set this parameter to the hostname of the preferred NFS server. The server must be a part of your OCP/Origin cluster. | +| `openshift_management_storage_class` | **No** | `nfs` | Storage type to use, choices: <ul><li>`nfs` - Best used for proof-of-concept installs. Will setup NFS on a cluster host (defaults to your first master in the inventory file) to back the required PVCs. The application requires a PVC and the database (which may be hosted externally) may require a second. PVC minimum required sizes are 5GiB for the MIQ application, and 15GiB for the PostgreSQL database (20GiB minimum available space on a volume/partition if used specifically for NFS purposes)</li> <li>`nfs_external` - You are using an external NFS server, such as a netapp appliance. See the [Configuration - Storage Classes](#storage-classes) section below for required information.</li> <li>`preconfigured` - This CFME role will do NOTHING to modify storage settings. This option assumes expert knowledge and that you have done everything required ahead of time.</li> <li>`cloudprovider` - You are using an OCP cloudprovider integration for your storage class. For this to work you must have already configured the required inventory parameters for your cloud provider. Ensure `openshift_cloudprovider_kind` is defined (aws or gce) and that the applicable cloudprovider parameters are provided. | +| `openshift_management_storage_nfs_external_hostname` | **No** | `false` | If you are using an *external NFS server*, such as a netapp appliance, then you must set the hostname here. Leave the value as `false` if you are not using external NFS. <br /> *Additionally*: **External NFS REQUIRES** that you create the NFS exports that will back the application PV and optionally the database PV. +| `openshift_management_storage_nfs_base_dir` | **No** | `/exports/` | If you are using **External NFS** then you may set the base path to the exports location here. <br />**Local NFS Note**: You *may* also change this value if you want to change the default path used for local NFS exports. | +| `openshift_management_storage_nfs_local_hostname` | **No** | `false` | If you do not have an `[nfs]` group in your inventory, or want to simply manually define the local NFS host in your cluster, set this parameter to the hostname of the preferred NFS server. The server must be a part of your OCP/Origin cluster. | | **CUSTOMIZATION OPTIONS** | | | | | -| `openshift_cfme_template_parameters` | **No** | `{}` | A dictionary of any parameters you want to override in the application/pv templates. +| `openshift_management_template_parameters` | **No** | `{}` | A dictionary of any parameters you want to override in the application/pv templates. * <sup>[1]</sup> The `cfme-template`s will be available and automatically detected once CFME 4.6 is released @@ -164,7 +165,7 @@ Below are some inventory snippets that can help you get started right away. If you want to install CFME/MIQ at the same time you install your -OCP/Origin cluster, ensure that `openshift_cfme_install_cfme` is set +OCP/Origin cluster, ensure that `openshift_management_install_management` is set to `true` in your inventory. Call the standard `playbooks/byo/config.yml` playbook to begin the cluster and CFME/MIQ installation. @@ -173,7 +174,7 @@ If you are installing CFME/MIQ on an *already provisioned cluster* then you can call the CFME/MIQ playbook directly: ``` -$ ansible-playbook -v -i <YOUR_INVENTORY> playbooks/byo/openshift-cfme/config.yml +$ ansible-playbook -v -i <YOUR_INVENTORY> playbooks/byo/openshift-management/config.yml ``` *Note: Use `miq-template` in the following examples for ManageIQ installs* @@ -187,7 +188,7 @@ created as pods in the container platform. ```ini [OSEv3:vars] -openshift_cfme_app_template=cfme-template +openshift_management_app_template=cfme-template ``` ## External NFS Storage @@ -196,37 +197,37 @@ This is as the previous example, except that instead of using local NFS services in the cluster it will use an external NFS server (such as a storage appliance). Note the two new parameters: -* `openshift_cfme_storage_class` - set to `nfs_external` -* `openshift_cfme_storage_nfs_external_hostname` - set to the hostname +* `openshift_management_storage_class` - set to `nfs_external` +* `openshift_management_storage_nfs_external_hostname` - set to the hostname of the NFS server ```ini [OSEv3:vars] -openshift_cfme_app_template=cfme-template -openshift_cfme_storage_class=nfs_external -openshift_cfme_storage_nfs_external_hostname=nfs.example.com +openshift_management_app_template=cfme-template +openshift_management_storage_class=nfs_external +openshift_management_storage_nfs_external_hostname=nfs.example.com ``` If the external NFS host exports directories under a different parent directory, such as `/exports/hosted/prod` then we would add an -additional parameter, `openshift_cfme_storage_nfs_base_dir`: +additional parameter, `openshift_management_storage_nfs_base_dir`: ```ini # ... -openshift_cfme_storage_nfs_base_dir=/exports/hosted/prod +openshift_management_storage_nfs_base_dir=/exports/hosted/prod ``` ## Override PV sizes This example will override the PV sizes. Note that we set the PV sizes -in the template parameters, `openshift_cfme_template_parameters`. This +in the template parameters, `openshift_management_template_parameters`. This ensures that the application/db will be able to make claims on created PVs without clobbering each other. ```ini [OSEv3:vars] -openshift_cfme_app_template=cfme-template -openshift_cfme_template_parameters={'APPLICATION_VOLUME_CAPACITY': '10Gi', 'DATABASE_VOLUME_CAPACITY': '25Gi'} +openshift_management_app_template=cfme-template +openshift_management_template_parameters={'APPLICATION_VOLUME_CAPACITY': '10Gi', 'DATABASE_VOLUME_CAPACITY': '25Gi'} ``` ## Override Memory Requirements @@ -238,8 +239,8 @@ performance or a complete failure to initialize the application. ```ini [OSEv3:vars] -openshift_cfme_app_template=cfme-template -openshift_cfme_template_parameters={'APPLICATION_MEM_REQ': '3000Mi', 'POSTGRESQL_MEM_REQ': '1Gi', 'ANSIBLE_MEM_REQ': '512Mi'} +openshift_management_app_template=cfme-template +openshift_management_template_parameters={'APPLICATION_MEM_REQ': '3000Mi', 'POSTGRESQL_MEM_REQ': '1Gi', 'ANSIBLE_MEM_REQ': '512Mi'} ``` Here we have instructed the installer to process the application @@ -253,18 +254,18 @@ displayed in the previous example. ## External PostgreSQL Database To use an external database you must change the -`openshift_cfme_app_template` parameter value to `miq-template-ext-db` +`openshift_management_app_template` parameter value to `miq-template-ext-db` or `cfme-template-ext-db`. Additionally, database connection information **must** be supplied in -the `openshift_cfme_template_parameters` customization parameter. See +the `openshift_management_template_parameters` customization parameter. See [Customization - Database - External](#external) for more information. ```ini [OSEv3:vars] -openshift_cfme_app_template=cfme-template-ext-db -openshift_cfme_template_parameters={'DATABASE_USER': 'root', 'DATABASE_PASSWORD': 'r1ck&M0r7y', 'DATABASE_IP': '10.10.10.10', 'DATABASE_PORT': '5432', 'DATABASE_NAME': 'cfme'} +openshift_management_app_template=cfme-template-ext-db +openshift_management_template_parameters={'DATABASE_USER': 'root', 'DATABASE_PASSWORD': 'r1ck&M0r7y', 'DATABASE_IP': '10.10.10.10', 'DATABASE_PORT': '5432', 'DATABASE_NAME': 'cfme'} ``` # Limitations @@ -294,7 +295,7 @@ it. There are two major decisions to make: Any `POSTGRES_*` or `DATABASE_*` template parameters in [miq-template.yaml](files/templates/manageiq/miq-template.yaml) or [cfme-template.yaml](files/templates/cloudforms/cfme-template.yaml) -may be customized through the `openshift_cfme_template_parameters` +may be customized through the `openshift_management_template_parameters` hash. ### External @@ -303,12 +304,12 @@ Any `POSTGRES_*` or `DATABASE_*` template parameters in [miq-template-ext-db.yaml](files/templates/manageiq/miq-template-ext-db.yaml) or [cfme-template-ext-db.yaml](files/templates/cloudforms/cfme-template-ext-db.yaml) -may be customized through the `openshift_cfme_template_parameters` +may be customized through the `openshift_management_template_parameters` hash. External PostgreSQL databases require you to provide database connection parameters. You must set the required connection keys in -the `openshift_cfme_template_parameters` parameter in your +the `openshift_management_template_parameters` parameter in your inventory. The following keys are required: * `DATABASE_USER` @@ -321,31 +322,31 @@ Your inventory would contain a line similar to this: ```ini [OSEv3:vars] -openshift_cfme_app_template=cfme-template-ext-db -openshift_cfme_template_parameters={'DATABASE_USER': 'root', 'DATABASE_PASSWORD': 'r1ck&M0r7y', 'DATABASE_IP': '10.10.10.10', 'DATABASE_PORT': '5432', 'DATABASE_NAME': 'cfme'} +openshift_management_app_template=cfme-template-ext-db +openshift_management_template_parameters={'DATABASE_USER': 'root', 'DATABASE_PASSWORD': 'r1ck&M0r7y', 'DATABASE_IP': '10.10.10.10', 'DATABASE_PORT': '5432', 'DATABASE_NAME': 'cfme'} ``` -**Note** the new value for the `openshift_cfme_app_template` +**Note** the new value for the `openshift_management_app_template` parameter, `cfme-template-ext-db` (ManageIQ installations would use `miq-template-ext-db` instead). At run time you may run into errors similar to this: ``` -TASK [openshift_cfme : Ensure the CFME App is created] *********************************** -task path: /home/tbielawa/rhat/os/openshift-ansible/roles/openshift_cfme/tasks/main.yml:74 +TASK [openshift_management : Ensure the CFME App is created] *********************************** +task path: /home/tbielawa/rhat/os/openshift-ansible/roles/openshift_management/tasks/main.yml:74 Tuesday 03 October 2017 15:30:44 -0400 (0:00:00.056) 0:00:12.278 ******* -{"cmd": "/usr/bin/oc create -f /tmp/postgresql-ZPEWQS -n openshift-cfme", "kind": "Endpoints", "results": {}, "returncode": 1, "stderr": "Error from server (BadRequest): error when creating \"/tmp/postgresql-ZPEWQS\": Endpoints in version \"v1\" cannot be handled as a Endpoints: [pos 218]: json: decNum: got first char 'f'\n", "stdout": ""} +{"cmd": "/usr/bin/oc create -f /tmp/postgresql-ZPEWQS -n openshift-management", "kind": "Endpoints", "results": {}, "returncode": 1, "stderr": "Error from server (BadRequest): error when creating \"/tmp/postgresql-ZPEWQS\": Endpoints in version \"v1\" cannot be handled as a Endpoints: [pos 218]: json: decNum: got first char 'f'\n", "stdout": ""} ``` Or like this: ``` -TASK [openshift_cfme : Ensure the CFME App is created] *********************************** -task path: /home/tbielawa/rhat/os/openshift-ansible/roles/openshift_cfme/tasks/main.yml:74 +TASK [openshift_management : Ensure the CFME App is created] *********************************** +task path: /home/tbielawa/rhat/os/openshift-ansible/roles/openshift_management/tasks/main.yml:74 Tuesday 03 October 2017 16:05:36 -0400 (0:00:00.052) 0:00:18.948 ******* fatal: [m01.example.com]: FAILED! => {"changed": true, "failed": true, "msg": -{"cmd": "/usr/bin/oc create -f /tmp/postgresql-igS5sx -n openshift-cfme", "kind": "Endpoints", "results": {}, "returncode": 1, "stderr": "The Endpoints \"postgresql\" is invalid: subsets[0].addresses[0].ip: Invalid value: \"doo\": must be a valid IP address, (e.g. 10.9.8.7)\n", "stdout": ""}, +{"cmd": "/usr/bin/oc create -f /tmp/postgresql-igS5sx -n openshift-management", "kind": "Endpoints", "results": {}, "returncode": 1, "stderr": "The Endpoints \"postgresql\" is invalid: subsets[0].addresses[0].ip: Invalid value: \"doo\": must be a valid IP address, (e.g. 10.9.8.7)\n", "stdout": ""}, ``` While intimidating at first, there are useful bits of information in @@ -380,8 +381,8 @@ choice. Customization is provided through the following role variables: -* `openshift_cfme_storage_nfs_base_dir` -* `openshift_cfme_storage_nfs_local_hostname` +* `openshift_management_storage_nfs_base_dir` +* `openshift_management_storage_nfs_local_hostname` ### NFS External @@ -393,19 +394,19 @@ for the required PVs. For external NFS you must have: Configuration is provided through the following role variables: -* `openshift_cfme_storage_nfs_external_hostname` -* `openshift_cfme_storage_nfs_base_dir` +* `openshift_management_storage_nfs_external_hostname` +* `openshift_management_storage_nfs_base_dir` -The `openshift_cfme_storage_nfs_external_hostname` parameter must be +The `openshift_management_storage_nfs_external_hostname` parameter must be set to the hostname or IP of your external NFS server. If `/exports` is not the parent directory to your exports then you must set the base directory via the -`openshift_cfme_storage_nfs_base_dir` parameter. +`openshift_management_storage_nfs_base_dir` parameter. For example, if your server export is `/exports/hosted/prod/cfme-app` then you must set -`openshift_cfme_storage_nfs_base_dir=/exports/hosted/prod`. +`openshift_management_storage_nfs_base_dir=/exports/hosted/prod`. ### Cloud Provider @@ -434,12 +435,12 @@ storage class. # Customization Application and database parameters may be customized by means of the -`openshift_cfme_template_parameters` inventory parameter. +`openshift_management_template_parameters` inventory parameter. **For example**, if you wanted to reduce the memory requirement of the PostgreSQL pod then you could configure the parameter like this: -`openshift_cfme_template_parameters={'POSTGRESQL_MEM_REQ': '1Gi'}` +`openshift_management_template_parameters={'POSTGRESQL_MEM_REQ': '1Gi'}` When the CFME template is processed `1Gi` will be used for the value of the `POSTGRESQL_MEM_REQ` template parameter. @@ -447,12 +448,19 @@ of the `POSTGRESQL_MEM_REQ` template parameter. Any parameter in the `parameters` section of the [miq-template.yaml](files/templates/manageiq/miq-template.yaml) or [miq-template-ext-db.yaml](files/templates/manageiq/miq-template-ext-db.yaml) -may be overridden through the `openshift_cfme_template_parameters` +may be overridden through the `openshift_management_template_parameters` hash. This applies to **CloudForms** installations as well: [cfme-template.yaml](files/templates/cloudforms/cfme-template.yaml), [cfme-template-ext-db.yaml](files/templates/cloudforms/cfme-template-ext-db.yaml). +# Uninstall + +This role includes a playbook to uninstall and erase the CFME/MIQ +installation: + +* `playbooks/byo/openshift-management/uninstall.yml` + # Additional Information The upstream project, diff --git a/roles/openshift_cfme/defaults/main.yml b/roles/openshift_management/defaults/main.yml index 8ba672262..ebb56313f 100644 --- a/roles/openshift_cfme/defaults/main.yml +++ b/roles/openshift_management/defaults/main.yml @@ -1,8 +1,8 @@ --- # Namespace for the CFME project -openshift_cfme_project: openshift-cfme +openshift_management_project: openshift-management # Namespace/project description -openshift_cfme_project_description: CloudForms Management Engine +openshift_management_project_description: CloudForms Management Engine ###################################################################### # BASE TEMPLATE AND DATABASE OPTIONS @@ -13,17 +13,17 @@ openshift_cfme_project_description: CloudForms Management Engine # # Choose 'miq-template' for a podified database install # Choose 'miq-template-ext-db' for an external database install -openshift_cfme_app_template: miq-template +openshift_management_app_template: miq-template # If you are using the miq-template-ext-db template then you must add # the required database parameters to the -# openshift_cfme_template_parameters variable. +# openshift_management_template_parameters variable. ###################################################################### # STORAGE OPTIONS ###################################################################### # DEFAULT - 'nfs' # Allowed options: nfs, nfs_external, preconfigured, cloudprovider. -openshift_cfme_storage_class: nfs +openshift_management_storage_class: nfs # * nfs - Best used for proof-of-concept installs. Will setup NFS on a # cluster host (defaults to your first master in the inventory file) # to back the required PVCs. The application requires a PVC and the @@ -55,26 +55,26 @@ openshift_cfme_storage_class: nfs # [OPTIONAL] - If you are using an EXTERNAL NFS server, such as a # netapp appliance, then you must set the hostname here. Leave the # value as 'false' if you are not using external NFS. -openshift_cfme_storage_nfs_external_hostname: false +openshift_management_storage_nfs_external_hostname: false # [OPTIONAL] - If you are using external NFS then you must set the base # path to the exports location here. # # Additionally: EXTERNAL NFS REQUIRES that YOU CREATE the nfs exports # that will back the application PV and optionally the database # pv. Export path definitions, relative to -# {{ openshift_cfme_storage_nfs_base_dir }} +# {{ openshift_management_storage_nfs_base_dir }} # # LOCAL NFS NOTE: # # You may may also change this value if you want to change the default # path used for local NFS exports. -openshift_cfme_storage_nfs_base_dir: /exports +openshift_management_storage_nfs_base_dir: /exports # # LOCAL NFS NOTE: # # You may override the automatically selected LOCAL NFS server by # setting this variable. Useful for testing specific task files. -openshift_cfme_storage_nfs_local_hostname: false +openshift_management_storage_nfs_local_hostname: false ###################################################################### # SCAFFOLDING - These are parameters we pre-seed that a user may or @@ -86,5 +86,5 @@ openshift_cfme_storage_nfs_local_hostname: false # under the .parameters list in files/miq-template{-ext-db}.yaml # Example: # -# openshift_cfme_template_parameters={'APPLICATION_MEM_REQ': '512Mi'} -openshift_cfme_template_parameters: {} +# openshift_management_template_parameters={'APPLICATION_MEM_REQ': '512Mi'} +openshift_management_template_parameters: {} diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-backup-job.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-backup-job.yaml index c3bc1d20c..c3bc1d20c 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-backup-job.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-backup-job.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-backup-pvc.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-backup-pvc.yaml index 92598ce82..92598ce82 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-backup-pvc.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-backup-pvc.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-pv-backup-example.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-pv-backup-example.yaml index 4fe349897..4fe349897 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-pv-backup-example.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-pv-backup-example.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-pv-db-example.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-pv-db-example.yaml index 0cdd821b5..0cdd821b5 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-pv-db-example.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-pv-db-example.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-pv-server-example.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-pv-server-example.yaml index 527090ae8..527090ae8 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-pv-server-example.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-pv-server-example.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-restore-job.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-restore-job.yaml index 8b23f8a33..8b23f8a33 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-restore-job.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-restore-job.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-scc-sysadmin.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-scc-sysadmin.yaml index d2ece9298..d2ece9298 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-scc-sysadmin.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-scc-sysadmin.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-template-ext-db.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-template-ext-db.yaml index 4a04f3372..4a04f3372 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-template-ext-db.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-template-ext-db.yaml diff --git a/roles/openshift_cfme/files/templates/cloudforms/cfme-template.yaml b/roles/openshift_management/files/templates/cloudforms/cfme-template.yaml index d7c9f5af7..d7c9f5af7 100644 --- a/roles/openshift_cfme/files/templates/cloudforms/cfme-template.yaml +++ b/roles/openshift_management/files/templates/cloudforms/cfme-template.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-backup-job.yaml b/roles/openshift_management/files/templates/manageiq/miq-backup-job.yaml index 044cb73a5..044cb73a5 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-backup-job.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-backup-job.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-backup-pvc.yaml b/roles/openshift_management/files/templates/manageiq/miq-backup-pvc.yaml index 25696ef23..25696ef23 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-backup-pvc.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-backup-pvc.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-pv-backup-example.yaml b/roles/openshift_management/files/templates/manageiq/miq-pv-backup-example.yaml index a5cf54d4e..a5cf54d4e 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-pv-backup-example.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-pv-backup-example.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-pv-db-example.yaml b/roles/openshift_management/files/templates/manageiq/miq-pv-db-example.yaml index a803bebe2..a803bebe2 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-pv-db-example.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-pv-db-example.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-pv-server-example.yaml b/roles/openshift_management/files/templates/manageiq/miq-pv-server-example.yaml index 1288544d1..1288544d1 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-pv-server-example.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-pv-server-example.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-restore-job.yaml b/roles/openshift_management/files/templates/manageiq/miq-restore-job.yaml index eea284dd4..eea284dd4 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-restore-job.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-restore-job.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-template-ext-db.yaml b/roles/openshift_management/files/templates/manageiq/miq-template-ext-db.yaml index 82cd5d49e..82cd5d49e 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-template-ext-db.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-template-ext-db.yaml diff --git a/roles/openshift_cfme/files/templates/manageiq/miq-template.yaml b/roles/openshift_management/files/templates/manageiq/miq-template.yaml index 3f5a12205..3f5a12205 100644 --- a/roles/openshift_cfme/files/templates/manageiq/miq-template.yaml +++ b/roles/openshift_management/files/templates/manageiq/miq-template.yaml diff --git a/roles/openshift_cfme/handlers/main.yml b/roles/openshift_management/handlers/main.yml index e69de29bb..e69de29bb 100644 --- a/roles/openshift_cfme/handlers/main.yml +++ b/roles/openshift_management/handlers/main.yml diff --git a/roles/openshift_cfme/meta/main.yml b/roles/openshift_management/meta/main.yml index 07ad51126..07ad51126 100644 --- a/roles/openshift_cfme/meta/main.yml +++ b/roles/openshift_management/meta/main.yml diff --git a/roles/openshift_cfme/tasks/accounts.yml b/roles/openshift_management/tasks/accounts.yml index 64976cd0e..e45ea8d43 100644 --- a/roles/openshift_cfme/tasks/accounts.yml +++ b/roles/openshift_management/tasks/accounts.yml @@ -3,16 +3,16 @@ # and ensuring correct access is provided as required. - name: Ensure the CFME system accounts exist oc_serviceaccount: - namespace: "{{ openshift_cfme_project }}" + namespace: "{{ openshift_management_project }}" state: present - name: "{{ openshift_cfme_flavor_short }}{{ item.name }}" + name: "{{ openshift_management_flavor_short }}{{ item.name }}" with_items: - "{{ __openshift_system_account_sccs }}" - name: Ensure the CFME system accounts have all the required SCCs oc_adm_policy_user: - namespace: "{{ openshift_cfme_project }}" - user: "system:serviceaccount:{{ openshift_cfme_project }}:{{ openshift_cfme_flavor_short }}{{ item.name }}" + namespace: "{{ openshift_management_project }}" + user: "system:serviceaccount:{{ openshift_management_project }}:{{ openshift_management_flavor_short }}{{ item.name }}" resource_kind: scc resource_name: "{{ item.resource_name }}" with_items: @@ -20,9 +20,9 @@ - name: Ensure the CFME system accounts have the required roles oc_adm_policy_user: - namespace: "{{ openshift_cfme_project }}" - user: "system:serviceaccount:{{ openshift_cfme_project }}:{{ openshift_cfme_flavor_short }}{{ item.name }}" + namespace: "{{ openshift_management_project }}" + user: "system:serviceaccount:{{ openshift_management_project }}:{{ openshift_management_flavor_short }}{{ item.name }}" resource_kind: role resource_name: "{{ item.resource_name }}" with_items: - - "{{ __openshift_cfme_system_account_roles }}" + - "{{ __openshift_management_system_account_roles }}" diff --git a/roles/openshift_cfme/tasks/main.yml b/roles/openshift_management/tasks/main.yml index 78a6710b3..86c4d0010 100644 --- a/roles/openshift_cfme/tasks/main.yml +++ b/roles/openshift_management/tasks/main.yml @@ -5,11 +5,11 @@ - name: Run pre-install CFME validation checks include: validate.yml -- name: "Ensure the CFME '{{ openshift_cfme_project }}' namespace exists" +- name: "Ensure the CFME '{{ openshift_management_project }}' namespace exists" oc_project: state: present - name: "{{ openshift_cfme_project }}" - display_name: "{{ openshift_cfme_project_description }}" + name: "{{ openshift_management_project }}" + display_name: "{{ openshift_management_project_description }}" - name: Create and Authorize CFME Accounts include: accounts.yml @@ -20,28 +20,28 @@ # * nfs - set up NFS shares on the first master for a proof of concept - name: Create required NFS exports for CFME app storage include: storage/nfs.yml - when: openshift_cfme_storage_class == 'nfs' + when: openshift_management_storage_class == 'nfs' #--------------------------------------------------------------------- # * external - NFS again, but pointing to a pre-configured NFS server - name: Note Storage Type - External NFS debug: - msg: "Setting up external NFS storage, openshift_cfme_storage_class is {{ openshift_cfme_storage_class }}" - when: openshift_cfme_storage_class == 'nfs_external' + msg: "Setting up external NFS storage, openshift_management_storage_class is {{ openshift_management_storage_class }}" + when: openshift_management_storage_class == 'nfs_external' #--------------------------------------------------------------------- # * cloudprovider - use an existing cloudprovider based storage - name: Note Storage Type - Cloud Provider debug: - msg: Validating cloud provider storage type, openshift_cfme_storage_class is 'cloudprovider' - when: openshift_cfme_storage_class == 'cloudprovider' + msg: Validating cloud provider storage type, openshift_management_storage_class is 'cloudprovider' + when: openshift_management_storage_class == 'cloudprovider' #--------------------------------------------------------------------- # * preconfigured - don't do anything, assume it's all there ready to go - name: Note Storage Type - Preconfigured debug: - msg: Skipping storage configuration, openshift_cfme_storage_class is 'preconfigured' - when: openshift_cfme_storage_class == 'preconfigured' + msg: Skipping storage configuration, openshift_management_storage_class is 'preconfigured' + when: openshift_management_storage_class == 'preconfigured' ###################################################################### # APPLICATION TEMPLATE @@ -52,28 +52,28 @@ # APP & DB Storage # For local/external NFS backed installations -- name: "Create the required App and DB PVs using {{ openshift_cfme_storage_class }}" +- name: "Create the required App and DB PVs using {{ openshift_management_storage_class }}" include: storage/create_nfs_pvs.yml when: - - openshift_cfme_storage_class in ['nfs', 'nfs_external'] + - openshift_management_storage_class in ['nfs', 'nfs_external'] ###################################################################### # CREATE APP - name: Note the correct ext-db template name set_fact: - openshift_cfme_template_name: "{{ openshift_cfme_flavor }}-ext-db" + openshift_management_template_name: "{{ openshift_management_flavor }}-ext-db" when: - - openshift_cfme_app_template in ['miq-template-ext-db', 'cfme-template-ext-db'] + - openshift_management_app_template in ['miq-template-ext-db', 'cfme-template-ext-db'] - name: Note the correct podified db template name set_fact: - openshift_cfme_template_name: "{{ openshift_cfme_flavor }}" + openshift_management_template_name: "{{ openshift_management_flavor }}" when: - - openshift_cfme_app_template in ['miq-template', 'cfme-template'] + - openshift_management_app_template in ['miq-template', 'cfme-template'] - name: Ensure the CFME App is created oc_process: - namespace: "{{ openshift_cfme_project }}" - template_name: "{{ openshift_cfme_template_name }}" + namespace: "{{ openshift_management_project }}" + template_name: "{{ openshift_management_template_name }}" create: True - params: "{{ openshift_cfme_template_parameters }}" + params: "{{ openshift_management_template_parameters }}" diff --git a/roles/openshift_management/tasks/storage/create_nfs_pvs.yml b/roles/openshift_management/tasks/storage/create_nfs_pvs.yml new file mode 100644 index 000000000..31c845725 --- /dev/null +++ b/roles/openshift_management/tasks/storage/create_nfs_pvs.yml @@ -0,0 +1,69 @@ +--- +# Create the required PVs for the App and the DB +- name: Note the App PV Size from Template Parameters + set_fact: + openshift_management_app_pv_size: "{{ openshift_management_template_parameters.APPLICATION_VOLUME_CAPACITY }}" + when: + - openshift_management_template_parameters.APPLICATION_VOLUME_CAPACITY is defined + +- name: Note the App PV Size from defaults + set_fact: + openshift_management_app_pv_size: "{{ __openshift_management_app_pv_size }}" + when: + - openshift_management_template_parameters.APPLICATION_VOLUME_CAPACITY is not defined + +- when: openshift_management_app_template in ['miq-template', 'cfme-template'] + block: + - name: Note the DB PV Size from Template Parameters + set_fact: + openshift_management_db_pv_size: "{{ openshift_management_template_parameters.DATABASE_VOLUME_CAPACITY }}" + when: + - openshift_management_template_parameters.DATABASE_VOLUME_CAPACITY is defined + + - name: Note the DB PV Size from defaults + set_fact: + openshift_management_db_pv_size: "{{ __openshift_management_db_pv_size }}" + when: + - openshift_management_template_parameters.DATABASE_VOLUME_CAPACITY is not defined + +- name: Check if the CFME App PV has been created + oc_obj: + namespace: "{{ openshift_management_project }}" + state: list + kind: pv + name: "{{ openshift_management_flavor_short }}-app" + register: miq_app_pv_check + +- name: Check if the CFME DB PV has been created + oc_obj: + namespace: "{{ openshift_management_project }}" + state: list + kind: pv + name: "{{ openshift_management_flavor_short }}-db" + register: miq_db_pv_check + when: + - openshift_management_app_template in ['miq-template', 'cfme-template'] + +- name: Ensure the CFME App PV is created + oc_process: + namespace: "{{ openshift_management_project }}" + template_name: "{{ openshift_management_flavor }}-app-pv" + create: True + params: + PV_SIZE: "{{ openshift_management_app_pv_size }}" + BASE_PATH: "{{ openshift_management_storage_nfs_base_dir }}" + NFS_HOST: "{{ openshift_management_nfs_server }}" + when: miq_app_pv_check.results.results == [{}] + +- name: Ensure the CFME DB PV is created + oc_process: + namespace: "{{ openshift_management_project }}" + template_name: "{{ openshift_management_flavor }}-db-pv" + create: True + params: + PV_SIZE: "{{ openshift_management_db_pv_size }}" + BASE_PATH: "{{ openshift_management_storage_nfs_base_dir }}" + NFS_HOST: "{{ openshift_management_nfs_server }}" + when: + - openshift_management_app_template in ['miq-template', 'cfme-template'] + - miq_db_pv_check.results.results == [{}] diff --git a/roles/openshift_management/tasks/storage/nfs.yml b/roles/openshift_management/tasks/storage/nfs.yml new file mode 100644 index 000000000..696808328 --- /dev/null +++ b/roles/openshift_management/tasks/storage/nfs.yml @@ -0,0 +1,67 @@ +--- +# Tasks to statically provision NFS volumes +# Include if not using dynamic volume provisioning + +- name: Ensure we save the local NFS server if one is provided + set_fact: + openshift_management_nfs_server: "{{ openshift_management_storage_nfs_local_hostname }}" + when: + - openshift_management_storage_nfs_local_hostname is defined + - openshift_management_storage_nfs_local_hostname != False + - openshift_management_storage_class == "nfs" + +- name: Ensure we save the local NFS server + set_fact: + openshift_management_nfs_server: "{{ groups['oo_nfs_to_config'].0 }}" + when: + - openshift_management_nfs_server is not defined + - openshift_management_storage_class == "nfs" + +- name: Ensure we save the external NFS server + set_fact: + openshift_management_nfs_server: "{{ openshift_management_storage_nfs_external_hostname }}" + when: + - openshift_management_storage_class == "nfs_external" + +- name: Failed NFS server detection + assert: + that: + - openshift_management_nfs_server is defined + msg: | + "Unable to detect an NFS server. The 'nfs_external' + openshift_management_storage_class option requires that you set + openshift_management_storage_nfs_external_hostname. NFS hosts detected + for local nfs services: {{ groups['oo_nfs_to_config'] | join(', ') }}" + +- name: Setting up NFS storage + block: + - name: Include the NFS Setup role tasks + include_role: + role: openshift_nfs + tasks_from: setup + vars: + l_nfs_base_dir: "{{ openshift_management_storage_nfs_base_dir }}" + + - name: Create the App export + include_role: + role: openshift_nfs + tasks_from: create_export + vars: + l_nfs_base_dir: "{{ openshift_management_storage_nfs_base_dir }}" + l_nfs_export_config: "{{ openshift_management_flavor_short }}" + l_nfs_export_name: "{{ openshift_management_flavor_short }}-app" + l_nfs_options: "*(rw,no_root_squash,no_wdelay)" + + - name: Create the DB export + include_role: + role: openshift_nfs + tasks_from: create_export + vars: + l_nfs_base_dir: "{{ openshift_management_storage_nfs_base_dir }}" + l_nfs_export_config: "{{ openshift_management_flavor_short }}" + l_nfs_export_name: "{{ openshift_management_flavor_short }}-db" + l_nfs_options: "*(rw,no_root_squash,no_wdelay)" + when: + - openshift_management_app_template in ['miq-template', 'cfme-template'] + + delegate_to: "{{ openshift_management_nfs_server }}" diff --git a/roles/openshift_cfme/tasks/storage/storage.yml b/roles/openshift_management/tasks/storage/storage.yml index d8bf7aa3e..d8bf7aa3e 100644 --- a/roles/openshift_cfme/tasks/storage/storage.yml +++ b/roles/openshift_management/tasks/storage/storage.yml diff --git a/roles/openshift_cfme/tasks/template.yml b/roles/openshift_management/tasks/template.yml index 2061e2bd7..299158ac4 100644 --- a/roles/openshift_cfme/tasks/template.yml +++ b/roles/openshift_management/tasks/template.yml @@ -13,59 +13,59 @@ ###################################################################### # STANDARD PODIFIED DATABASE TEMPLATE -- when: openshift_cfme_app_template in ['miq-template', 'cfme-template'] +- when: openshift_management_app_template in ['miq-template', 'cfme-template'] block: - name: Check if the CFME Server template has been created already oc_obj: - namespace: "{{ openshift_cfme_project }}" + namespace: "{{ openshift_management_project }}" state: list kind: template - name: "{{ openshift_cfme_flavor }}" + name: "{{ openshift_management_flavor }}" register: miq_server_check - when: miq_server_check.results.results == [{}] block: - name: Copy over CFME Server template copy: - src: "templates/{{ openshift_cfme_flavor }}/{{ openshift_cfme_flavor_short }}-template.yaml" + src: "templates/{{ openshift_management_flavor }}/{{ openshift_management_flavor_short }}-template.yaml" dest: "{{ template_dir }}/" - name: Ensure CFME Server Template is created oc_obj: - namespace: "{{ openshift_cfme_project }}" - name: "{{ openshift_cfme_flavor }}" + namespace: "{{ openshift_management_project }}" + name: "{{ openshift_management_flavor }}" state: present kind: template files: - - "{{ template_dir }}/{{ openshift_cfme_flavor_short }}-template.yaml" + - "{{ template_dir }}/{{ openshift_management_flavor_short }}-template.yaml" ###################################################################### # EXTERNAL DATABASE TEMPLATE -- when: openshift_cfme_app_template in ['miq-template-ext-db', 'cfme-template'] +- when: openshift_management_app_template in ['miq-template-ext-db', 'cfme-template'] block: - name: Check if the CFME Ext-DB Server template has been created already oc_obj: - namespace: "{{ openshift_cfme_project }}" + namespace: "{{ openshift_management_project }}" state: list kind: template - name: "{{ openshift_cfme_flavor }}-ext-db" + name: "{{ openshift_management_flavor }}-ext-db" register: miq_ext_db_server_check - when: miq_ext_db_server_check.results.results == [{}] block: - name: Copy over CFME Ext-DB Server template copy: - src: "templates/{{ openshift_cfme_flavor }}/{{openshift_cfme_flavor_short}}-template-ext-db.yaml" + src: "templates/{{ openshift_management_flavor }}/{{openshift_management_flavor_short}}-template-ext-db.yaml" dest: "{{ template_dir }}/" - name: Ensure CFME Ext-DB Server Template is created oc_obj: - namespace: "{{ openshift_cfme_project }}" - name: "{{ openshift_cfme_flavor }}-ext-db" + namespace: "{{ openshift_management_project }}" + name: "{{ openshift_management_flavor }}-ext-db" state: present kind: template files: - - "{{ template_dir }}/{{ openshift_cfme_flavor_short }}-template-ext-db.yaml" + - "{{ template_dir }}/{{ openshift_management_flavor_short }}-template-ext-db.yaml" # End app template creation. ###################################################################### @@ -76,53 +76,53 @@ # Required for the application server - name: Check if the CFME App PV template has been created already oc_obj: - namespace: "{{ openshift_cfme_project }}" + namespace: "{{ openshift_management_project }}" state: list kind: template - name: "{{ openshift_cfme_flavor }}-app-pv" + name: "{{ openshift_management_flavor }}-app-pv" register: miq_app_pv_check - when: miq_app_pv_check.results.results == [{}] block: - name: Copy over CFME App PV template copy: - src: "templates/{{ openshift_cfme_flavor }}/{{ openshift_cfme_flavor_short }}-pv-server-example.yaml" + src: "templates/{{ openshift_management_flavor }}/{{ openshift_management_flavor_short }}-pv-server-example.yaml" dest: "{{ template_dir }}/" - name: Ensure CFME App PV Template is created oc_obj: - namespace: "{{ openshift_cfme_project }}" - name: "{{ openshift_cfme_flavor }}-app-pv" + namespace: "{{ openshift_management_project }}" + name: "{{ openshift_management_flavor }}-app-pv" state: present kind: template files: - - "{{ template_dir }}/{{ openshift_cfme_flavor_short }}-pv-server-example.yaml" + - "{{ template_dir }}/{{ openshift_management_flavor_short }}-pv-server-example.yaml" #--------------------------------------------------------------------- # Required for database if the installation is fully podified -- when: openshift_cfme_app_template in ['miq-template', 'cfme-template'] +- when: openshift_management_app_template in ['miq-template', 'cfme-template'] block: - name: Check if the CFME DB PV template has been created already oc_obj: - namespace: "{{ openshift_cfme_project }}" + namespace: "{{ openshift_management_project }}" state: list kind: template - name: "{{ openshift_cfme_flavor }}-db-pv" + name: "{{ openshift_management_flavor }}-db-pv" register: miq_db_pv_check - when: miq_db_pv_check.results.results == [{}] block: - name: Copy over CFME DB PV template copy: - src: "templates/{{ openshift_cfme_flavor }}/{{ openshift_cfme_flavor_short }}-pv-db-example.yaml" + src: "templates/{{ openshift_management_flavor }}/{{ openshift_management_flavor_short }}-pv-db-example.yaml" dest: "{{ template_dir }}/" - name: Ensure CFME DB PV Template is created oc_obj: - namespace: "{{ openshift_cfme_project }}" - name: "{{ openshift_cfme_flavor }}-db-pv" + namespace: "{{ openshift_management_project }}" + name: "{{ openshift_management_flavor }}-db-pv" state: present kind: template files: - - "{{ template_dir }}/{{ openshift_cfme_flavor_short }}-pv-db-example.yaml" + - "{{ template_dir }}/{{ openshift_management_flavor_short }}-pv-db-example.yaml" diff --git a/roles/openshift_cfme/tasks/uninstall.yml b/roles/openshift_management/tasks/uninstall.yml index 068d065c2..09fbc609f 100644 --- a/roles/openshift_cfme/tasks/uninstall.yml +++ b/roles/openshift_management/tasks/uninstall.yml @@ -1,6 +1,6 @@ --- - name: Start removing all the objects - command: "oc delete -n {{ openshift_cfme_project }} {{ item }} --all" + command: "oc delete -n {{ openshift_management_project }} {{ item }} --all" with_items: - rc - dc @@ -12,10 +12,10 @@ - routes - name: Remove the project - command: "oc delete -n {{ openshift_cfme_project }} project {{ openshift_cfme_project }}" + command: "oc delete -n {{ openshift_management_project }} project {{ openshift_management_project }}" - name: Verify project has been destroyed - command: "oc get project {{ openshift_cfme_project }}" + command: "oc get project {{ openshift_management_project }}" ignore_errors: True register: project_terminated until: project_terminated.stderr.find("NotFound") != -1 diff --git a/roles/openshift_cfme/tasks/validate.yml b/roles/openshift_management/tasks/validate.yml index 1ba813a43..8b20bdc5e 100644 --- a/roles/openshift_cfme/tasks/validate.yml +++ b/roles/openshift_management/tasks/validate.yml @@ -1,49 +1,49 @@ --- -# Validate configuration parameters passed to the openshift_cfme role +# Validate configuration parameters passed to the openshift_management role ###################################################################### # CORE PARAMETERS -- name: Ensure openshift_cfme_app_template is valid +- name: Ensure openshift_management_app_template is valid assert: that: - - openshift_cfme_app_template in __openshift_cfme_app_templates + - openshift_management_app_template in __openshift_management_app_templates msg: | - "openshift_cfme_app_template must be one of {{ - __openshift_cfme_app_templates | join(', ') }}" + "openshift_management_app_template must be one of {{ + __openshift_management_app_templates | join(', ') }}" -- name: Ensure openshift_cfme_storage_class is a valid type +- name: Ensure openshift_management_storage_class is a valid type assert: that: - - openshift_cfme_storage_class in __openshift_cfme_storage_classes + - openshift_management_storage_class in __openshift_management_storage_classes msg: | - "openshift_cfme_storage_class must be one of {{ - __openshift_cfme_storage_classes | join(', ') }}" + "openshift_management_storage_class must be one of {{ + __openshift_management_storage_classes | join(', ') }}" ###################################################################### # STORAGE PARAMS - NFS - name: Ensure external NFS storage has a valid NFS server hostname defined assert: that: - - openshift_cfme_storage_nfs_external_hostname | default(False) + - openshift_management_storage_nfs_external_hostname | default(False) msg: | The selected storage class 'nfs_external' requires a valid - hostname for the openshift_cfme_storage_nfs_hostname parameter + hostname for the openshift_management_storage_nfs_hostname parameter when: - - openshift_cfme_storage_class == 'nfs_external' + - openshift_management_storage_class == 'nfs_external' - name: Ensure local NFS storage has a valid NFS server to use fail: msg: | No NFS hosts detected or defined but storage class is set to 'nfs'. Add hosts to your [nfs] group or define one manually with - the 'openshift_cfme_storage_nfs_local_hostname' parameter + the 'openshift_management_storage_nfs_local_hostname' parameter when: - - openshift_cfme_storage_class == 'nfs' + - openshift_management_storage_class == 'nfs' # You haven't created any NFS groups - (groups.nfs is defined and groups.nfs | length == 0) or (groups.nfs is not defined) # You did not manually specify a host to use - - (openshift_cfme_storage_nfs_local_hostname is not defined) or (openshift_cfme_storage_nfs_local_hostname == false) + - (openshift_management_storage_nfs_local_hostname is not defined) or (openshift_management_storage_nfs_local_hostname == false) ###################################################################### # STORAGE PARAMS -CLOUD PROVIDER @@ -52,13 +52,13 @@ that: - openshift_cloudprovider_kind == 'aws' or openshift_cloudprovider_kind == 'gce' msg: | - openshift_cfme_storage_class is 'cloudprovider' but you have an + openshift_management_storage_class is 'cloudprovider' but you have an invalid kind defined, '{{ openshift_cloudprovider_kind }}'. See 'openshift_cloudprovider_kind' in the example inventories for the required parameters for your selected cloud provider. Working providers: 'aws' and 'gce'. when: - - openshift_cfme_storage_class == 'cloudprovider' + - openshift_management_storage_class == 'cloudprovider' - openshift_cloudprovider_kind is defined - name: Validate 'cloudprovider' Storage Class has required parameters defined @@ -66,25 +66,25 @@ that: - openshift_cloudprovider_kind is defined msg: | - openshift_cfme_storage_class is 'cloudprovider' but you do not + openshift_management_storage_class is 'cloudprovider' but you do not have 'openshift_cloudprovider_kind' defined, this is required. Search the example inventories for 'openshift_cloudprovider_kind'. The required parameters for your selected cloud provider must be defined in your inventory as well. Working providers: 'aws' and 'gce'. when: - - openshift_cfme_storage_class == 'cloudprovider' + - openshift_management_storage_class == 'cloudprovider' ###################################################################### # DATABASE CONNECTION VALIDATION - name: Validate all required database parameters were provided for ext-db template assert: that: - - item in openshift_cfme_template_parameters + - item in openshift_management_template_parameters msg: | "You are using external database services but a required database parameter {{ item }} was not found in - 'openshift_cfme_template_parameters'" - with_items: "{{ __openshift_cfme_required_db_conn_params }}" + 'openshift_management_template_parameters'" + with_items: "{{ __openshift_management_required_db_conn_params }}" when: - - openshift_cfme_app_template in ['miq-template-ext-db', 'cfme-template-ext-db'] + - openshift_management_app_template in ['miq-template-ext-db', 'cfme-template-ext-db'] diff --git a/roles/openshift_cfme/vars/main.yml b/roles/openshift_management/vars/main.yml index 9764f464c..da3ad0af7 100644 --- a/roles/openshift_cfme/vars/main.yml +++ b/roles/openshift_management/vars/main.yml @@ -2,7 +2,7 @@ # Misc enumerated values #--------------------------------------------------------------------- # Allowed choices for the storage class parameter -__openshift_cfme_storage_classes: +__openshift_management_storage_classes: - nfs - nfs_external - preconfigured @@ -11,19 +11,19 @@ __openshift_cfme_storage_classes: #--------------------------------------------------------------------- # DEFAULT PV SIZES # How large to make the MIQ application PV -__openshift_cfme_app_pv_size: 5Gi +__openshift_management_app_pv_size: 5Gi # How large to make the MIQ PostgreSQL PV -__openshift_cfme_db_pv_size: 15Gi +__openshift_management_db_pv_size: 15Gi # Name of the application templates with object/parameter definitions -__openshift_cfme_app_templates: +__openshift_management_app_templates: - miq-template-ext-db - miq-template - cfme-template-ext-db - cfme-template # PostgreSQL database connection parameters -__openshift_cfme_db_parameters: +__openshift_management_db_parameters: - DATABASE_USER - DATABASE_PASSWORD - DATABASE_IP @@ -31,13 +31,13 @@ __openshift_cfme_db_parameters: - DATABASE_NAME # # Commented out until we can support both CFME and MIQ -# # openshift_cfme_flavor: "{{ 'cloudforms' if openshift_deployment_type == 'openshift-enterprise' else 'manageiq' }}" -#openshift_cfme_flavor: cloudforms -openshift_cfme_flavor: manageiq +# # openshift_management_flavor: "{{ 'cloudforms' if openshift_deployment_type == 'openshift-enterprise' else 'manageiq' }}" +#openshift_management_flavor: cloudforms +openshift_management_flavor: manageiq # TODO: Make this conditional as well based on the prior variable -# # openshift_cfme_flavor_short: "{{ 'cfme' if openshift_deployment_type == 'openshift-enterprise' else 'miq' }}" -# openshift_cfme_flavor_short: cfme -openshift_cfme_flavor_short: miq +# # openshift_management_flavor_short: "{{ 'cfme' if openshift_deployment_type == 'openshift-enterprise' else 'miq' }}" +# openshift_management_flavor_short: cfme +openshift_management_flavor_short: miq ###################################################################### # ACCOUNTING @@ -54,7 +54,7 @@ __openshift_system_account_sccs: resource_name: anyuid # Service Account Roles -__openshift_cfme_system_account_roles: +__openshift_management_system_account_roles: - name: -orchestrator resource_name: view - name: -orchestrator @@ -68,7 +68,7 @@ __openshift_cfme_system_account_roles: # the final connection structure. # # TODO: Update user provided configs with this if they are missing fields -__openshift_cfme_required_db_conn_params: +__openshift_management_required_db_conn_params: - DATABASE_USER - DATABASE_PASSWORD - DATABASE_IP diff --git a/roles/openshift_master/templates/master.yaml.v1.j2 b/roles/openshift_master/templates/master.yaml.v1.j2 index d045b402b..9b3fbcf49 100644 --- a/roles/openshift_master/templates/master.yaml.v1.j2 +++ b/roles/openshift_master/templates/master.yaml.v1.j2 @@ -251,11 +251,7 @@ servingInfo: bindAddress: {{ openshift.master.bind_addr }}:{{ openshift.master.api_port }} bindNetwork: tcp4 certFile: master.server.crt -{% if openshift.common.version_gte_3_2_or_1_2 | bool %} - clientCA: ca-bundle.crt -{% else %} clientCA: ca.crt -{% endif %} keyFile: master.server.key maxRequestsInFlight: {{ openshift.master.max_requests_inflight }} requestTimeoutSeconds: 3600 diff --git a/roles/openshift_node/tasks/config.yml b/roles/openshift_node/tasks/config.yml index e3898b520..e5fcaf9af 100644 --- a/roles/openshift_node/tasks/config.yml +++ b/roles/openshift_node/tasks/config.yml @@ -111,9 +111,5 @@ msg: Node failed to start please inspect the logs and try again when: node_start_result | failed -- name: Setup tuned - include: tuned.yml - static: yes - - set_fact: node_service_status_changed: "{{ node_start_result | changed }}" diff --git a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh index df02bcf0e..230f0a28c 100755 --- a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh +++ b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh @@ -112,10 +112,10 @@ EOF fi sed -e '/^nameserver.*$/d' /etc/resolv.conf >> ${NEW_RESOLV_CONF} echo "nameserver "${def_route_ip}"" >> ${NEW_RESOLV_CONF} - if ! grep -q 'search.*cluster.local' ${NEW_RESOLV_CONF}; then - sed -i '/^search/ s/$/ cluster.local/' ${NEW_RESOLV_CONF} - elif ! grep -qw search ${NEW_RESOLV_CONF}; then + if ! grep -qw search ${NEW_RESOLV_CONF}; then echo 'search cluster.local' >> ${NEW_RESOLV_CONF} + elif ! grep -q 'search.*cluster.local' ${NEW_RESOLV_CONF}; then + sed -i '/^search/ s/$/ cluster.local/' ${NEW_RESOLV_CONF} fi cp -Z ${NEW_RESOLV_CONF} /etc/resolv.conf fi diff --git a/roles/tuned/defaults/main.yml b/roles/tuned/defaults/main.yml new file mode 100644 index 000000000..418a4b521 --- /dev/null +++ b/roles/tuned/defaults/main.yml @@ -0,0 +1,3 @@ +--- +tuned_etc_directory: '/etc/tuned' +tuned_templates_source: '../templates' diff --git a/roles/tuned/meta/main.yml b/roles/tuned/meta/main.yml new file mode 100644 index 000000000..833d94c13 --- /dev/null +++ b/roles/tuned/meta/main.yml @@ -0,0 +1,13 @@ +--- +galaxy_info: + author: Jiri Mencak + description: Restart the tuned daemon if present and make it use the recommended profile + company: Red Hat, Inc. + license: Apache License, Version 2.0 + min_ansible_version: 2.3 + platforms: + - name: EL + versions: + - 7 + categories: + - cloud diff --git a/roles/openshift_node/tasks/tuned.yml b/roles/tuned/tasks/main.yml index 425bf6a26..e95d274d5 100644 --- a/roles/openshift_node/tasks/tuned.yml +++ b/roles/tuned/tasks/main.yml @@ -12,8 +12,6 @@ - name: Set tuned OpenShift variables set_fact: openshift_tuned_guest_profile: "{{ 'atomic-guest' if openshift.common.is_atomic else 'virtual-guest' }}" - tuned_etc_directory: '/etc/tuned' - tuned_templates_source: '../templates/tuned' - name: Ensure directory structure exists file: diff --git a/roles/openshift_node/templates/tuned/openshift-control-plane/tuned.conf b/roles/tuned/templates/openshift-control-plane/tuned.conf index f22f21065..f22f21065 100644 --- a/roles/openshift_node/templates/tuned/openshift-control-plane/tuned.conf +++ b/roles/tuned/templates/openshift-control-plane/tuned.conf diff --git a/roles/openshift_node/templates/tuned/openshift-node/tuned.conf b/roles/tuned/templates/openshift-node/tuned.conf index 78c7d19c9..78c7d19c9 100644 --- a/roles/openshift_node/templates/tuned/openshift-node/tuned.conf +++ b/roles/tuned/templates/openshift-node/tuned.conf diff --git a/roles/openshift_node/templates/tuned/openshift/tuned.conf b/roles/tuned/templates/openshift/tuned.conf index 68ac5dadb..68ac5dadb 100644 --- a/roles/openshift_node/templates/tuned/openshift/tuned.conf +++ b/roles/tuned/templates/openshift/tuned.conf diff --git a/roles/openshift_node/templates/tuned/recommend.conf b/roles/tuned/templates/recommend.conf index 5fa765798..086e5673d 100644 --- a/roles/openshift_node/templates/tuned/recommend.conf +++ b/roles/tuned/templates/recommend.conf @@ -1,8 +1,11 @@ -[openshift-node] -/etc/origin/node/node-config.yaml=.*region=primary - [openshift-control-plane,master] /etc/origin/master/master-config.yaml=.* [openshift-control-plane,node] /etc/origin/node/node-config.yaml=.*region=infra + +[openshift-control-plane,lb] +/etc/haproxy/haproxy.cfg=.* + +[openshift-node] +/etc/origin/node/node-config.yaml=.* |