diff --git a/CHANGELOG.md b/CHANGELOG.md index ca042315..6be9c141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## UNRELEASED +### NEW COMPONENTS + +* Python VirtualEnv component ([GH-74](https://github.com/ystia/forge/issues/74)) + ### ENHANCEMENTS * Add a vault in secured full stack topology ([GH-67](https://github.com/ystia/forge/issues/67)) diff --git a/README.md b/README.md index 2a3961ea..2b2ad85b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A set of public TOSCA Types and Topology templates used by the Ystia project ## Documentation -See [our documentation for more details](https://github.com/ystia/forge/blob/develop/org/ystia/README.rst) +See [our documentation for more details](https://github.com/ystia/forge/blob/develop/org/ystia/README.rst). ## Downloads diff --git a/org/ystia/python/virtualenv/linux/ansible/images/python-logo.png b/org/ystia/python/virtualenv/linux/ansible/images/python-logo.png new file mode 100644 index 00000000..7ef40651 Binary files /dev/null and b/org/ystia/python/virtualenv/linux/ansible/images/python-logo.png differ diff --git a/org/ystia/python/virtualenv/linux/ansible/playbooks/create.yaml b/org/ystia/python/virtualenv/linux/ansible/playbooks/create.yaml new file mode 100644 index 00000000..70ed85a9 --- /dev/null +++ b/org/ystia/python/virtualenv/linux/ansible/playbooks/create.yaml @@ -0,0 +1,57 @@ + +# +# Copyright 2019 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France. +# +# 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 python requirements + hosts: all + become: true + vars: + pip_extra_args: "" + tasks: + - name: Install pip + easy_install: + name: pip + state: latest + + - name: Install 'virtualenv' package + pip: + name: virtualenv + state: latest + + - name: Set virtualenv path + set_fact: + VIRTUAL_ENV_PATH: "/usr/local/py-env-{{NODE}}" + + - name: Force installation of at least one package + set_fact: + PACKAGES: ["pip"] + when: PACKAGES  | length == 0 + + - name: Set alternate pip index url + set_fact: + pip_extra_args: "-i {{PIP_INDEX_URL}}" + when: PIP_INDEX_URL is defined and PIP_INDEX_URL  | length > 0 + + - name: Dumping packages to install + debug: + var: PACKAGES + + - name: Install python packages + pip: + name: "{{PACKAGES}}" + extra_args: "{{pip_extra_args}}" + virtualenv: "{{ VIRTUAL_ENV_PATH }}" + virtualenv_python: "python{{VERSION}}" diff --git a/org/ystia/python/virtualenv/linux/ansible/playbooks/delete.yaml b/org/ystia/python/virtualenv/linux/ansible/playbooks/delete.yaml new file mode 100644 index 00000000..7d6cf9da --- /dev/null +++ b/org/ystia/python/virtualenv/linux/ansible/playbooks/delete.yaml @@ -0,0 +1,24 @@ +# +# Copyright 2019 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France. +# +# 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: Delete python virtualenv + hosts: all + become: true + tasks: + - name: "Delete {{VIRTUAL_ENV_PATH}}" + file: + path: "{{VIRTUAL_ENV_PATH}}" + state: absent \ No newline at end of file diff --git a/org/ystia/python/virtualenv/linux/ansible/types.yml b/org/ystia/python/virtualenv/linux/ansible/types.yml new file mode 100644 index 00000000..7cef9772 --- /dev/null +++ b/org/ystia/python/virtualenv/linux/ansible/types.yml @@ -0,0 +1,65 @@ +tosca_definitions_version: alien_dsl_2_0_0 + +# +# Ystia Forge +# Copyright (C) 2018 Bull S. A. S. - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. +# + +metadata: + template_name: org.ystia.python.virtualenv.linux.ansible + template_version: 2.2.0-SNAPSHOT + template_author: Ystia + +description: Python VirtualEnv for linux system + +imports: + - tosca-normative-types:1.0.0-ALIEN20 + - yorc-types:1.0.0 + - org.ystia.python.pub:2.2.0-SNAPSHOT + + +node_types: + org.ystia.python.virtualenv.linux.ansible.nodes.Python: + derived_from: tosca.nodes.SoftwareComponent + description: Python in a virtualenv component for linux + tags: + icon: /images/python-logo.png + properties: + component_version: + type: version + description: The installed Python version should be the version of the python executable eg 3.5 for python3.5 + default: 2.7 + packages: + type: list + entry_schema: + type: string + description: Install additionnal package + required: false + pip_index_url: + type: string + description: > + allows to set a custom index url for pip. + This allows offline installations for instance. + default: "" + required: false + attributes: + virtualenv_path: { get_operation_output: [SELF, Standard, create, VIRTUAL_ENV_PATH] } + capabilities: + python_host: + type: org.ystia.python.pub.capabilities.PythonHosting + occurrences: [0,unbounded] + interfaces: + Standard: + create: + inputs: + VERSION: { get_property: [SELF, component_version] } + PACKAGES: { get_property: [SELF, packages] } + PIP_INDEX_URL: { get_property: [SELF, pip_index_url] } + implementation: playbooks/create.yaml + delete: + inputs: + VIRTUAL_ENV_PATH: { get_attribute: [SELF, virtualenv_path] } + implementation: playbooks/delete.yaml + +