]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Adding role for deploying python on CoreOS
authorpprokop <pprokop@gklab-126-023.igk.intel.com>
Mon, 14 Mar 2016 09:57:40 +0000 (10:57 +0100)
committerSébastien Han <seb@redhat.com>
Thu, 24 Mar 2016 15:24:44 +0000 (16:24 +0100)
roles/ceph-common-coreos/README.md [new file with mode: 0644]
roles/ceph-common-coreos/defaults/main.yml [new file with mode: 0644]
roles/ceph-common-coreos/tasks/install_pip.yml [new file with mode: 0644]
roles/ceph-common-coreos/tasks/install_pypy.yml [new file with mode: 0644]
roles/ceph-common-coreos/tasks/main.yml [new file with mode: 0644]
roles/ceph-common-coreos/templates/install_pip.sh.j2 [new file with mode: 0644]
roles/ceph-common-coreos/templates/install_python.sh.j2 [new file with mode: 0644]

diff --git a/roles/ceph-common-coreos/README.md b/roles/ceph-common-coreos/README.md
new file mode 100644 (file)
index 0000000..ae22a8b
--- /dev/null
@@ -0,0 +1,44 @@
+# Ansible role: Ceph Storage Agent
+
+This role installs python and pip on CoreOS.
+
+# Requirements
+
+This role has to be run without gathering facts and with sudo attribute.
+
+# Role variables
+
+Have a look at: `defaults/main.yml`.
+
+## Mandatory variables
+
+None.
+
+# Dependencies
+
+New CoreOS releases support pypy in version 2.4 and above. Unfortunetly CoreOS stable channel
+has to be used with pypy in version 2.4 and below due to some dependency issues.
+
+# Example Playbook
+
+```
+- hosts: servers
+  remote_user: core
+  sudo: True
+  gather_facts: false
+  roles:
+     - { role: ceph-common-coreos }
+```
+
+# Contribution
+
+**THIS REPOSITORY DOES NOT ACCEPT PULL REQUESTS**
+**PULL REQUESTS MUST GO THROUGH [CEPH-ANSIBLE](https://github.com/ceph/ceph-ansible)**
+
+# License
+
+Apache
+
+# Author Information
+
+This role was created by Alfredo Deza.
diff --git a/roles/ceph-common-coreos/defaults/main.yml b/roles/ceph-common-coreos/defaults/main.yml
new file mode 100644 (file)
index 0000000..8b21fb8
--- /dev/null
@@ -0,0 +1,7 @@
+coreos_pypy_version: 4.0.1
+coreos_pypy_arch: linux64
+coreos_pypy_url: https://bitbucket.org/pypy/pypy/downloads/pypy-{{coreos_pypy_version}}-{{coreos_pypy_arch}}.tar.bz2
+pypy_directory: /opt/pypy
+pypy_binary_directory: /opt/bin
+pip_url: https://bootstrap.pypa.io/get-pip.py
+local_temp_directory: /tmp
\ No newline at end of file
diff --git a/roles/ceph-common-coreos/tasks/install_pip.yml b/roles/ceph-common-coreos/tasks/install_pip.yml
new file mode 100644 (file)
index 0000000..2108f29
--- /dev/null
@@ -0,0 +1,30 @@
+---
+- name: download get_pip.py
+  raw: cd $HOME && wget {{pip_url}}
+
+- name: run get-pip.py
+  raw: "{{pypy_binary_directory}}/python $HOME/get-pip.py"
+
+- name: create local temp directory
+  local_action: raw mkdir -p {{local_temp_directory}}
+  sudo: no
+
+- name: prepare install_pip.sh
+  local_action: template src=install_pip.sh.j2 dest={{local_temp_directory}}/install_pip.sh
+  sudo: no
+
+- name: run pip.sh
+  script: "{{local_temp_directory}}/install_pip.sh"
+
+- name: add execute permission
+  raw:  chmod a+x {{pypy_directory}}/pip
+
+- name: move python to binary directory
+  raw:  mv {{pypy_directory}}/pip {{pypy_binary_directory}}/pip
+
+- name: create .pip
+  raw: touch $HOME/.pip
+
+- name: remove pip.sh
+  local_action: file path="{{local_temp_directory}}/pip.sh" state=absent
+  sudo: no
\ No newline at end of file
diff --git a/roles/ceph-common-coreos/tasks/install_pypy.yml b/roles/ceph-common-coreos/tasks/install_pypy.yml
new file mode 100644 (file)
index 0000000..26d52c7
--- /dev/null
@@ -0,0 +1,33 @@
+---
+- name: download python
+  raw: cd $HOME &&  wget -O - {{coreos_pypy_url}} |tar -xjf -
+
+- name: move pypy to pypy_install_directory
+  raw:  mv $HOME/pypy-{{coreos_pypy_version}}-{{coreos_pypy_arch}} {{pypy_directory}}
+
+- name: create local temp directory
+  local_action: raw mkdir -p {{local_temp_directory}}
+  sudo: no
+
+- name: prepare python executable
+  local_action: template src=install_python.sh.j2 dest={{local_temp_directory}}/install_python.sh
+  sudo: no
+
+- name: fix library
+  raw:  ln -s /lib64/libncurses.so.5.9 {{pypy_directory}}/lib_pypy/libtinfo.so.5
+
+- name: run install_python.sh
+  script: "{{local_temp_directory}}/install_python.sh"
+
+- name: add execute permission
+  raw:  chmod a+x {{pypy_directory}}/python
+
+- name: move python to binary directory
+  raw:  mv {{pypy_directory}}/python {{pypy_binary_directory}}/python
+
+- name: create .python
+  raw: touch $HOME/.python
+
+- name: remove install_python.sh
+  local_action: file path="{{local_temp_directory}}/install_python.sh" state=absent
+  sudo: no
\ No newline at end of file
diff --git a/roles/ceph-common-coreos/tasks/main.yml b/roles/ceph-common-coreos/tasks/main.yml
new file mode 100644 (file)
index 0000000..4f3404a
--- /dev/null
@@ -0,0 +1,16 @@
+---
+- name: check if there is python
+  raw: stat $HOME/.python
+  register: need_python
+  ignore_errors: true
+
+- include: install_pypy.yml
+  when: need_python | failed
+
+- name: check if there is pip
+  raw: stat $HOME/.pip
+  register: need_pip
+  ignore_errors: true
+
+- include: install_pip.yml
+  when: need_pip | failed and need_python | failed
\ No newline at end of file
diff --git a/roles/ceph-common-coreos/templates/install_pip.sh.j2 b/roles/ceph-common-coreos/templates/install_pip.sh.j2
new file mode 100644 (file)
index 0000000..af7bc59
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+
+cat > {{pypy_directory}}/pip << EOF
+#!/bin/bash
+LD_LIBRARY_PATH={{pypy_directory}}/lib_pypy:$LD_LIBRARY_PATH exec {{pypy_directory}}/bin/pip "\$@"\
\ No newline at end of file
diff --git a/roles/ceph-common-coreos/templates/install_python.sh.j2 b/roles/ceph-common-coreos/templates/install_python.sh.j2
new file mode 100644 (file)
index 0000000..04c14f0
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cat > {{pypy_directory}}/python << EOF
+#!/bin/bash
+LD_LIBRARY_PATH={{pypy_directory}}/lib_pypy:$LD_LIBRARY_PATH exec {{pypy_directory}}/bin/pypy "\$@"\