From fae3f02b026e26044f28f0f6588cc0a635d91338 Mon Sep 17 00:00:00 2001 From: Sylvain Afchain Date: Fri, 30 Mar 2018 16:45:38 +0000 Subject: [PATCH] skydive external_deploy_task migration Change-Id: I9b9104ab3e8631addbca4d008d9a1d868e1c20fb implements: blueprint skydive-external-deploy-tasks --- docker/services/skydive/skydive-agent.yaml | 66 ------- docker/services/skydive/skydive-analyzer.yaml | 71 -------- docker/services/skydive/skydive-base.yaml | 108 ----------- .../services/skydive-environment.yaml | 13 +- extraconfig/services/skydive-agent.yaml | 40 +++++ extraconfig/services/skydive-analyzer.yaml | 170 ++++++++++++++++++ 6 files changed, 221 insertions(+), 247 deletions(-) delete mode 100644 docker/services/skydive/skydive-agent.yaml delete mode 100644 docker/services/skydive/skydive-analyzer.yaml delete mode 100644 docker/services/skydive/skydive-base.yaml create mode 100644 extraconfig/services/skydive-agent.yaml create mode 100644 extraconfig/services/skydive-analyzer.yaml diff --git a/docker/services/skydive/skydive-agent.yaml b/docker/services/skydive/skydive-agent.yaml deleted file mode 100644 index f83a037b92..0000000000 --- a/docker/services/skydive/skydive-agent.yaml +++ /dev/null @@ -1,66 +0,0 @@ -heat_template_version: rocky - -description: > - Skydive agent service. - -parameters: - ServiceData: - default: {} - description: Dictionary packing service data - type: json - ServiceNetMap: - default: {} - description: Mapping of service_name -> network name. Typically set - via parameter_defaults in the resource registry. This - mapping overrides those in ServiceNetMapDefaults. - type: json - DefaultPasswords: - default: {} - type: json - RoleName: - default: '' - description: Role name on which the service is applied - type: string - RoleParameters: - default: {} - description: Parameters specific to the role - type: json - EndpointMap: - default: {} - description: Mapping of service endpoint -> protocol. Typically set - via parameter_defaults in the resource registry. - type: json - DockerSkydiveAgentImage: - description: image - type: string - -resources: - SkydiveBase: - type: ./skydive-base.yaml - properties: - ServiceData: {get_param: ServiceData} - ServiceNetMap: {get_param: ServiceNetMap} - DefaultPasswords: {get_param: DefaultPasswords} - EndpointMap: {get_param: EndpointMap} - RoleName: {get_param: RoleName} - RoleParameters: {get_param: RoleParameters} - DockerSkydiveImage: {get_param: DockerSkydiveAgentImage} - -outputs: - role_data: - description: Role data for the Skydive agent service. - value: - service_name: skydive_agent - upgrade_tasks: [] - puppet_config: - config_image: '' - config_volume: '' - step_config: '' - docker_config: {} - workflow_tasks: {get_attr: [SkydiveBase, role_data, workflow_tasks]} - config_settings: - skydive_agent_ansible_vars: - map_merge: - - {get_attr: [SkydiveBase, role_data, config_settings, skydive_common_ansible_vars]} - - skydive_agent_docker_image: {get_attr: [SkydiveBase, role_data, config_settings, skydive_docker_image]} - skydive_agent_docker_command: "/usr/bin/skydive agent --conf /etc/skydive.yml" diff --git a/docker/services/skydive/skydive-analyzer.yaml b/docker/services/skydive/skydive-analyzer.yaml deleted file mode 100644 index 5cb7b8a647..0000000000 --- a/docker/services/skydive/skydive-analyzer.yaml +++ /dev/null @@ -1,71 +0,0 @@ -heat_template_version: rocky - -description: > - Skydive analyzer service. - -parameters: - ServiceData: - default: {} - description: Dictionary packing service data - type: json - ServiceNetMap: - default: {} - description: Mapping of service_name -> network name. Typically set - via parameter_defaults in the resource registry. This - mapping overrides those in ServiceNetMapDefaults. - type: json - DefaultPasswords: - default: {} - type: json - RoleName: - default: '' - description: Role name on which the service is applied - type: string - RoleParameters: - default: {} - description: Parameters specific to the role - type: json - EndpointMap: - default: {} - description: Mapping of service endpoint -> protocol. Typically set - via parameter_defaults in the resource registry. - type: json - DockerSkydiveAnalyzerImage: - description: image - type: string - -resources: - SkydiveBase: - type: ./skydive-base.yaml - properties: - ServiceData: {get_param: ServiceData} - ServiceNetMap: {get_param: ServiceNetMap} - DefaultPasswords: {get_param: DefaultPasswords} - EndpointMap: {get_param: EndpointMap} - RoleName: {get_param: RoleName} - RoleParameters: {get_param: RoleParameters} - DockerSkydiveImage: {get_param: DockerSkydiveAnalyzerImage} - -outputs: - role_data: - description: Role data for the Skydive analyzer service. - value: - service_name: skydive_analyzer - upgrade_tasks: [] - puppet_config: - config_image: '' - config_volume: '' - step_config: '' - docker_config: {} - workflow_tasks: {get_attr: [SkydiveBase, role_data, workflow_tasks]} - config_settings: - map_merge: - - tripleo.skydive_analyzer.firewall_rules: - '150 skydive_analyzer': - dport: 8082 - proto: tcp - - skydive_analyzer_ansible_vars: - map_merge: - - {get_attr: [SkydiveBase, role_data, config_settings, skydive_common_ansible_vars]} - - skydive_analyzer_docker_image: {get_attr: [SkydiveBase, role_data, config_settings, skydive_docker_image]} - skydive_analyzer_docker_command: "/usr/bin/skydive analyzer --conf /etc/skydive.yml" diff --git a/docker/services/skydive/skydive-base.yaml b/docker/services/skydive/skydive-base.yaml deleted file mode 100644 index fcef6c6edd..0000000000 --- a/docker/services/skydive/skydive-base.yaml +++ /dev/null @@ -1,108 +0,0 @@ -heat_template_version: rocky - -description: > - Skydive base service. Shared by all Skydive services. - -parameters: - ServiceData: - default: {} - description: Dictionary packing service data - type: json - ServiceNetMap: - default: {} - description: Mapping of service_name -> network name. Typically set - via parameter_defaults in the resource registry. This - mapping overrides those in ServiceNetMapDefaults. - type: json - DefaultPasswords: - default: {} - type: json - RoleName: - default: '' - description: Role name on which the service is applied - type: string - RoleParameters: - default: {} - description: Parameters specific to the role - type: json - EndpointMap: - default: {} - description: Mapping of service endpoint -> protocol. Typically set - via parameter_defaults in the resource registry. - type: json - SkydiveAnsibleWorkflowName: - type: string - description: Name of the Mistral workflow to execute - default: tripleo.skydive_ansible.v1.skydive_install - SkydiveAnsiblePlaybook: - type: string - description: Path to the skydive-ansible playbook to execute - default: /usr/share/skydive-ansible/playbook.yml.sample - SkydiveAnsibleExtraConfig: - type: json - description: Extra vars for the skydive-ansible playbook - default: - deployment_mode: container - DockerSkydiveImage: - description: image - type: string - -conditions: - custom_registry_host: - yaql: - data: {get_param: DockerSkydiveImage} - expression: $.data.split('/')[0].matches('(\.|:)') - -resources: - DockerImageUrlParts: - type: OS::Heat::Value - properties: - type: json - value: - host: - if: - - custom_registry_host - - yaql: - expression: let(location => $.data.rightSplit(':', 1)[0]) -> regex('(?:https?://)?(.*?)/(.*)').split($location)[1] - data: {get_param: DockerSkydiveImage} - - docker.io - image: - if: - - custom_registry_host - - yaql: - expression: let(location => $.data.rightSplit(':', 1)[0]) -> regex('(?:https?://)?(.*?)/(.*)').split($location)[2] - data: {get_param: DockerSkydiveImage} - - yaql: - expression: $.data.rightSplit(':', 1)[0] - data: {get_param: DockerSkydiveImage} - image_tag: - yaql: - expression: $.data.rightSplit(':', 1)[1] - data: {get_param: DockerSkydiveImage} - -outputs: - role_data: - description: Role data for the Skydive base service. - value: - service_name: skydive_base - upgrade_tasks: [] - puppet_config: - config_image: '' - config_volume: '' - step_config: '' - docker_config: {} - workflow_tasks: - step2: - - name: skydive_base_ansible_workflow - workflow: { get_param: SkydiveAnsibleWorkflowName } - input: - skydive_ansible_extra_vars: {get_param: SkydiveAnsibleExtraConfig} - skydive_ansible_playbook: {get_param: SkydiveAnsiblePlaybook} - config_settings: - skydive_docker_image: {get_attr: [DockerImageUrlParts, value, image]} - skydive_common_ansible_vars: - skydive_docker_registry: {get_attr: [DockerImageUrlParts, value, host]} - skydive_docker_image_tag: {get_attr: [DockerImageUrlParts, value, image_tag]} - skydive_deployment_mode: container - skydive_extra_config: - flow.protocol: websocket diff --git a/environments/services/skydive-environment.yaml b/environments/services/skydive-environment.yaml index 731ab7a2b0..c67bff73c6 100644 --- a/environments/services/skydive-environment.yaml +++ b/environments/services/skydive-environment.yaml @@ -1,3 +1,12 @@ resource_registry: - OS::TripleO::Services::SkydiveAgent: ../../docker/services/skydive/skydive-agent.yaml - OS::TripleO::Services::SkydiveAnalyzer: ../../docker/services/skydive/skydive-analyzer.yaml + OS::TripleO::Services::SkydiveAnalyzer: ../../extraconfig/services/skydive-analyzer.yaml + OS::TripleO::Services::SkydiveAgent: ../../extraconfig/services/skydive-agent.yaml + +#parameter_defaults: +# SkydiveVars: +# globals: +# skydive_listen_ip: 0.0.0.0 +# analyzers: +# skydive_analyzer_docker_command: "analyzer" +# agents: +# skydive_analyzer_docker_command: "agent" diff --git a/extraconfig/services/skydive-agent.yaml b/extraconfig/services/skydive-agent.yaml new file mode 100644 index 0000000000..656403734b --- /dev/null +++ b/extraconfig/services/skydive-agent.yaml @@ -0,0 +1,40 @@ +heat_template_version: rocky + +description: External tasks definition for Skydive + +parameters: + ServiceData: + default: {} + description: Dictionary packing service data + type: json + ServiceNetMap: + default: {} + description: Mapping of service_name -> network name. Typically set + via parameter_defaults in the resource registry. This + mapping overrides those in ServiceNetMapDefaults. + type: json + DefaultPasswords: + default: {} + type: json + RoleName: + default: '' + description: Role name on which the service is applied + type: string + RoleParameters: + default: {} + description: Parameters specific to the role + type: json + EndpointMap: + default: {} + description: Mapping of service endpoint -> protocol. Typically set + via parameter_defaults in the resource registry. + type: json + +outputs: + role_data: + description: Role data for Skydive services. + # This service template essentially tags the nodes that we want + # as agents. The installation is performed in skydive-analyzer template. + value: + service_name: skydive_agent + upgrade_tasks: [] diff --git a/extraconfig/services/skydive-analyzer.yaml b/extraconfig/services/skydive-analyzer.yaml new file mode 100644 index 0000000000..27f715aa5a --- /dev/null +++ b/extraconfig/services/skydive-analyzer.yaml @@ -0,0 +1,170 @@ +heat_template_version: rocky + +description: External tasks definition for Skydive + +parameters: + ServiceData: + default: {} + description: Dictionary packing service data + type: json + ServiceNetMap: + default: {} + description: Mapping of service_name -> network name. Typically set + via parameter_defaults in the resource registry. This + mapping overrides those in ServiceNetMapDefaults. + type: json + DefaultPasswords: + default: {} + type: json + RoleName: + default: '' + description: Role name on which the service is applied + type: string + RoleParameters: + default: {} + description: Parameters specific to the role + type: json + EndpointMap: + default: {} + description: Mapping of service endpoint -> protocol. Typically set + via parameter_defaults in the resource registry. + type: json + KeystoneRegion: + type: string + default: 'regionOne' + description: Keystone region for endpoint + EnableInternalTLS: + type: boolean + default: false + SkydiveAnsiblePlaybook: + type: string + description: Path to the skydive-ansible playbook to execute + default: /usr/share/skydive-ansible/playbook.yml.sample + SkydiveVars: + type: json + description: Variables used by skydive-ansible + default: {} + DockerSkydiveAnalyzerImage: + description: Analyzer docker image + type: string + DockerSkydiveAgentImage: + description: Agent docker image + type: string + +outputs: + role_data: + description: Role data for Skydive services. + value: + service_name: skydive_analyzer + upgrade_tasks: [] + puppet_config: + config_image: '' + config_volume: '' + step_config: '' + docker_config: {} + config_settings: + tripleo.skydive_analyzer.firewall_rules: + '150 skydive_analyzer': + dport: 8082 + proto: tcp + external_deploy_tasks: + - name: Skydive deployment + when: step == '5' + block: + - name: create skydive temp dirs + file: + path: "{{item}}" + state: directory + with_items: + - "{{playbook_dir}}/skydive" + + - name: Skydive global vars fact + set_fact: + os_auth_url: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix]} + os_region_name: {get_param: KeystoneRegion} + skydive_ansible_playbook: {get_param: SkydiveAnsiblePlaybook} + skydive_analyzer_docker_image: {get_param: DockerSkydiveAnalyzerImage} + skydive_agent_docker_image: {get_param: DockerSkydiveAgentImage} + skydive_vars: {get_param: SkydiveVars} + + - name: Skydive global defaults + copy: + dest: "{{playbook_dir}}/skydive/global_defaults.yml" + content: | + skydive_docker_registry: {{skydive_analyzer_docker_image | regex_replace("([^/]*).*", "\1")}} + skydive_docker_image_tag: {{skydive_analyzer_docker_image | regex_replace(".*:")}} + skydive_analyzer_docker_image: {{skydive_analyzer_docker_image | regex_replace("[^/]*/([^:]*).*", "\1")}} + skydive_analyzer_docker_command: "/usr/bin/skydive analyzer --conf /etc/skydive.yml" + skydive_agent_docker_image: {{skydive_agent_docker_image | regex_replace("[^/]*/([^:]*).*", "\1")}} + skydive_agent_docker_command: "/usr/bin/skydive agent --conf /etc/skydive.yml" + os_auth_url: {{overcloud_keystone_url}}/v3 + os_username: {{username}} + os_password: {{overcloud_admin_password}} + os_tenant_name: {{project_name}} + skydive_auth_type: keystone + skydive_os_auth_url: {{os_auth_url}}/v3 + skydive_os_service_region_name: {{os_region_name}} + skydive_deployment_mode: container + skydive_flow_protocol: websocket + skydive_topology_probes: + - neutron + - ovsdb + - docker + + - name: generate Skydive global vars + copy: + dest: "{{playbook_dir}}/skydive/global_vars.yml" + content: "{{skydive_vars.globals|default({})|to_nice_yaml}}" + + - name: generate inventory + copy: + dest: "{{playbook_dir}}/skydive/inventory.yml" + content: | + analyzers: + hosts: + {% for host in groups['skydive_analyzer'] -%} + {{hostvars.raw_get(host)['ansible_hostname']}}: + ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }} + ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }} + ansible_become: true + skydive_listen_ip: {{hostvars.raw_get(host)['ctlplane_ip']}} + {% if skydive_vars.analyzers is defined -%} + {{skydive_vars.analyzers|to_nice_yaml()|indent(6)}} + {%- endif %} + + {% endfor %} + + agents: + hosts: + {% for host in groups['skydive_agent'] -%} + {{hostvars.raw_get(host)['ansible_hostname']}}: + ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }} + ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }} + ansible_become: true + skydive_listen_ip: {{hostvars.raw_get(host)['ctlplane_ip']}} + {% if skydive_vars.agents is defined -%} + {{skydive_vars.agents|to_nice_yaml()|indent(6)}} + {%- endif %} + + {% endfor %} + + - name: write Skydive deploy script + copy: + content: > + #!/bin/bash + + set -e + + ANSIBLE_HOST_KEY_CHECKING=False + ansible-playbook + -i '{{playbook_dir}}/skydive/inventory.yml' + --extra-vars '@{{playbook_dir}}/skydive/global_defaults.yml' + --extra-vars '@{{playbook_dir}}/skydive/global_vars.yml' + '{{skydive_ansible_playbook}}' + dest: '{{playbook_dir}}/skydive/skydive-deploy.sh' + mode: 0700 + + - name: run skydive-deploy.sh (immediate log at {{playbook_dir}}/skydive/playbook.log) + shell: | + {{playbook_dir}}/skydive/skydive-deploy.sh 2>&1 | tee {{playbook_dir}}/skydive/playbook.log + exit ${PIPESTATUS[0]}