This repository was archived by the owner on Nov 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Add a docker image loader TOSCA component #148
Open
laurentganne
wants to merge
17
commits into
develop
Choose a base branch
from
feature/GH-140-docker-image-loader
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b025007
First version
laurentganne 973cf4d
Updates to load and removal
laurentganne 9ab4d34
Added an optional requirement on archive provider
laurentganne 704a8f5
Minor updates
laurentganne d53ff0a
Minor fix
laurentganne 6d5ba45
Merge branch 'develop' into feature/GH-140-docker-image-loader
laurentganne 7c212a8
Fixed issues depending on python version
laurentganne 3273480
Updated Loader components names
laurentganne dd91ce6
Fixed an install issue on CentOS 7
laurentganne f58a322
Added an abstract component for common properties
laurentganne 83458c0
Fixed issues with docker repositories
laurentganne 50d65de
Fixed issues with container stop/deletion
laurentganne 913a1ce
Removed unused options
laurentganne 41c549f
Merge branch 'develop' into feature/GH-140-docker-image-loader
laurentganne a15243f
Updated changelog
laurentganne d68a0c9
Add retries to apt
laurentganne 57cd842
Added opional hostname and network_mode properties
laurentganne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ metadata: | |
| template_version: 3.0.0-SNAPSHOT | ||
| template_author: Ystia | ||
|
|
||
|
|
||
| description: Docker container types | ||
|
|
||
| imports: | ||
| - tosca-normative-types:1.0.0-ALIEN20 | ||
|
|
@@ -47,6 +47,10 @@ node_types: | |
| List of additional container ports which informs Docker that the container listens on the specified network ports at runtime. | ||
| If the port is already exposed using EXPOSE in a Dockerfile, it does not need to be exposed again. | ||
| required: false | ||
| hostname: | ||
| type: string | ||
| description: Container hostname | ||
| required: false | ||
| image: | ||
| type: string | ||
| description: > | ||
|
|
@@ -59,6 +63,13 @@ node_types: | |
| description: > | ||
| Retain volumes associated with a removed container. | ||
| default: true | ||
| network_mode: | ||
| type: string | ||
| description: > | ||
| Connect the container to a network. | ||
| Possible values: bridge, none, host, <network-name>|<network-id> | ||
| or container:<name|id> to reuse another container's network stack | ||
| required: false | ||
| published_ports: | ||
| type: list | ||
| entry_schema: | ||
|
|
@@ -102,21 +113,26 @@ node_types: | |
| required: false | ||
| attributes: | ||
| container_id: { get_operation_output: [SELF, Standard, create, CONTAINER_ID] } | ||
| started_container_id: { get_operation_output: [SELF, Standard, create, STARTED_CONTAINER_ID] } | ||
| interfaces: | ||
| Standard: | ||
| inputs: | ||
| # Will be empty for create operation but not a big deal | ||
| CONTAINER_ID: { get_attribute: [SELF, container_id] } | ||
| STARTED_CONTAINER_ID: { get_attribute: [SELF, started_container_id] } | ||
| AUTO_REMOVE: { get_property: [SELF, auto_remove] } | ||
| CLEANUP: { get_property: [SELF, cleanup] } | ||
| COMMAND: { get_property: [SELF, docker_run_cmd] } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably also deal with |
||
| CPU_SHARE: { get_property: [SELF, cpu_share] } | ||
| DETACH: { get_property: [SELF, detach] } | ||
| ENV_VARS: { get_property: [SELF, docker_env_vars] } | ||
| EXPOSED_PORTS: { get_property: [SELF, exposed_ports] } | ||
| HOSTNAME: { get_property: [SELF, hostname] } | ||
| IMAGE: { get_property: [SELF, image] } | ||
| KEEP_VOLUMES: { get_property: [SELF, keep_volumes] } | ||
| MEM_SHARE: { get_property: [SELF, mem_share] } | ||
| MEM_SHARE_LIMIT: { get_property: [SELF, mem_share_limit] } | ||
| NETWORK_MODE: { get_property: [SELF, network_mode] } | ||
| PUBLISHED_PORTS: { get_property: [SELF, published_ports] } | ||
| RESTART_POLICY: { get_property: [SELF, restart_policy] } | ||
| SHM_SIZE: { get_property: [SELF, shm_size] } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # | ||
| # 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. | ||
| # | ||
| - name: Install ansible docker_image requirements | ||
| hosts: all | ||
| become: true | ||
| tasks: | ||
| - name: Get python version | ||
| python_requirements_info: | ||
| register: pri | ||
| failed_when: pri == None or pri.python_version == None or pri.python_version == '' | ||
| - name: Get python major version | ||
| set_fact: | ||
| python_major_version: "{{pri.python_version | replace('\n', '') | regex_replace('^(\\d+).*', '\\1') }}" | ||
| - name: Set python version for pip | ||
| set_fact: | ||
| python_pip_pkg: "python3-pip" | ||
| pip_cmd: "pip3" | ||
| when: python_major_version != "2" | ||
| - name: Set python 2 version for pip | ||
| set_fact: | ||
| python_pip_pkg: "python-pip" | ||
| pip_cmd: "pip" | ||
| when: python_major_version == "2" | ||
| - name: RedHat - install prerequisites | ||
| yum: | ||
| name: | ||
| - "{{ python_pip_pkg }}" | ||
| state: present | ||
| update_cache: yes | ||
| when: ansible_os_family == 'RedHat' | ||
| - name: Debian - install prerequisites | ||
| apt: | ||
| name: | ||
| - "{{ python_pip_pkg }}" | ||
| state: present | ||
| update_cache: yes | ||
| register: apt_res | ||
| retries: 5 | ||
| delay: 15 | ||
| until: apt_res is success | ||
| when: ansible_os_family == 'Debian' | ||
laurentganne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Install latest Pip version | ||
| pip: | ||
| name: "pip" | ||
| state: latest | ||
| executable: "{{pip_cmd}}" | ||
| when: python_major_version != "2" | ||
| - name: Install latest Pip version compatible with python 2 | ||
| pip: | ||
| name: "pip<21.0" | ||
| state: latest | ||
| executable: "{{pip_cmd}}" | ||
| when: python_major_version == "2" | ||
| - name: Add user to docker group | ||
| user: | ||
| name: "{{USER}}" | ||
| groups: docker | ||
| append: yes | ||
| when: USER != "root" | ||
| - name: Install 'docker' python package | ||
| pip: | ||
| name: docker | ||
| # In user directory to avoid potential issues with distutils | ||
| # see issue https://github.com/pypa/pip/issues/5247 | ||
| extra_args: --user | ||
| executable: "{{pip_cmd}}" | ||
| become_user: "{{USER}}" | ||
| become_method: sudo | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # | ||
| # Ystia Forge | ||
| # Copyright (C) 2020 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. | ||
| # | ||
| - name: Load Docker image from tar archive | ||
| hosts: all | ||
| tasks: | ||
| - name: Get archive PATH property | ||
| set_fact: | ||
| archive_path: "{{PATH}}" | ||
| failed_when: PATH == "" | ||
| - name: Load tar archive | ||
| docker_image: | ||
| name: "{{NAME}}" | ||
| tag: "{{TAG}}" | ||
| push: "{{PUSH}}" | ||
| repository: "{{REPOSITORY}}" | ||
| load_path: "{{archive_path}}" | ||
| source: load | ||
| force_source: "{{FORCE_LOAD}}" | ||
| become: true | ||
| become_user: "{{USER}}" | ||
| become_method: sudo | ||
| register: result | ||
| - name: Fail if the image specified does not correpond to the archive specified | ||
| debug: | ||
| msg: "Checking if image {{NAME}} {{TAG}} is in tar archive {{PATH}}" | ||
| failed_when: result.image == None | ||
| - name: Check if an image was loaded | ||
| debug: | ||
| msg: "Image {{NAME}} {{TAG}} already loaded" | ||
| when: result.image == {} | ||
| - name: Intialize fact used in opration output | ||
| set_fact: | ||
| REPO_TAGS: [] | ||
| - name: Set repo tags output if returned by docker_image | ||
| set_fact: | ||
| REPO_TAGS: "{{result.image.RepoTags | to_json}}" | ||
| when: result.image != None and result.image != {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.