summaryrefslogtreecommitdiffstats
path: root/roles/openshift_facts
diff options
context:
space:
mode:
authorTobias Florek <tob@butter.sh>2015-09-23 13:51:41 +0200
committerScott Dodson <sdodson@redhat.com>2015-12-15 15:43:27 -0500
commita0b6fc7db1be2cf6190d982f90e96f4c39a4c699 (patch)
treeabab0b910d891a8b419b2231b3a52075ea1f0e49 /roles/openshift_facts
parente26eab4bdc817ef02a16e8b5c6c49e311a721e7b (diff)
downloadopenshift-a0b6fc7db1be2cf6190d982f90e96f4c39a4c699.tar.gz
openshift-a0b6fc7db1be2cf6190d982f90e96f4c39a4c699.tar.bz2
openshift-a0b6fc7db1be2cf6190d982f90e96f4c39a4c699.tar.xz
openshift-a0b6fc7db1be2cf6190d982f90e96f4c39a4c699.zip
Initial containerization work from @ibotty
copied from https://github.com/eparis/kubernetes-ansible/blob/17f98edd7ff53e649b43e26822b8fbc0be42b233/roles/common/tasks/main.yml
Diffstat (limited to 'roles/openshift_facts')
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py26
-rw-r--r--roles/openshift_facts/tasks/main.yml14
2 files changed, 39 insertions, 1 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index e557853b1..4278111c2 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -710,7 +710,8 @@ def set_sdn_facts_if_unset(facts, system_facts):
if 'common' in facts:
use_sdn = facts['common']['use_openshift_sdn']
if not (use_sdn == '' or isinstance(use_sdn, bool)):
- facts['common']['use_openshift_sdn'] = bool(strtobool(str(use_sdn)))
+ use_sdn = bool(strtobool(str(use_sdn)))
+ facts['common']['use_openshift_sdn'] = use_sdn
if 'sdn_network_plugin_name' not in facts['common']:
plugin = 'redhat/openshift-ovs-subnet' if use_sdn else ''
facts['common']['sdn_network_plugin_name'] = plugin
@@ -1031,6 +1032,7 @@ class OpenShiftFacts(object):
facts = set_version_facts_if_unset(facts)
facts = set_aggregate_facts(facts)
facts = set_etcd_facts_if_unset(facts)
+ facts = self.init_in_docker_facts(facts)
return dict(openshift=facts)
def get_defaults(self, roles):
@@ -1197,6 +1199,28 @@ class OpenShiftFacts(object):
self.changed = changed
return new_local_facts
+ def init_in_docker_facts(self, facts):
+ facts['is_atomic'] = os.path.isfile('/run/ostree-booted')
+
+ docker = dict()
+ docker['image_name'] = 'openshift/origin'
+ # TODO: figure out right way to set the version
+ docker['image_version'] = 'latest'
+ docker['image'] = "%s:%s" % (docker['image_name'], docker['image_version'])
+
+ # 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
+ docker['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=docker['image'])
+
+ if facts['is_atomic']:
+ facts['common']['client_binary'] = '%s cli' % docker['runner']
+ facts['common']['admin_binary'] = '%s admin' % docker['runner']
+
+ facts['docker'] = docker
+ return facts
+
def main():
""" main """
diff --git a/roles/openshift_facts/tasks/main.yml b/roles/openshift_facts/tasks/main.yml
index 832f7ad84..e98b7c591 100644
--- a/roles/openshift_facts/tasks/main.yml
+++ b/roles/openshift_facts/tasks/main.yml
@@ -6,6 +6,20 @@
- ansible_version | version_compare('1.9.0', 'ne')
- ansible_version | version_compare('1.9.0.1', 'ne')
+- name: Determine if Atomic
+ stat: path=/run/ostree-booted
+ register: s
+ changed_when: false
+
+- name: Init the is_atomic fact
+ set_fact:
+ is_atomic: false
+
+- name: Set the is_atomic fact
+ set_fact:
+ is_atomic: true
+ when: s.stat.exists
+
- name: Ensure PyYaml is installed
action: "{{ ansible_pkg_mgr }} name=PyYAML state=present"