summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2015-11-23 15:21:23 -0500
committerScott Dodson <sdodson@redhat.com>2015-12-15 15:45:45 -0500
commit7a2891780e827513859628c7703cc1e7be53683f (patch)
tree54745bd070661ecf47e37fd3dff8898810ff2f3e
parentd3edce9c192c8d1eba572ba45ca25c06d0fbb830 (diff)
downloadopenshift-7a2891780e827513859628c7703cc1e7be53683f.tar.gz
openshift-7a2891780e827513859628c7703cc1e7be53683f.tar.bz2
openshift-7a2891780e827513859628c7703cc1e7be53683f.tar.xz
openshift-7a2891780e827513859628c7703cc1e7be53683f.zip
Add openshift_cli role
This role ensures that the clients package is installed or if it's a containerized install places a wrapper script in /usr/local/bin/openshift and symlinks for oc, oadm, and kubectl.
-rw-r--r--roles/openshift_cli/meta/main.yml16
-rw-r--r--roles/openshift_cli/tasks/main.yml32
-rw-r--r--roles/openshift_cli/templates/openshift.j216
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py20
-rw-r--r--roles/openshift_master/meta/main.yml1
-rw-r--r--roles/openshift_master_ca/meta/main.yml1
6 files changed, 68 insertions, 18 deletions
diff --git a/roles/openshift_cli/meta/main.yml b/roles/openshift_cli/meta/main.yml
new file mode 100644
index 000000000..1e8f8b719
--- /dev/null
+++ b/roles/openshift_cli/meta/main.yml
@@ -0,0 +1,16 @@
+---
+galaxy_info:
+ author: Jason DeTiberus
+ description: OpenShift Docker
+ company: Red Hat, Inc.
+ license: Apache License, Version 2.0
+ min_ansible_version: 1.9
+ platforms:
+ - name: EL
+ versions:
+ - 7
+ categories:
+ - cloud
+dependencies:
+- { role: openshift_common }
+- { role: docker }
diff --git a/roles/openshift_cli/tasks/main.yml b/roles/openshift_cli/tasks/main.yml
new file mode 100644
index 000000000..c0ea66e70
--- /dev/null
+++ b/roles/openshift_cli/tasks/main.yml
@@ -0,0 +1,32 @@
+---
+- openshift_facts:
+ role: common
+ local_facts:
+ deployment_type: "{{ openshift_deployment_type }}"
+
+- name: Install clients
+ yum: pkg={{ openshift.common.service_type }}-clients state=installed
+ when: not openshift.common.is_containerized | bool
+
+- name: Pull CLI Image
+ command: >
+ docker pull {{ openshift.common.cli_image }}
+ when: openshift.common.is_containerized | bool
+
+- name: Create /usr/local/bin/openshift cli wrapper
+ template:
+ src: openshift.j2
+ dest: /usr/local/bin/openshift
+ mode: 0755
+ when: openshift.common.is_containerized | bool
+
+- name: Create client symlinks
+ file:
+ path: "{{ item }}"
+ state: link
+ src: /usr/local/bin/openshift
+ with_items:
+ - /usr/local/bin/oadm
+ - /usr/local/bin/oc
+ - /usr/local/bin/kubectl
+ when: openshift.common.is_containerized | bool \ No newline at end of file
diff --git a/roles/openshift_cli/templates/openshift.j2 b/roles/openshift_cli/templates/openshift.j2
new file mode 100644
index 000000000..cade4d1a7
--- /dev/null
+++ b/roles/openshift_cli/templates/openshift.j2
@@ -0,0 +1,16 @@
+#!/bin/bash
+if [ ! -d ~/.kube ]; then
+ mkdir -m 0700 ~/.kube
+fi
+cmd=`basename $0`
+user=`id -u`
+group=`id -g`
+
+# docker can only split stderr and stdin when run without -t
+# https://github.com/docker/docker/issues/725
+# ansible checks various streams DO NOT CROSS THE STREAMS
+if [ -z $TERM ]; then
+ $t = '-it'
+fi
+
+docker run ${t} -a STDERR -a STDOUT -a STDIN --privileged --net=host --user=${user}:${group} -v ~/.kube:/root/.kube -v /tmp:/tmp -v {{ openshift.common.config_base}}:{{ openshift.common.config_base }} -e KUBECONFIG=/root/.kube/config --entrypoint ${cmd} --rm {{ openshift.common.cli_image }} ${@} \ No newline at end of file
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index b5454dd81..35ee18f4f 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -1014,22 +1014,6 @@ def set_container_facts_if_unset(facts):
if 'ovs_image' not in facts['node']:
facts['node']['ovs_image'] = ovs_image
- # shared /tmp/openshift vol is for file exchange with ansible
- # --privileged is required to read the config dir
- # --net host to access openshift from the container
- # maybe -v /var/run/docker.sock:/var/run/docker.sock is required as well
- runner = ("docker run --rm --privileged --net host -v "
- "/tmp/openshift:/tmp/openshift -v {datadir}:{datadir} "
- "-v {confdir}:{confdir} "
- "-e KUBECONFIG={confdir}/master/admin.kubeconfig "
- "{image}").format(confdir=facts['common']['config_base'],
- datadir=facts['common']['data_dir'],
- image=facts['common']['cli_image'])
-
- if facts['common']['is_containerized']:
- facts['common']['client_binary'] = '%s cli' % runner
- facts['common']['admin_binary'] = '%s admin' % runner
-
return facts
@@ -1134,8 +1118,8 @@ class OpenShiftFacts(object):
common = dict(use_openshift_sdn=True, ip=ip_addr, public_ip=ip_addr,
deployment_type='origin', hostname=hostname,
public_hostname=hostname, use_manageiq=False)
- common['client_binary'] = 'oc' if os.path.isfile('/usr/bin/oc') else 'osc'
- common['admin_binary'] = 'oadm' if os.path.isfile('/usr/bin/oadm') else 'osadm'
+ common['client_binary'] = 'oc'
+ common['admin_binary'] = 'oadm'
common['dns_domain'] = 'cluster.local'
common['install_examples'] = True
defaults['common'] = common
diff --git a/roles/openshift_master/meta/main.yml b/roles/openshift_master/meta/main.yml
index c125cb5d0..8db99fc2a 100644
--- a/roles/openshift_master/meta/main.yml
+++ b/roles/openshift_master/meta/main.yml
@@ -13,3 +13,4 @@ galaxy_info:
- cloud
dependencies:
- { role: openshift_common }
+- { role: openshift_cli }
diff --git a/roles/openshift_master_ca/meta/main.yml b/roles/openshift_master_ca/meta/main.yml
index 0c8881521..b5dd466c9 100644
--- a/roles/openshift_master_ca/meta/main.yml
+++ b/roles/openshift_master_ca/meta/main.yml
@@ -14,3 +14,4 @@ galaxy_info:
- system
dependencies:
- { role: openshift_repos }
+- { role: openshift_cli }