diff options
18 files changed, 380 insertions, 45 deletions
diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..d201b5c --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,18 @@ +- job: + name: heat-templates-check + parent: legacy-dsvm-base + run: playbooks/devstack/run.yaml + post-run: playbooks/devstack/post.yaml + timeout: 7500 + required-projects: + - openstack-infra/devstack-gate + - openstack/heat + - openstack/heat-templates + +- project: + check: + jobs: + - heat-templates-check + gate: + jobs: + - heat-templates-check diff --git a/hot/autoscaling.yaml b/hot/autoscaling.yaml index 312a7a0..d6d8991 100644 --- a/hot/autoscaling.yaml +++ b/hot/autoscaling.yaml @@ -1,4 +1,4 @@ -heat_template_version: 2013-05-23 +heat_template_version: 2016-10-14 description: AutoScaling Wordpress parameters: image: @@ -75,6 +75,7 @@ resources: image: {get_param: image} key_name: {get_param: key} network: {get_param: network} + subnet: {get_param: subnet_id} pool_id: {get_resource: pool} metadata: {"metering.server_group": {get_param: "OS::stack_id"}} user_data: @@ -128,7 +129,7 @@ resources: - str_replace: template: trust+url params: - url: {get_attr: [scaleup_policy, signal_url]} + url: {get_attr: [web_server_scaleup_policy, signal_url]} query: list_join: - '' @@ -148,40 +149,44 @@ resources: - str_replace: template: trust+url params: - url: {get_attr: [scaleup_policy, signal_url]} + url: {get_attr: [web_server_scaledown_policy, signal_url]} query: list_join: - '' - - {'=': {server_group: {get_param: "OS::stack_id"}}} - monitor: - type: OS::Neutron::HealthMonitor + lb: + type: OS::Neutron::LBaaS::LoadBalancer properties: - type: TCP - delay: 5 - max_retries: 5 - timeout: 5 + vip_subnet: {get_param: subnet_id} + listener: + type: OS::Neutron::LBaaS::Listener + properties: + loadbalancer: {get_resource: lb} + protocol: HTTP + protocol_port: 80 pool: - type: OS::Neutron::Pool + type: OS::Neutron::LBaaS::Pool properties: + listener: {get_resource: listener} + lb_algorithm: ROUND_ROBIN protocol: HTTP - monitors: [{get_resource: monitor}] - subnet_id: {get_param: subnet_id} - lb_method: ROUND_ROBIN - vip: - protocol_port: 80 - lb: - type: OS::Neutron::LoadBalancer + session_persistence: + type: SOURCE_IP + lb_monitor: + type: OS::Neutron::LBaaS::HealthMonitor properties: - protocol_port: 80 - pool_id: {get_resource: pool} - + pool: { get_resource: pool } + type: TCP + delay: 5 + max_retries: 5 + timeout: 5 # assign a floating ip address to the load balancer # pool. lb_floating: type: OS::Neutron::FloatingIP properties: floating_network_id: {get_param: external_network_id} - port_id: {get_attr: [pool, vip, port_id]} + port_id: {get_attr: [lb, vip_port_id]} outputs: scale_up_url: @@ -197,7 +202,7 @@ outputs: this URL; no body nor extra headers are needed. value: {get_attr: [web_server_scaledown_policy, alarm_url]} pool_ip_address: - value: {get_attr: [pool, vip, address]} + value: {get_attr: [lb, vip_address]} description: The IP address of the load balancing pool website_url: value: diff --git a/hot/condition.yaml b/hot/condition.yaml new file mode 100644 index 0000000..9f5e640 --- /dev/null +++ b/hot/condition.yaml @@ -0,0 +1,102 @@ +heat_template_version: 2017-02-24 +parameters: + env_type: + default: test + type: string + constraints: + - allowed_values: [prod, test] + zone: + type: string + default: beijing +conditions: + prod: {equals: [{get_param: env_type}, "prod"]} + test: + not: + equals: + - get_param: env_type + - prod + beijing_prod: + and: + - equals: + - get_param: zone + - beijing + - equals: + - get_param: env_type + - prod + xian_zone: + equals: + - get_param: zone + - xian + xianyang_zone: + equals: + - get_param: zone + - xianyang + fujian_zone: + or: + - equals: + - get_param: zone + - fuzhou + - equals: + - get_param: zone + - xiamen + fujian_prod: + and: + - fujian_zone + - prod + shannxi_province: + or: + - xian_zone + - xianyang_zone +resources: + test_res: + type: OS::Heat::TestResource + properties: + value: {if: ["prod", "env_is_prod", "env_is_test"]} + prod_res: + type: OS::Heat::TestResource + properties: + value: prod_res + condition: prod + test_res1: + type: OS::Heat::TestResource + properties: + value: just in test env + condition: test + beijing_prod_res: + type: OS::Heat::TestResource + properties: + value: beijing_prod_res + condition: beijing_prod + fujian_res: + type: OS::Heat::TestResource + condition: fujian_zone + properties: + value: fujian_res + fujian_prod_res: + type: OS::Heat::TestResource + condition: fujian_prod + properties: + value: fujian_prod_res + shannxi_res: + type: OS::Heat::TestResource + condition: shannxi_province + properties: + value: shannxi_res + not_shannxi_res: + type: OS::Heat::TestResource + condition: {not: shannxi_province} + properties: + value: not_shannxi_res +outputs: + res_value: + value: {get_attr: [prod_res, output]} + condition: prod + test_res_value: + value: {get_attr: [test_res, output]} + prod_resource: + value: {if: [prod, {get_resource: prod_res}, 'no_prod_res']} + test_res1_value: + value: {if: [test, {get_attr: [test_res1, output]}, 'no_test_res1']} + beijing_prod_res: + value: {if: [beijing_prod, {get_resource: beijing_prod_res}, + 'no_prod_res']} diff --git a/hot/external_resource.yaml b/hot/external_resource.yaml new file mode 100644 index 0000000..516e728 --- /dev/null +++ b/hot/external_resource.yaml @@ -0,0 +1,21 @@ +heat_template_version: newton + +description: > + This template shows use case for external resource. + external resource can be any resource (create by + heat or not) that heat got type for it. + +parameters: + external_server_id: + type: string + default: da5b940a-14ff-4884-8e95-5cf6a3a1028f + description: ID of external server + +resources: + external_server: + type: OS::Nova::Server + external_id: { get_param: external_server_id } + +outputs: + server_address: + value: { get_attr: [external_server, networks, private, 0 ] } diff --git a/hot/lb_server.yaml b/hot/lb_server.yaml index 3cd907f..67762b6 100644 --- a/hot/lb_server.yaml +++ b/hot/lb_server.yaml @@ -1,4 +1,4 @@ -heat_template_version: 2013-05-23 +heat_template_version: 2016-10-14 description: A load-balancer server parameters: image: @@ -21,6 +21,9 @@ parameters: network: type: string description: Network used by the server + subnet: + type: string + description: Subnet used by the server resources: server: @@ -34,11 +37,12 @@ resources: user_data_format: RAW networks: [{network: {get_param: network} }] member: - type: OS::Neutron::PoolMember + type: OS::Neutron::LBaaS::PoolMember properties: - pool_id: {get_param: pool_id} + pool: {get_param: pool_id} address: {get_attr: [server, first_address]} protocol_port: 80 + subnet: {get_param: subnet} outputs: server_ip: diff --git a/hot/magnum/create_coe_cluster.yaml b/hot/magnum/create_coe_cluster.yaml new file mode 100644 index 0000000..0315cbd --- /dev/null +++ b/hot/magnum/create_coe_cluster.yaml @@ -0,0 +1,116 @@ +heat_template_version: pike + +description: > + This template demostrates how to create Magnum COE cluster. + +parameters: + cluster_name: + type: string + description: (optional) Name for cluster. + default: coe_cluster + node_count: + type: number + default: 1 + description: The node count for this cluster. + master_count: + type: number + default: 1 + description: The number of master nodes for this cluster. + create_timeout: + type: number + default: 60 + description: Timeout for creating the cluster in minutes. + cluster_template_name: + type: string + description: (optional) Name for cluster. + default: coe_cluster_template + keypair: + type: string + default: key + constraints: + - custom_constraint: nova.keypair + flavor: + type: string + description: Flavor for the COE nodes to be created + default: m1.small + constraints: + - custom_constraint: nova.flavor + master_flavor: + type: string + description: Flavor for the COE masters to be created + default: m1.small + constraints: + - custom_constraint: nova.flavor + image: + type: string + description: Image ID or image name to use for the COE nodes/masters + constraints: + - custom_constraint: glance.image + external_network: + type: string + description: The external neutron network to attach the Cluster + constraints: + - custom_constraint: neutron.network + coe: + type: string + description: The Container Orchestration Engine for cluster + default: kubernetes + server_type: + type: string + description: Specify the server type to be used + default: vm + registry_enabled: + type: boolean + description: Enable the docker registry + default: False + master_lb_enabled: + type: boolean + description: clusters should have a load balancer for master nodes or not + default: False + floating_ip_enabled: + type: boolean + description: clusters should have a floating ip for master nodes or not + default: False + +resources: + coe_cluster: + type: OS::Magnum::Cluster + properties: + name: { get_param: cluster_name } + cluster_template: { get_resource: coe_cluster_template } + keypair: { get_param: keypair } + node_count: { get_param: node_count } + master_count: { get_param: master_count } + create_timeout: { get_param: create_timeout } + + coe_cluster_template: + type: OS::Magnum::ClusterTemplate + properties: + name: { get_param: cluster_template_name } + flavor: { get_param: flavor } + keypair: { get_param: keypair } + master_flavor: { get_param: master_flavor } + image: { get_param: image } + external_network: { get_param: external_network } + coe: { get_param: coe } + server_type: { get_param: server_type } + registry_enabled: { get_param: registry_enabled } + master_lb_enabled: { get_param: master_lb_enabled } + floating_ip_enabled: { get_param: floating_ip_enabled } + +outputs: + coe_api_address: + description: The endpoint URL of COE API exposed to end-users + value: { get_attr: [coe_cluster, api_address] } + coe_stack: + description: The reference UUID of orchestration stack for the COE cluster + value: { get_attr: [coe_cluster, stack_id] } + coe_discovery_url: + description: The custom discovery url for node discovery. + value: { get_attr: [coe_cluster, discovery_url] } + container_version: + description: Version info of container environment. + value: { get_attr: [coe_cluster, container_version] } + coe_version: + description: Version info of chosen COE. + value: { get_attr: [coe_cluster, coe_version] } diff --git a/hot/software-config/example-templates/cirros-example/init.d/heat-deploy-hook b/hot/software-config/example-templates/cirros-example/init.d/heat-deploy-hook index e063e09..daa592f 100755 --- a/hot/software-config/example-templates/cirros-example/init.d/heat-deploy-hook +++ b/hot/software-config/example-templates/cirros-example/init.d/heat-deploy-hook @@ -16,18 +16,18 @@ USER_ID=$(cat $OSC_DATA_PATH/user_id) AUTH_URL=$(cat $OSC_DATA_PATH/auth_url) PROJECT_ID=$(cat $OSC_DATA_PATH/project_id) -# Get a token and de-jsonify the response -# FIXME currently this only works with v2 keystone -V2_JSON='{"auth": {"tenantId": "'$PROJECT_ID'", "passwordCredentials": {"userId": "'$USER_ID'", "password": "'$PASSWORD'"}}}' -curl -i -d "$V2_JSON" -H "Content-type: application/json" $AUTH_URL/tokens | grep "^{" > ${TMPDIR}/token_json.json +# Get a token and de-jsonify the response, only supports keystone v3 +V3_JSON='{"auth": {"identity": {"methods": ["password"], "password": {"user": {"id": "'$USER_ID'", "password": "'$PASSWORD'"}}}, "scope": {"project": {"id": "'$PROJECT_ID'"}}}}' +curl -i -d "$V3_JSON" -H "Content-type: application/json" $AUTH_URL/auth/tokens > ${TMPDIR}/token.json +TOKEN=$(grep 'X-Subject-Token' ${TMPDIR}/token.json | awk '{print $2}') mkdir -p ${TMPDIR}/token_data_out -json2fstree ${TMPDIR}/token_data_out ${TMPDIR}/token_json.json -TOKEN=$(cat ${TMPDIR}/token_data_out/access/token/id) +grep "^{" ${TMPDIR}/token.json > ${TMPDIR}/token_body.json +json2fstree ${TMPDIR}/token_data_out ${TMPDIR}/token_body.json # Locate the heat API endpoint from the token response -SC_DIR=$(grep -r orchestration ${TMPDIR}/token_data_out/access/serviceCatalog/ | sed "s/\/type:orchestration//") -SC_PUBURL=$(find $SC_DIR -name publicURL) -SC_ENDPOINT=$(cat $SC_PUBURL) +SC_DIR=$(grep -r orchestration ${TMPDIR}/token_data_out/token/catalog | sed "s/\/type:orchestration//") +SC_PUBURL=$(grep -r public ${SC_DIR} | sed "s/\/interface:public//") +SC_ENDPOINT=$(cat ${SC_PUBURL}/url) # Get resource metadata and decode it with json2fstree STACK_ID=$(cat $OSC_DATA_PATH/stack_id) diff --git a/openshift-origin/F19/aws-template/openshift.template b/openshift-origin/F19/aws-template/openshift.template index b253e83..edca844 100644 --- a/openshift-origin/F19/aws-template/openshift.template +++ b/openshift-origin/F19/aws-template/openshift.template @@ -63,7 +63,7 @@ "Type": "String" }, "PrivateNetworkName": { - "Description": "Name of the private network wich will be created", + "Description": "Name of the private network which will be created", "Type": "String", "Default": "OpenShift-Network" }, diff --git a/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/nodeinstance.yaml b/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/nodeinstance.yaml index a65e47f..32ce5ec 100644 --- a/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/nodeinstance.yaml +++ b/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/nodeinstance.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/openshift.yaml b/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/openshift.yaml index 769669b..c84c6aa 100644 --- a/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/openshift.yaml +++ b/openshift-origin/F19/hot-template/openshift-scalable-cpu-nbgears/openshift.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/openshift-origin/F19/hot-template/openshift-scalable-cpu/nodeinstance.yaml b/openshift-origin/F19/hot-template/openshift-scalable-cpu/nodeinstance.yaml index a65e47f..32ce5ec 100644 --- a/openshift-origin/F19/hot-template/openshift-scalable-cpu/nodeinstance.yaml +++ b/openshift-origin/F19/hot-template/openshift-scalable-cpu/nodeinstance.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/openshift-origin/F19/hot-template/openshift-scalable-cpu/openshift.yaml b/openshift-origin/F19/hot-template/openshift-scalable-cpu/openshift.yaml index fef5b7c..d881b67 100644 --- a/openshift-origin/F19/hot-template/openshift-scalable-cpu/openshift.yaml +++ b/openshift-origin/F19/hot-template/openshift-scalable-cpu/openshift.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/openshift-origin/F19/hot-template/openshift-scalable-nbgears/nodeinstance.yaml b/openshift-origin/F19/hot-template/openshift-scalable-nbgears/nodeinstance.yaml index e3fcd66..e4a68b1 100644 --- a/openshift-origin/F19/hot-template/openshift-scalable-nbgears/nodeinstance.yaml +++ b/openshift-origin/F19/hot-template/openshift-scalable-nbgears/nodeinstance.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/openshift-origin/F19/hot-template/openshift-scalable-nbgears/openshift.yaml b/openshift-origin/F19/hot-template/openshift-scalable-nbgears/openshift.yaml index d015194..1229136 100644 --- a/openshift-origin/F19/hot-template/openshift-scalable-nbgears/openshift.yaml +++ b/openshift-origin/F19/hot-template/openshift-scalable-nbgears/openshift.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/openshift-origin/F19/hot-template/openshift/openshift.yaml b/openshift-origin/F19/hot-template/openshift/openshift.yaml index e57838f..f1a9d5d 100644 --- a/openshift-origin/F19/hot-template/openshift/openshift.yaml +++ b/openshift-origin/F19/hot-template/openshift/openshift.yaml @@ -43,7 +43,7 @@ parameters: description: External network ID type: string private_network_name: - description: Name of the private network wich will be created + description: Name of the private network which will be created type: string default: OpenShift-Network private_network_cidr: diff --git a/playbooks/devstack/post.yaml b/playbooks/devstack/post.yaml new file mode 100644 index 0000000..e07f551 --- /dev/null +++ b/playbooks/devstack/post.yaml @@ -0,0 +1,15 @@ +- hosts: primary + tasks: + + - name: Copy files from {{ ansible_user_dir }}/workspace/ on node + synchronize: + src: '{{ ansible_user_dir }}/workspace/' + dest: '{{ zuul.executor.log_root }}' + mode: pull + copy_links: true + verify_host: true + rsync_opts: + - --include=/logs/** + - --include=*/ + - --exclude=* + - --prune-empty-dirs diff --git a/playbooks/devstack/run.yaml b/playbooks/devstack/run.yaml new file mode 100644 index 0000000..0e9bd33 --- /dev/null +++ b/playbooks/devstack/run.yaml @@ -0,0 +1,54 @@ +- hosts: all + name: job for templates-devstack + tasks: + + - name: Ensure legacy workspace directory + file: + path: '{{ ansible_user_dir }}/workspace' + state: directory + + - shell: + cmd: | + set -e + set -x + cat > clonemap.yaml << EOF + clonemap: + - name: openstack-infra/devstack-gate + dest: devstack-gate + EOF + /usr/zuul-env/bin/zuul-cloner -m clonemap.yaml --cache-dir /opt/git \ + git://git.openstack.org \ + openstack-infra/devstack-gate + executable: /bin/bash + chdir: '{{ ansible_user_dir }}/workspace' + environment: '{{ zuul | zuul_legacy_vars }}' + + - shell: + cmd: | + set -e + set -x + cat << 'EOF' >>"/tmp/dg-local.conf" + [[local|localrc]] + enable_plugin heat git://git.openstack.org/openstack/heat + EOF + executable: /bin/bash + chdir: '{{ ansible_user_dir }}/workspace' + environment: '{{ zuul | zuul_legacy_vars }}' + + - shell: + cmd: | + set -e + set -x + export PYTHONUNBUFFERED=true + export DEVSTACK_GATE_TEMPEST=0 + export DEVSTACK_GATE_EXERCISES=0 + function post_test_hook { + cd $BASE/new/heat-templates/tools + ./post_test_hook.sh + } + export -f post_test_hook + cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh + ./safe-devstack-vm-gate-wrap.sh + executable: /bin/bash + chdir: '{{ ansible_user_dir }}/workspace' + environment: '{{ zuul | zuul_legacy_vars }}' diff --git a/tools/validate-templates b/tools/validate-templates index 2ebb12a..59f9f1d 100755 --- a/tools/validate-templates +++ b/tools/validate-templates @@ -1,12 +1,11 @@ #!/usr/bin/env python import os -import re import subprocess import sys -EXCLUDED_DIRS = ('contrib', 'elements', 'invalid') +EXCLUDED_DIRS = ('contrib', 'elements', 'invalid', 'playbooks') def main(args): @@ -20,7 +19,8 @@ def main(args): if excluded in dirs: dirs.remove(excluded) for name in files: - if name.endswith((".yaml", ".template")): + if name.endswith((".yaml", ".template") + ) and not name == ".zuul.yaml": got_error = validate(root, name) or got_error sys.exit(int(got_error)) |