diff --git a/roles/ceph-common-coreos/README.md b/roles/ceph-common-coreos/README.md new file mode 100644 index 000000000..ae22a8b5d --- /dev/null +++ b/roles/ceph-common-coreos/README.md @@ -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 index 000000000..8b21fb830 --- /dev/null +++ b/roles/ceph-common-coreos/defaults/main.yml @@ -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 index 000000000..2108f298f --- /dev/null +++ b/roles/ceph-common-coreos/tasks/install_pip.yml @@ -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 index 000000000..26d52c775 --- /dev/null +++ b/roles/ceph-common-coreos/tasks/install_pypy.yml @@ -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 index 000000000..4f3404a14 --- /dev/null +++ b/roles/ceph-common-coreos/tasks/main.yml @@ -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 index 000000000..af7bc59f0 --- /dev/null +++ b/roles/ceph-common-coreos/templates/install_pip.sh.j2 @@ -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 index 000000000..04c14f0fa --- /dev/null +++ b/roles/ceph-common-coreos/templates/install_python.sh.j2 @@ -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 "\$@"\