From 846c15d8e1ca39e12b823d1b2e508f3edc009bbf Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Wed, 5 Dec 2018 10:04:52 +0100 Subject: [PATCH] Allow set tty for containers This change adds support to comfigure tty, it was enabled by default but a recent patch removed it. Some services such as Karaf in opendaylight requires a TTY during startup. Closes-Bug: #1806662 Change-Id: Ia4335523b727d0e45505cbb1efb40ccf04c27db7 --- ansible/library/kolla_docker.py | 10 +++++++++- ansible/roles/opendaylight/defaults/main.yml | 1 + ansible/roles/opendaylight/handlers/main.yml | 1 + ansible/roles/opendaylight/tasks/config.yml | 1 + .../notes/support-tty-containers-c2d189f2e7c25dba.yaml | 5 +++++ tests/test_kolla_docker.py | 4 +++- 6 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/support-tty-containers-c2d189f2e7c25dba.yaml diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index e74d0f06fd..16092ed112 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -173,6 +173,12 @@ options: - running - exited - paused + tty: + description: + - Allocate TTY to container + required: False + default: False + type: bool author: Sam Yaple ''' @@ -639,6 +645,7 @@ class DockerWorker(object): 'image': self.params.get('image'), 'name': self.params.get('name'), 'volumes': volumes, + 'tty': self.params.get('tty'), } def create_container(self): @@ -842,7 +849,8 @@ def generate_module(): tls_cacert=dict(required=False, type='str'), volumes=dict(required=False, type='list'), volumes_from=dict(required=False, type='list'), - dimensions=dict(required=False, type='dict', default=dict()) + dimensions=dict(required=False, type='dict', default=dict()), + tty=dict(required=False, type='bool', default=False), ) required_if = [ ['action', 'pull_image', ['image']], diff --git a/ansible/roles/opendaylight/defaults/main.yml b/ansible/roles/opendaylight/defaults/main.yml index b5d026ec00..8fbb7eb4b2 100644 --- a/ansible/roles/opendaylight/defaults/main.yml +++ b/ansible/roles/opendaylight/defaults/main.yml @@ -14,6 +14,7 @@ opendaylight_services: - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" dimensions: "{{ opendaylight_dimensions }}" + tty: True haproxy: opendaylight_api: enabled: "{{ enable_opendaylight }}" diff --git a/ansible/roles/opendaylight/handlers/main.yml b/ansible/roles/opendaylight/handlers/main.yml index c9bd033c2c..6985258e3c 100644 --- a/ansible/roles/opendaylight/handlers/main.yml +++ b/ansible/roles/opendaylight/handlers/main.yml @@ -12,6 +12,7 @@ volumes: "{{ service.volumes }}" privileged: "{{ service.privileged | default(False) }}" dimensions: "{{ service.dimensions }}" + tty: "{{ service.tty }}" when: - kolla_action != "config" - service.enabled | bool diff --git a/ansible/roles/opendaylight/tasks/config.yml b/ansible/roles/opendaylight/tasks/config.yml index 921817497c..d41dd3d2e7 100644 --- a/ansible/roles/opendaylight/tasks/config.yml +++ b/ansible/roles/opendaylight/tasks/config.yml @@ -217,6 +217,7 @@ privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" + tty: "{{ item.value.tty }}" register: check_opendaylight_containers when: - kolla_action != "config" diff --git a/releasenotes/notes/support-tty-containers-c2d189f2e7c25dba.yaml b/releasenotes/notes/support-tty-containers-c2d189f2e7c25dba.yaml new file mode 100644 index 0000000000..392c86d395 --- /dev/null +++ b/releasenotes/notes/support-tty-containers-c2d189f2e7c25dba.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added new parameter in kolla_docker to support configuring + TTY in containers, value is False by default diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index d8374e8e08..79a4ca31ec 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -84,7 +84,8 @@ class ModuleArgsTest(base.BaseTestCase): tls_cacert=dict(required=False, type='str'), volumes=dict(required=False, type='list'), volumes_from=dict(required=False, type='list'), - dimensions=dict(required=False, type='dict', default=dict()) + dimensions=dict(required=False, type='dict', default=dict()), + tty=dict(required=False, type='bool', default=False), ) required_if = [ ['action', 'pull_image', ['image']], @@ -133,6 +134,7 @@ FAKE_DATA = { 'image': 'myregistrydomain.com:5000/ubuntu:16.04', 'name': 'test_container', 'volumes': None, + 'tty': False, }, 'images': [