From 967a055c5d2b6270f7614ee81a669f8603251b54 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 3 Mar 2020 10:51:03 -0600 Subject: [PATCH] Use openstackclient from container We have multiple places, such as bridge, where we use openstackclient as a utility. The current practice tends to be installing it into a venv somewhere. On bridge there are 16 venvs in /root - and in some of them but not all exist a working openstack client. Since it's purely an API interaction tool, all it needs is the clouds.yaml files bind-mounted in. The openstackclient project now publishes a container image. Install a wrapper script for calling it into /usr/local on bridge. Change-Id: I4c64125d5dd3c89275e259a57b0efa0847ac6fc2 --- .../roles/install-osc-container/README.rst | 1 + .../install-osc-container/files/openstack | 20 +++++++++++++++++++ .../install-osc-container/tasks/main.yaml | 8 ++++++++ playbooks/service-bridge.yaml | 2 ++ 4 files changed, 31 insertions(+) create mode 100644 playbooks/roles/install-osc-container/README.rst create mode 100644 playbooks/roles/install-osc-container/files/openstack create mode 100644 playbooks/roles/install-osc-container/tasks/main.yaml diff --git a/playbooks/roles/install-osc-container/README.rst b/playbooks/roles/install-osc-container/README.rst new file mode 100644 index 0000000000..5d2e77e6e9 --- /dev/null +++ b/playbooks/roles/install-osc-container/README.rst @@ -0,0 +1 @@ +An ansible role to install openstackclient container and helper script diff --git a/playbooks/roles/install-osc-container/files/openstack b/playbooks/roles/install-osc-container/files/openstack new file mode 100644 index 0000000000..7ff8057739 --- /dev/null +++ b/playbooks/roles/install-osc-container/files/openstack @@ -0,0 +1,20 @@ +#!/bin/bash +# Copyright (c) 2020 Red Hat, 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. + +exec docker run -it --rm \ + -v/etc/openstack:/etc/openstack \ + docker.io/osclient/python-openstackclient \ + openstack $@ diff --git a/playbooks/roles/install-osc-container/tasks/main.yaml b/playbooks/roles/install-osc-container/tasks/main.yaml new file mode 100644 index 0000000000..f821e8cbd9 --- /dev/null +++ b/playbooks/roles/install-osc-container/tasks/main.yaml @@ -0,0 +1,8 @@ +- name: Add helper script + become: yes + copy: + dest: /usr/local/bin/openstack + group: root + mode: 0755 + owner: root + src: openstack diff --git a/playbooks/service-bridge.yaml b/playbooks/service-bridge.yaml index 1eeea3ef03..26b81fe095 100644 --- a/playbooks/service-bridge.yaml +++ b/playbooks/service-bridge.yaml @@ -4,6 +4,8 @@ - ansible-cron - cloud-launcher-cron - edit-secrets-script + - install-docker + - install-osc-container - install-kubectl - configure-kubectl tasks: