commit 275bfbad159428fce093bfcfbb9f69497c46e0b8 Author: Kevin Carter Date: Sat Feb 14 10:06:50 2015 -0600 Convert existing roles into galaxy roles This change implements the blueprint to convert all roles and plays into a more generic setup, following upstream ansible best practices. Items Changed: * All tasks have tags. * All roles use namespaced variables. * All redundant tasks within a given play and role have been removed. * All of the repetitive plays have been removed in-favor of a more simplistic approach. This change duplicates code within the roles but ensures that the roles only ever run within their own scope. * All roles have been built using an ansible galaxy syntax. * The `*requirement.txt` files have been reformatted follow upstream Openstack practices. * Dynamically generated inventory is now more organized, this should assist anyone who may want or need to dive into the JSON blob that is created. In the inventory a properties field is used for items that customize containers within the inventory. * The environment map has been modified to support additional host groups to enable the seperation of infrastructure pieces. While the old infra_hosts group will still work this change allows for groups to be divided up into seperate chunks; eg: deployment of a swift only stack. * The LXC logic now exists within the plays. * etc/openstack_deploy/user_variables.yml has all password/token variables extracted into the separate file etc/openstack_deploy/user_secrets.yml in order to allow seperate security settings on that file. Items Excised: * All of the roles have had the LXC logic removed from within them which should allow roles to be consumed outside of the `os-ansible-deployment` reference architecture. Note: * the directory rpc_deployment still exists and is presently pointed at plays containing a deprecation warning instructing the user to move to the standard playbooks directory. * While all of the rackspace specific components and variables have been removed and or were refactored the repository still relies on an upstream mirror of Openstack built python files and container images. This upstream mirror is hosted at rackspace at "http://rpc-repo.rackspace.com" though this is not locked to and or tied to rackspace specific installations. This repository contains all of the needed code to create and/or clone your own mirror. DocImpact Co-Authored-By: Jesse Pretorius Closes-Bug: #1403676 Implements: blueprint galaxy-roles Change-Id: I03df3328b7655f0cc9e43ba83b02623d038d214e diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..daf20da --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,85 @@ +OpenStack glance +################ +:tags: openstack, glance, cloud, ansible +:category: \*nix + +contributor guidelines +^^^^^^^^^^^^^^^^^^^^^^ + +Filing Bugs +----------- + +Bugs should be filed on Launchpad, not GitHub: "https://bugs.launchpad.net/openstack-ansible" + + +When submitting a bug, or working on a bug, please ensure the following criteria are met: + * The description clearly states or describes the original problem or root cause of the problem. + * Include historical information on how the problem was identified. + * Any relevant logs are included. + * The provided information should be totally self-contained. External access to web services/sites should not be needed. + * Steps to reproduce the problem if possible. + + +Submitting Code +--------------- + +Changes to the project should be submitted for review via the Gerrit tool, following +the workflow documented at: "http://docs.openstack.org/infra/manual/developers.html#development-workflow" + +Pull requests submitted through GitHub will be ignored and closed without regard. + + +Extra +----- + +Tags: + If it's a bug that needs fixing in a branch in addition to Master, add a '\-backport-potential' tag (eg ``juno-backport-potential``). There are predefined tags that will autocomplete. + +Status: + Please leave this alone, it should be New till someone triages the issue. + +Importance: + Should only be touched if it is a Blocker/Gating issue. If it is, please set to High, and only use Critical if you have found a bug that can take down whole infrastructures. + + +Style guide +----------- + +When creating tasks and other roles for use in Ansible please create then using the YAML dictionary format. + +Example YAML dictionary format: + .. code-block:: yaml + + - name: The name of the tasks + module_name: + thing1: "some-stuff" + thing2: "some-other-stuff" + tags: + - some-tag + - some-other-tag + + +Example **NOT** in YAML dictionary format: + .. code-block:: yaml + + - name: The name of the tasks + module_name: thing1="some-stuff" thing2="some-other-stuff" + tags: + - some-tag + - some-other-tag + + +Usage of the ">" and "|" operators should be limited to Ansible conditionals and command modules such as the ansible ``shell`` module. + + +Issues +------ + +When submitting an issue, or working on an issue please ensure the following criteria are met: + * The description clearly states or describes the original problem or root cause of the problem. + * Include historical information on how the problem was identified. + * Any relevant logs are included. + * If the issue is a bug that needs fixing in a branch other than Master, add the ‘backport potential’ tag TO THE ISSUE (not the PR). + * The provided information should be totally self-contained. External access to web services/sites should not be needed. + * If the issue is needed for a hotfix release, add the 'expedite' label. + * Steps to reproduce the problem if possible. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e06d208 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..050745c --- /dev/null +++ b/README.rst @@ -0,0 +1,26 @@ +OpenStack heat +############## +:tags: openstack, heat, cloud, ansible +:category: \*nix + +Role to install heat api, cfn, cloudwatch, and engine. + +This role will install the following: + * heat-api + * heat-api-cfn + * heat-api-cloudwatch + * heat-engine + +.. code-block:: yaml + + - name: Install heat server + hosts: heat_all + user: root + roles: + - { role: "os_heat", tags: [ "os-heat" ] } + vars: + external_lb_vip_address: 172.16.24.1 + internal_lb_vip_address: 192.168.0.1 + galera_address: "{{ internal_lb_vip_address }}" + keystone_admin_user_name: admin + keystone_admin_tenant_name: admin diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..9b06e3e --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,131 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The variables file used by the playbooks in the Heat-api group. +# These don't have to be explicitly imported by vars_files: they are autopopulated. + +# Defines that the role will be deployed on a host machine +is_metal: true + +## Verbosity Options +debug: False +verbose: True + +heat_client_endpoint: internalURL + +## DB +heat_galera_user: heat +heat_galera_database: heat + +## RPC +heat_rpc_backend: heat.openstack.common.rpc.impl_kombu + +## Heat User / Group +heat_system_user_name: heat +heat_system_group_name: heat +heat_system_comment: heat system user +heat_system_shell: /bin/false +heat_system_home_folder: "/var/lib/{{ heat_system_user_name }}" + +## Default domain +heat_project_domain_id: default +heat_project_name: admin +heat_user_domain_id: default + +## Stack +heat_stack_domain_admin: stack_domain_admin +heat_stack_owner_name: heat_stack_owner +heat_stack_domain_description: Owns users and projects created by heat +heat_stack_user_domain_name: heat +heat_stack_admin_user_name: admin +heat_stack_admin_tenant_name: admin +heat_deferred_auth_method: trusts + +## Auth +heat_service_tenant_name: "service" +heat_service_user_name: "heat" + +## Heat api service type and data +heat_service_name: heat +heat_service_role_name: admin +heat_service_region: RegionOne +heat_service_description: "Heat Orchestration Service" +heat_service_port: 8004 +heat_service_proto: http +heat_service_type: orchestration +heat_service_publicuri: "{{ heat_service_proto }}://{{ external_lb_vip_address }}:{{ heat_service_port }}" +heat_service_publicurl: "{{ heat_service_publicuri }}/v1/%(tenant_id)s" +heat_service_adminuri: "{{ heat_service_proto }}://{{ internal_lb_vip_address }}:{{ heat_service_port }}" +heat_service_adminurl: "{{ heat_service_adminuri }}/v1/%(tenant_id)s" +heat_service_internaluri: "{{ heat_service_proto }}://{{ internal_lb_vip_address }}:{{ heat_service_port }}" +heat_service_internalurl: "{{ heat_service_internaluri }}/v1/%(tenant_id)s" +heat_service_program_name: heat-api + +## Heat wait and metadata server +heat_waitcondition_server_uri: "{{ heat_service_proto }}://{{ external_lb_vip_address }}:{{ heat_cfn_service_port }}" +heat_waitcondition_server_url: "{{ heat_waitcondition_server_uri }}/v1/waitcondition" +heat_metadata_server_url: "{{ heat_service_proto }}://{{ internal_lb_vip_address }}:{{ heat_cfn_service_port }}" + +## Heat api cfn service type and data +heat_cfn_service_name: heat-cfn +heat_cfn_service_description: "Heat CloudFormation Service" +heat_cfn_service_port: 8000 +heat_cfn_service_proto: http +heat_cfn_service_type: cloudformation +heat_cfn_service_publicuri: "{{ heat_cfn_service_proto }}://{{ external_lb_vip_address }}:{{ heat_cfn_service_port }}" +heat_cfn_service_publicurl: "{{ heat_cfn_service_publicuri }}/v1" +heat_cfn_service_adminuri: "{{ heat_cfn_service_proto }}://{{ internal_lb_vip_address }}:{{ heat_cfn_service_port }}" +heat_cfn_service_adminurl: "{{ heat_cfn_service_adminuri }}/v1" +heat_cfn_service_internaluri: "{{ heat_cfn_service_proto }}://{{ internal_lb_vip_address }}:{{ heat_cfn_service_port }}" +heat_cfn_service_internalurl: "{{ heat_cfn_service_internaluri }}/v1" +heat_cfn_service_program_name: heat-api-cfn + +## Heat cloudwatch +heat_cloudwatch_program_name: heat-api-cloudwatch +heat_engine_program_name: heat-engine + +## Heat watch server +heat_watch_proto: http +heat_watch_port: 8003 +heat_watch_server_uri: "{{ heat_watch_proto }}://{{ external_lb_vip_address }}:{{ heat_watch_port }}" +heat_watch_server_url: "{{ heat_watch_server_uri }}" + +heat_apt_packages: + - rsync + - libxslt1.1 + +heat_pip_packages: + - keystonemiddleware + - MySQL-python + - python-memcached + - pycrypto + - python-ceilometerclient + - python-cinderclient + - python-glanceclient + - python-heatclient + - python-keystoneclient + - python-neutronclient + - python-novaclient + - python-openstackclient + - python-swiftclient + - python-troveclient + - heat + +## Service Names +heat_service_names: + - heat-api + - heat-api-cfn + - heat-api-cloudwatch + - heat-engine diff --git a/files/api-paste.ini b/files/api-paste.ini new file mode 100644 index 0000000..31a49e9 --- /dev/null +++ b/files/api-paste.ini @@ -0,0 +1,94 @@ +# heat-api pipeline +[pipeline:heat-api] +pipeline = faultwrap ssl versionnegotiation authurl authtoken context apiv1app + +# heat-api pipeline for standalone heat +# ie. uses alternative auth backend that authenticates users against keystone +# using username and password instead of validating token (which requires +# an admin/service token). +# To enable, in heat.conf: +# [paste_deploy] +# flavor = standalone +# +[pipeline:heat-api-standalone] +pipeline = faultwrap ssl versionnegotiation authurl authpassword context apiv1app + +# heat-api pipeline for custom cloud backends +# i.e. in heat.conf: +# [paste_deploy] +# flavor = custombackend +# +[pipeline:heat-api-custombackend] +pipeline = faultwrap versionnegotiation context custombackendauth apiv1app + +# heat-api-cfn pipeline +[pipeline:heat-api-cfn] +pipeline = cfnversionnegotiation ec2authtoken authtoken context apicfnv1app + +# heat-api-cfn pipeline for standalone heat +# relies exclusively on authenticating with ec2 signed requests +[pipeline:heat-api-cfn-standalone] +pipeline = cfnversionnegotiation ec2authtoken context apicfnv1app + +# heat-api-cloudwatch pipeline +[pipeline:heat-api-cloudwatch] +pipeline = versionnegotiation ec2authtoken authtoken context apicwapp + +# heat-api-cloudwatch pipeline for standalone heat +# relies exclusively on authenticating with ec2 signed requests +[pipeline:heat-api-cloudwatch-standalone] +pipeline = versionnegotiation ec2authtoken context apicwapp + +[app:apiv1app] +paste.app_factory = heat.common.wsgi:app_factory +heat.app_factory = heat.api.openstack.v1:API + +[app:apicfnv1app] +paste.app_factory = heat.common.wsgi:app_factory +heat.app_factory = heat.api.cfn.v1:API + +[app:apicwapp] +paste.app_factory = heat.common.wsgi:app_factory +heat.app_factory = heat.api.cloudwatch:API + +[filter:versionnegotiation] +paste.filter_factory = heat.common.wsgi:filter_factory +heat.filter_factory = heat.api.openstack:version_negotiation_filter + +[filter:faultwrap] +paste.filter_factory = heat.common.wsgi:filter_factory +heat.filter_factory = heat.api.openstack:faultwrap_filter + +[filter:cfnversionnegotiation] +paste.filter_factory = heat.common.wsgi:filter_factory +heat.filter_factory = heat.api.cfn:version_negotiation_filter + +[filter:cwversionnegotiation] +paste.filter_factory = heat.common.wsgi:filter_factory +heat.filter_factory = heat.api.cloudwatch:version_negotiation_filter + +[filter:context] +paste.filter_factory = heat.common.context:ContextMiddleware_filter_factory + +[filter:ec2authtoken] +paste.filter_factory = heat.api.aws.ec2token:EC2Token_filter_factory + +[filter:ssl] +paste.filter_factory = heat.common.wsgi:filter_factory +heat.filter_factory = heat.api.openstack:sslmiddleware_filter + +# Middleware to set auth_url header appropriately +[filter:authurl] +paste.filter_factory = heat.common.auth_url:filter_factory + +# Auth middleware that validates token against keystone +[filter:authtoken] +paste.filter_factory = keystonemiddleware.auth_token:filter_factory + +# Auth middleware that validates username/password against keystone +[filter:authpassword] +paste.filter_factory = heat.common.auth_password:filter_factory + +# Auth middleware that validates against custom backend +[filter:custombackendauth] +paste.filter_factory = heat.common.custom_backend_auth:filter_factory diff --git a/files/environment.d/default.yaml b/files/environment.d/default.yaml new file mode 100644 index 0000000..388f37a --- /dev/null +++ b/files/environment.d/default.yaml @@ -0,0 +1,8 @@ +resource_registry: + # allow older templates with Quantum in them. + "OS::Quantum*": "OS::Neutron*" + # Choose your implementation of AWS::CloudWatch::Alarm + #"AWS::CloudWatch::Alarm": "file:///etc/heat/templates/AWS_CloudWatch_Alarm.yaml" + "AWS::CloudWatch::Alarm": "OS::Heat::CWLiteAlarm" + "OS::Metering::Alarm": "OS::Ceilometer::Alarm" + "AWS::RDS::DBInstance": "file:///etc/heat/templates/AWS_RDS_DBInstance.yaml" diff --git a/files/policy.json b/files/policy.json new file mode 100644 index 0000000..e3e8822 --- /dev/null +++ b/files/policy.json @@ -0,0 +1,64 @@ +{ + "context_is_admin": "role:admin", + "deny_stack_user": "not role:heat_stack_user", + "deny_everybody": "!", + + "cloudformation:ListStacks": "rule:deny_stack_user", + "cloudformation:CreateStack": "rule:deny_stack_user", + "cloudformation:DescribeStacks": "rule:deny_stack_user", + "cloudformation:DeleteStack": "rule:deny_stack_user", + "cloudformation:UpdateStack": "rule:deny_stack_user", + "cloudformation:DescribeStackEvents": "rule:deny_stack_user", + "cloudformation:ValidateTemplate": "rule:deny_stack_user", + "cloudformation:GetTemplate": "rule:deny_stack_user", + "cloudformation:EstimateTemplateCost": "rule:deny_stack_user", + "cloudformation:DescribeStackResource": "", + "cloudformation:DescribeStackResources": "rule:deny_stack_user", + "cloudformation:ListStackResources": "rule:deny_stack_user", + + "cloudwatch:DeleteAlarms": "rule:deny_stack_user", + "cloudwatch:DescribeAlarmHistory": "rule:deny_stack_user", + "cloudwatch:DescribeAlarms": "rule:deny_stack_user", + "cloudwatch:DescribeAlarmsForMetric": "rule:deny_stack_user", + "cloudwatch:DisableAlarmActions": "rule:deny_stack_user", + "cloudwatch:EnableAlarmActions": "rule:deny_stack_user", + "cloudwatch:GetMetricStatistics": "rule:deny_stack_user", + "cloudwatch:ListMetrics": "rule:deny_stack_user", + "cloudwatch:PutMetricAlarm": "rule:deny_stack_user", + "cloudwatch:PutMetricData": "", + "cloudwatch:SetAlarmState": "rule:deny_stack_user", + + "actions:action": "rule:deny_stack_user", + "build_info:build_info": "rule:deny_stack_user", + "events:index": "rule:deny_stack_user", + "events:show": "rule:deny_stack_user", + "resource:index": "rule:deny_stack_user", + "resource:metadata": "", + "resource:signal": "", + "resource:show": "rule:deny_stack_user", + "stacks:abandon": "rule:deny_stack_user", + "stacks:create": "rule:deny_stack_user", + "stacks:delete": "rule:deny_stack_user", + "stacks:detail": "rule:deny_stack_user", + "stacks:generate_template": "rule:deny_stack_user", + "stacks:global_index": "rule:deny_everybody", + "stacks:index": "rule:deny_stack_user", + "stacks:list_resource_types": "rule:deny_stack_user", + "stacks:lookup": "", + "stacks:preview": "rule:deny_stack_user", + "stacks:resource_schema": "rule:deny_stack_user", + "stacks:show": "rule:deny_stack_user", + "stacks:template": "rule:deny_stack_user", + "stacks:update": "rule:deny_stack_user", + "stacks:validate_template": "rule:deny_stack_user", + + "software_configs:create": "rule:deny_stack_user", + "software_configs:show": "rule:deny_stack_user", + "software_configs:delete": "rule:deny_stack_user", + "software_deployments:index": "rule:deny_stack_user", + "software_deployments:create": "rule:deny_stack_user", + "software_deployments:show": "rule:deny_stack_user", + "software_deployments:update": "rule:deny_stack_user", + "software_deployments:delete": "rule:deny_stack_user", + "software_deployments:metadata": "" +} diff --git a/files/templates/AWS_CloudWatch_Alarm.yaml b/files/templates/AWS_CloudWatch_Alarm.yaml new file mode 100644 index 0000000..e21e500 --- /dev/null +++ b/files/templates/AWS_CloudWatch_Alarm.yaml @@ -0,0 +1,86 @@ +HeatTemplateFormatVersion: '2012-12-12' +Description: AWS::CloudWatch::Alarm using Ceilometer. +Parameters: + AlarmDescription: + Type: String + Default: An alarm + EvaluationPeriods: + Type: String + MetricName: + Type: String + Namespace: + Type: String + Default: system/linux + Period: + Type: String + ComparisonOperator: + Type: String + AllowedValues: [GreaterThanOrEqualToThreshold, GreaterThanThreshold, + LessThanThreshold, LessThanOrEqualToThreshold] + Statistic: + Type: String + AllowedValues: [SampleCount, Average, Sum, Minimum, Maximum] + Threshold: + Type: String + Units: + Type: String + AllowedValues: [Seconds, Microseconds, Milliseconds, Bytes, Kilobytes, + Megabytes, Gigabytes, Terabytes, Bits, Kilobits, Megabits, + Gigabits, Terabits, Percent, Count, Bytes/Second, + Kilobytes/Second, Megabytes/Second, Gigabytes/Second, + Terabytes/Second, Bits/Second, Kilobits/Second, + Megabits/Second, Gigabits/Second, Terabits/Second, + Count/Second, None] + Default: None + AlarmActions: + Type: CommaDelimitedList + Default: '' + OKActions: + Type: CommaDelimitedList + Default: '' + InsufficientDataActions: + Type: CommaDelimitedList + Default: '' + Dimensions: + Type: CommaDelimitedList + +Mappings: + ComparisonOperatorMap: + LessThanOrEqualToThreshold: {Ceilometer: le} + LessThanThreshold: {Ceilometer: lt} + GreaterThanThreshold: {Ceilometer: gt} + GreaterThanOrEqualToThreshold: {Ceilometer: ge} + StatisticMap: + SampleCount: {Ceilometer: count} + Average: {Ceilometer: avg} + Sum: {Ceilometer: sum} + Minimum: {Ceilometer: min} + Maximum: {Ceilometer: max} + +Resources: + __alarm__: + Type: OS::Ceilometer::Alarm + Properties: + description: + Ref: AlarmDescription + meter_name: + Ref: MetricName + period: + Ref: Period + evaluation_periods: + Ref: EvaluationPeriods + repeat_actions: true + threshold: + Ref: Threshold + alarm_actions: + Ref: AlarmActions + ok_actions: + Ref: OKActions + insufficient_data_actions: + Ref: InsufficientDataActions + statistic: + "Fn::FindInMap": [StatisticMap, {Ref: Statistic}, Ceilometer] + comparison_operator: + "Fn::FindInMap": [ComparisonOperatorMap, {Ref: ComparisonOperator}, Ceilometer] + matching_metadata: + "Fn::MemberListToMap": [Name, Value, {Ref: Dimensions}] diff --git a/files/templates/AWS_RDS_DBInstance.yaml b/files/templates/AWS_RDS_DBInstance.yaml new file mode 100644 index 0000000..3017344 --- /dev/null +++ b/files/templates/AWS_RDS_DBInstance.yaml @@ -0,0 +1,127 @@ +HeatTemplateFormatVersion: '2012-12-12' +Description: 'Builtin AWS::RDS::DBInstance' +Parameters: + AllocatedStorage: + Type: String + DBInstanceClass: + Type: String + DBName: + Type: String + DBSecurityGroups: + Type: CommaDelimitedList + Default: '' + Engine: + Type: String + AllowedValues: ['MySQL'] + MasterUsername: + Type: String + MasterUserPassword: + Type: String + Port: + Type: String + Default: '3306' + KeyName: + Type: String + Default: '' + +Mappings: + DBInstanceToInstance: + db.m1.small: {Instance: m1.small} + db.m1.large: {Instance: m1.large} + db.m1.xlarge: {Instance: m1.xlarge} + db.m2.xlarge: {Instance: m2.xlarge} + db.m2.2xlarge: {Instance: m2.2xlarge} + db.m2.4xlarge: {Instance: m2.4xlarge} + +Resources: + ServerSecurityGroup: + Type: AWS::EC2::SecurityGroup + Properties: + GroupDescription: 'Enable SSH access' + SecurityGroupIngress: + - IpProtocol: icmp + FromPort: '-1' + ToPort: '-1' + CidrIp: '0.0.0.0/0' + - IpProtocol: tcp + FromPort: '22' + ToPort : '22' + CidrIp : '0.0.0.0/0' + - IpProtocol: tcp + FromPort: {Ref: Port} + ToPort : {Ref: Port} + CidrIp : '0.0.0.0/0' + DatabaseInstance: + Type: AWS::EC2::Instance + Metadata: + AWS::CloudFormation::Init: + config: + files: + /tmp/db_setup.sql: + content: + 'Fn::Replace': + - DBName: {Ref: DBName} + MasterUserPassword: {Ref: MasterUserPassword} + MasterUsername: {Ref: MasterUsername} + - | + CREATE DATABASE DBName; + GRANT ALL PRIVILEGES ON DBName.* TO "MasterUsername"@"%" + IDENTIFIED BY "MasterUserPassword"; + FLUSH PRIVILEGES; + EXIT + mode: '000644' + owner: root + group: root + packages: + yum: + mariadb: [] + mariadb-server: [] + services: + systemd: + mysqld: + enabled: true + ensureRunning: true + Properties: + ImageId: F19-x86_64-cfntools + InstanceType: {'Fn::FindInMap': [DBInstanceToInstance, + {Ref: DBInstanceClass}, Instance]} + KeyName: {Ref: KeyName} + SecurityGroups: [{"Ref" : "ServerSecurityGroup"}] + UserData: + Fn::Base64: + Fn::Replace: + - 'AWS::StackName': {Ref: 'AWS::StackName'} + 'AWS::Region': {Ref: 'AWS::Region'} + MasterUserPassword: {Ref: MasterUserPassword} + WaitHandle: {Ref: WaitHandle} + - | + #!/bin/bash -v + # + iptables -F + + # Helper function + function error_exit + { + /opt/aws/bin/cfn-signal -e 1 -r \"$1\" 'WaitHandle' + exit 1 + } + /opt/aws/bin/cfn-init -s AWS::StackName -r DatabaseInstance --region AWS::Region || error_exit 'Failed to run cfn-init' + # Setup MySQL root password and create a user + mysqladmin -u root password 'MasterUserPassword' + mysql -u root --password='MasterUserPassword' < /tmp/db_setup.sql || error_exit 'Failed to setup mysql' + + # Database setup completed, signal success + /opt/aws/bin/cfn-signal -e 0 -r "MySQL server setup complete" 'WaitHandle' + + WaitHandle: + Type: AWS::CloudFormation::WaitConditionHandle + WaitCondition: + Type: AWS::CloudFormation::WaitCondition + DependsOn: DatabaseInstance + Properties: + Handle: {Ref: WaitHandle} + Timeout: "600" + +Outputs: + Endpoint.Address: {'Fn::GetAtt': [DatabaseInstance, PublicIp]} + Endpoint.Port: {Ref: Port} diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..1ca13a9 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,22 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Restart heat services + service: + name: "{{ item }}" + state: restarted + pattern: "{{ item }}" + with_items: heat_service_names + failed_when: false diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..5166663 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,35 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +galaxy_info: + author: rcbops + description: Installation and setup of heat + company: Rackspace + license: Apache2 + min_ansible_version: 1.6.6 + platforms: + - name: Ubuntu + versions: + - trusty + categories: + - cloud + - python + - heat + - development + - openstack +dependencies: + - galera_client + - openstack_openrc + - pip_lock_down diff --git a/tasks/heat_db_setup.yml b/tasks/heat_db_setup.yml new file mode 100644 index 0000000..022e720 --- /dev/null +++ b/tasks/heat_db_setup.yml @@ -0,0 +1,48 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Create DB for service + mysql_db: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ galera_address }}" + name: "{{ heat_galera_database }}" + state: "present" + tags: + - heat-db-setup + +- name: Grant access to the DB for the service + mysql_user: + login_user: "{{ galera_root_user }}" + login_password: "{{ galera_root_password }}" + login_host: "{{ galera_address }}" + name: "{{ heat_galera_user }}" + password: "{{ heat_container_mysql_password }}" + host: "{{ item }}" + state: "present" + priv: "{{ heat_galera_database }}.*:ALL" + with_items: + - "localhost" + - "%" + tags: + - heat-db-setup + +- name: Perform a heat DB sync + command: heat-manage db_sync + sudo: yes + sudo_user: "{{ heat_system_user_name }}" + tags: + - heat-db-sync + - heat-setup diff --git a/tasks/heat_domain_setup.yml b/tasks/heat_domain_setup.yml new file mode 100644 index 0000000..69aecd6 --- /dev/null +++ b/tasks/heat_domain_setup.yml @@ -0,0 +1,149 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This is the role assigned to users created within Heat stacks themselves +- name: Ensure stack_user role + keystone: + command: "ensure_role" + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + role_name: "heat_stack_user" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-domain + - heat-domain-role + - heat-domain-setup + - heat-config + +- name: check for heat domain + shell: | + . {{ ansible_env.HOME }}/openrc + openstack --os-identity-api-version=3 \ + --os-auth-url={{ keystone_service_adminurl_v3 }} \ + --os-project-name={{ heat_project_name }} \ + --os-project-domain-id={{ heat_project_domain_id }} \ + --os-user-domain-id={{ heat_user_domain_id }} \ + domain \ + show \ + "{{ heat_stack_user_domain_name }}" | grep -w "{{ heat_stack_user_domain_name }}" + failed_when: false + changed_when: stack_user_domain.rc == 1 + register: stack_user_domain + tags: + - heat-domain + - heat-domain-setup + - heat-config + +- name: Create heat domain + shell: | + . {{ ansible_env.HOME }}/openrc + openstack --os-identity-api-version=3 \ + --os-auth-url={{ keystone_service_adminurl_v3 }} \ + --os-project-name={{ heat_project_name }} \ + --os-project-domain-id={{ heat_project_domain_id }} \ + --os-user-domain-id={{ heat_user_domain_id }} \ + domain \ + create \ + --description "{{ heat_stack_domain_description }}" \ + "{{ heat_stack_user_domain_name }}" + when: stack_user_domain.rc == 1 + tags: + - heat-domain + - heat-domain-setup + - heat-config + +- name: Check for heat user + shell: | + . {{ ansible_env.HOME }}/openrc + openstack --os-identity-api-version=3 \ + --os-auth-url={{ keystone_service_adminurl_v3 }} \ + --os-project-name={{ heat_project_name }} \ + --os-project-domain-id={{ heat_project_domain_id }} \ + --os-user-domain-id={{ heat_user_domain_id }} \ + user \ + list | grep -w "{{ heat_stack_domain_admin }}" + failed_when: false + changed_when: stack_user.rc == 1 + register: stack_user + tags: + - heat-domain + - heat-domain-setup + - heat-config + +- name: Create heat domain admin user + shell: | + . {{ ansible_env.HOME }}/openrc + openstack --os-identity-api-version=3 \ + --os-auth-url={{ keystone_service_adminurl_v3 }} \ + --os-project-name={{ heat_project_name }} \ + --os-project-domain-id={{ heat_project_domain_id }} \ + --os-user-domain-id={{ heat_user_domain_id }} \ + user \ + create \ + --domain {{ heat_stack_user_domain_name }} \ + --password {{ heat_stack_domain_admin_password }} \ + "{{ heat_stack_domain_admin }}" + when: stack_user.rc == 1 + tags: + - heat-domain + - heat-domain-setup + - heat-config + +- name: Retrieve heat domain id + shell: | + . {{ ansible_env.HOME }}/openrc + openstack --os-identity-api-version=3 \ + --os-auth-url={{ keystone_service_adminurl_v3 }} \ + --os-project-name={{ heat_project_name }} \ + --os-project-domain-id={{ heat_project_domain_id }} \ + --os-user-domain-id={{ heat_user_domain_id }} \ + domain \ + show \ + {{ heat_stack_user_domain_name }} | grep -oE -m 1 "[0-9a-f]{32}" + register: stack_user_domain_id + tags: + - heat-domain + - heat-domain-setup + - heat-config + +- name: Set fact for heat domain id + set_fact: + stack_user_domain_id: "{{ stack_user_domain_id.stdout }}" + tags: + - heat-domain + - heat-domain-setup + - heat-config + +- name: Assign admin role to heat domain admin user + shell: | + . {{ ansible_env.HOME }}/openrc + openstack --os-identity-api-version=3 \ + --os-auth-url={{ keystone_service_adminurl_v3 }} \ + --os-project-name={{ heat_project_name }} \ + --os-project-domain-id={{ heat_project_domain_id }} \ + --os-user-domain-id={{ heat_user_domain_id }} \ + role \ + add \ + --user {{ heat_stack_domain_admin }} \ + --domain {{ stack_user_domain_id }} \ + admin + tags: + - heat-domain + - heat-domain-setup + - heat-config + diff --git a/tasks/heat_install.yml b/tasks/heat_install.yml new file mode 100644 index 0000000..99f6f4c --- /dev/null +++ b/tasks/heat_install.yml @@ -0,0 +1,41 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Install apt packages + apt: + pkg: "{{ item }}" + state: latest + update_cache: yes + cache_valid_time: 600 + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: heat_apt_packages + tags: + - heat-apt-packages + +- name: Install pip packages + pip: + name: "{{ item }}" + state: present + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: + - "{{ heat_pip_packages }}" + tags: + - heat-pip-packages diff --git a/tasks/heat_post_install.yml b/tasks/heat_post_install.yml new file mode 100644 index 0000000..1b7a38c --- /dev/null +++ b/tasks/heat_post_install.yml @@ -0,0 +1,44 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Generate heat Config + template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: "{{ heat_system_user_name }}" + group: "{{ heat_system_group_name }}" + with_items: + - { src: "heat.conf.j2", dest: "/etc/heat/heat.conf" } + notify: + - Restart heat services + tags: + - heat-config + +- name: Drop heat Configs + copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + owner: "{{ heat_system_user_name }}" + group: "{{ heat_system_group_name }}" + with_items: + - { src: "api-paste.ini", dest: "/etc/heat/api-paste.ini" } + - { src: "environment.d/default.yaml", dest: "/etc/heat/environment.d/default.yaml" } + - { src: "policy.json", dest: "/etc/heat/policy.json" } + - { src: "templates/AWS_CloudWatch_Alarm.yaml", dest: "/etc/heat/templates/AWS_CloudWatch_Alarm.yaml" } + - { src: "templates/AWS_RDS_DBInstance.yaml", dest: "/etc/heat/templates/AWS_RDS_DBInstance.yaml" } + notify: + - Restart heat services + tags: + - heat-config diff --git a/tasks/heat_pre_install.yml b/tasks/heat_pre_install.yml new file mode 100644 index 0000000..f6683b5 --- /dev/null +++ b/tasks/heat_pre_install.yml @@ -0,0 +1,79 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: create the system group + group: + name: "{{ heat_system_group_name }}" + state: "present" + system: "yes" + tags: + - heat-group + +- name: Create the heat system user + user: + name: "{{ heat_system_user_name }}" + group: "{{ heat_system_group_name }}" + comment: "{{ heat_system_comment }}" + shell: "{{ heat_system_shell }}" + system: "yes" + createhome: "yes" + home: "/var/lib/{{ heat_system_user_name }}" + tags: + - heat-user + +- name: Create heat dir + file: + path: "{{ item.path }}" + state: directory + owner: "{{ item.owner|default(heat_system_user_name) }}" + group: "{{ item.group|default(heat_system_group_name) }}" + with_items: + - { path: "/etc/heat" } + - { path: "/etc/heat/environment.d" } + - { path: "/etc/heat/templates" } + - { path: "/etc/sudoers.d", mode: "0750", owner: "root", group: "root" } + - { path: "/var/cache/heat" } + - { path: "{{ heat_system_home_folder }}" } + tags: + - heat-dirs + +- name: Test for log directory or link + shell: | + if [ -h "/var/log/heat" ]; then + chown -h {{ heat_system_user_name }}:{{ heat_system_group_name }} "/var/log/heat" + chown -R {{ heat_system_user_name }}:{{ heat_system_group_name }} "$(readlink /var/log/heat)" + else + exit 1 + fi + register: log_dir + failed_when: false + changed_when: log_dir.rc != 0 + tags: + - heat-dirs + - heat-logs + +- name: Create heat log dir + file: + path: "{{ item.path }}" + state: directory + owner: "{{ item.owner|default(heat_system_user_name) }}" + group: "{{ item.group|default(heat_system_group_name) }}" + mode: "{{ item.mode|default('0755') }}" + with_items: + - { path: "/var/log/heat" } + when: log_dir.rc != 0 + tags: + - heat-dirs + - heat-logs diff --git a/tasks/heat_service_add.yml b/tasks/heat_service_add.yml new file mode 100644 index 0000000..260802f --- /dev/null +++ b/tasks/heat_service_add.yml @@ -0,0 +1,89 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Create a service +- name: Ensure heat service + keystone: + command: "ensure_service" + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + service_name: "{{ service_name }}" + service_type: "{{ service_type }}" + description: "{{ service_description }}" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-api-setup + - heat-service-add + - heat-setup + +# Create an admin user +- name: Ensure heat user + keystone: + command: "ensure_user" + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + user_name: "{{ service_user_name }}" + tenant_name: "{{ service_tenant_name }}" + password: "{{ service_password }}" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-api-setup + - heat-service-add + - heat-setup + +# Add a role to the user +- name: Ensure heat user to admin role + keystone: + command: "ensure_user_role" + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + user_name: "{{ service_user_name }}" + tenant_name: "{{ service_tenant_name }}" + role_name: "{{ role_name }}" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-api-setup + - heat-service-add + - heat-setup + +# Create an endpoint +- name: Ensure heat endpoint + keystone: + command: "ensure_endpoint" + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + region_name: "{{ service_region }}" + service_name: "{{ service_name }}" + service_type: "{{ service_type }}" + publicurl: "{{ service_publicurl }}" + adminurl: "{{ service_internalurl }}" + internalurl: "{{ service_adminurl }}" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-api-setup + - heat-service-add + - heat-setup diff --git a/tasks/heat_service_setup.yml b/tasks/heat_service_setup.yml new file mode 100644 index 0000000..5302ad2 --- /dev/null +++ b/tasks/heat_service_setup.yml @@ -0,0 +1,83 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- include: heat_service_add.yml + vars: + service_user_name: "{{ heat_service_user_name }}" + service_tenant_name: "{{ heat_service_tenant_name }}" + service_name: "{{ heat_service_name }}" + service_type: "{{ heat_service_type }}" + service_region: "{{ heat_service_region }}" + service_description: "{{ heat_service_description }}" + service_password: "{{ heat_service_password }}" + service_publicurl: "{{ heat_service_publicurl }}" + service_internalurl: "{{ heat_service_internalurl }}" + service_adminurl: "{{ heat_service_adminurl }}" + role_name: "{{ heat_service_role_name }}" + tags: + - heat-api + +- include: heat_service_add.yml + vars: + service_user_name: "{{ heat_service_user_name }}" + service_tenant_name: "{{ heat_service_tenant_name }}" + service_name: "{{ heat_cfn_service_name }}" + service_type: "{{ heat_cfn_service_type }}" + service_region: "{{ heat_service_region }}" + service_description: "{{ heat_cfn_service_description }}" + service_password: "{{ heat_cfn_service_password }}" + service_publicurl: "{{ heat_cfn_service_publicurl }}" + service_internalurl: "{{ heat_cfn_service_internalurl }}" + service_adminurl: "{{ heat_cfn_service_adminurl }}" + role_name: "{{ heat_service_role_name }}" + tags: + - heat-api + - heat-api-cfn + +# We add the keystone role used by heat to delegate to the heat service user +# (for performing deferred operations via trusts) +- name: Ensure stack_owner role + keystone: + command: "ensure_role" + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + user_name: "{{ heat_service_user_name }}" + tenant_name: "{{ heat_service_tenant_name }}" + role_name: "{{ heat_stack_owner_name }}" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-api + - heat-api-cfn + +# Any user creating stacks needs to have the 'heat_stack_owner' role assigned, +# we add to admin user here for testing purposes +- name: Ensure admin has stack_owner role + keystone: + command: ensure_user_role + token: "{{ keystone_auth_admin_token }}" + endpoint: "{{ keystone_service_adminurl }}" + user_name: "{{ keystone_admin_user_name }}" + tenant_name: "{{ keystone_admin_tenant_name }}" + role_name: "{{ heat_stack_owner_name }}" + register: add_service + until: add_service|success + retries: 5 + delay: 10 + tags: + - heat-api + - heat-api-cfn diff --git a/tasks/heat_upstart_common_init.yml b/tasks/heat_upstart_common_init.yml new file mode 100644 index 0000000..cd6f602 --- /dev/null +++ b/tasks/heat_upstart_common_init.yml @@ -0,0 +1,46 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Place the init script + template: + src: "heat-upstart-init.j2" + dest: "/etc/init/{{ program_name }}.conf" + mode: "0644" + owner: "root" + group: "root" + notify: + - Restart heat services + tags: + - upstart-init + - heat-init + +- name: Reload init scripts + shell: | + initctl reload-configuration + notify: + - Restart heat services + tags: + - upstart-init + - heat-init + +- name: Load service + service: + name: "{{ program_name }}" + enabled: "yes" + notify: + - Restart heat services + tags: + - upstart-init + - heat-init diff --git a/tasks/heat_upstart_init.yml b/tasks/heat_upstart_init.yml new file mode 100644 index 0000000..ca38d1f --- /dev/null +++ b/tasks/heat_upstart_init.yml @@ -0,0 +1,54 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- include: heat_upstart_common_init.yml + vars: + program_name: "{{ heat_service_program_name }}" + service_name: "{{ heat_service_name }}" + system_user: "{{ heat_system_user_name }}" + system_group: "{{ heat_system_group_name }}" + service_home: "{{ heat_system_home_folder }}" + when: > + inventory_hostname in groups['heat_api'] + +- include: heat_upstart_common_init.yml + vars: + program_name: "{{ heat_cfn_service_program_name }}" + service_name: "{{ heat_service_name }}" + system_user: "{{ heat_system_user_name }}" + system_group: "{{ heat_system_group_name }}" + service_home: "{{ heat_system_home_folder }}" + when: > + inventory_hostname in groups['heat_api_cfn'] + +- include: heat_upstart_common_init.yml + vars: + program_name: "{{ heat_cloudwatch_program_name }}" + service_name: "{{ heat_service_name }}" + system_user: "{{ heat_system_user_name }}" + system_group: "{{ heat_system_group_name }}" + service_home: "{{ heat_system_home_folder }}" + when: > + inventory_hostname in groups['heat_api_cloudwatch'] + +- include: heat_upstart_common_init.yml + vars: + program_name: "{{ heat_engine_program_name }}" + service_name: "{{ heat_service_name }}" + system_user: "{{ heat_system_user_name }}" + system_group: "{{ heat_system_group_name }}" + service_home: "{{ heat_system_home_folder }}" + when: > + inventory_hostname in groups['heat_engine'] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..f447468 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,33 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- include: heat_pre_install.yml +- include: heat_install.yml + +- include: heat_domain_setup.yml + when: > + inventory_hostname == groups['heat_all'][0] + +- include: heat_post_install.yml + +- include: heat_db_setup.yml + when: > + inventory_hostname == groups['heat_all'][0] + +- include: heat_service_setup.yml + when: > + inventory_hostname == groups['heat_all'][0] + +- include: heat_upstart_init.yml diff --git a/templates/heat-upstart-init.j2 b/templates/heat-upstart-init.j2 new file mode 100644 index 0000000..9ecb77d --- /dev/null +++ b/templates/heat-upstart-init.j2 @@ -0,0 +1,41 @@ +# {{ ansible_managed }} + +# vim:set ft=upstart ts=2 et: + +description "{{ program_name }}" +author "Kevin Carter " + +start on runlevel [2345] +stop on runlelvel [016] + +respawn +respawn limit 10 5 + +# Set the RUNBIN environment variable +env RUNBIN="/usr/local/bin/{{ program_name }}" + +# Change directory to service users home +chdir "{{ service_home }}" + +# Pre start actions +pre-start script + mkdir -p "/var/run/{{ program_name }}" + chown {{ system_user }}:{{ system_group }} "/var/run/{{ program_name }}" + + mkdir -p "/var/lock/{{ program_name }}" + chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}" +end script + +# Post stop actions +post-stop script + rm "/var/run/{{ program_name }}/{{ program_name }}.pid" +end script + +# Run the start up job +exec start-stop-daemon --start \ + --chuid {{ system_user }} \ + --make-pidfile \ + --pidfile /var/run/{{ program_name }}/{{ program_name }}.pid \ + --exec "{{ program_override|default('$RUNBIN') }}" \ + -- {{ program_config_options|default('') }} \ + --log-file=/var/log/{{ service_name }}/{{ program_name }}.log diff --git a/templates/heat.conf.j2 b/templates/heat.conf.j2 new file mode 100644 index 0000000..7b6317c --- /dev/null +++ b/templates/heat.conf.j2 @@ -0,0 +1,96 @@ +# {{ ansible_managed }} + +[DEFAULT] +verbose = {{ verbose }} +debug = {{ debug }} +use_syslog = False + +log_file = /var/log/heat/heat.log + +stack_domain_admin_password = {{ heat_stack_domain_admin_password }} +stack_domain_admin = {{ heat_stack_domain_admin }} +stack_user_domain_id = {{ hostvars[groups['heat_api'][0]]['stack_user_domain_id'] }} +deferred_auth_method = {{ heat_deferred_auth_method }} + +auth_encryption_key = {{ heat_auth_encryption_key }} + +heat_watch_server_url = {{ heat_watch_server_url }} +heat_waitcondition_server_url = {{ heat_waitcondition_server_url }} +heat_metadata_server_url = {{ heat_metadata_server_url }} + + +## RPC Backend +rpc_backend = {{ heat_rpc_backend }} + + +## RabbitMQ +rabbit_port = {{ rabbitmq_port }} +rabbit_userid = {{ rabbitmq_userid }} +rabbit_password = {{ rabbitmq_password }} +rabbit_hosts = {{ rabbitmq_servers }} + + +[clients] +endpoint_type = {{ heat_client_endpoint }} + +[clients_ceilometer] +endpoint_type = {{ heat_client_endpoint }} + +[clients_cinder] +endpoint_type = {{ heat_client_endpoint }} + +[clients_glance] +endpoint_type = {{ heat_client_endpoint }} + +[clients_heat] +endpoint_type = {{ heat_client_endpoint }} + +[clients_keystone] +endpoint_type = {{ heat_client_endpoint }} + +[clients_neutron] +endpoint_type = {{ heat_client_endpoint }} + +[clients_nova] +endpoint_type = {{ heat_client_endpoint }} + +[clients_swift] +endpoint_type = {{ heat_client_endpoint }} + +[clients_trove] +endpoint_type = {{ heat_client_endpoint }} + +[database] +connection = mysql://{{ heat_galera_user }}:{{ heat_container_mysql_password }}@{{ galera_address }}/{{ heat_galera_database }}?charset=utf8 + +[ec2authtoken] +auth_uri = {{ keystone_service_internaluri }} + +[heat_api] +bind_port = {{ heat_service_port }} + +[heat_api_cfn] +bind_port = {{ heat_cfn_service_port }} + +[heat_api_cloudwatch] +bind_port = {{ heat_watch_port }} + +[keystone_authtoken] +signing_dir = /var/cache/heat +identity_uri = {{ keystone_service_internaluri }} +auth_uri = {{ keystone_service_internaluri }} +admin_tenant_name = {{ heat_service_tenant_name }} +admin_user = {{ heat_service_user_name }} +admin_password = {{ heat_service_password }} + +memcached_servers = {{ memcached_servers }} + +token_cache_time = 300 +revocation_cache_time = 60 + +# if your memcached server is shared, use these settings to avoid cache poisoning +memcache_security_strategy = ENCRYPT +memcache_secret_key = {{ memcached_encryption_key }} + +# if your keystone deployment uses PKI, and you value security over performance: +check_revocations_for_cached = False