Commit feb87e57 by John Jarvis

Merge pull request #355 from edx/jarv/rbenv-update

updating the rbenv role, removing environment
parents 4ca09ea6 c3ad9cab
......@@ -26,7 +26,7 @@
- elasticsearch
- role: rbenv
rbenv_user: "{{ forum_user }}"
rbenv_user_home: "{{ forum_home }}"
rbenv_dir: "{{ forum_home }}"
rbenv_ruby_version: "{{ forum_ruby_version }}"
- forum
- role: virtualenv
......
......@@ -27,6 +27,6 @@
- { role: 'edxapp', celery_worker: True }
- role: rbenv
rbenv_user: "{{ forum_user }}"
rbenv_user_home: "{{ forum_home }}"
rbenv_dir: "{{ forum_home }}"
rbenv_ruby_version: "{{ forum_ruby_version }}"
- forum
---
- name: common | restart rsyslogd
service: name=rsyslog state=restarted
- name: common | restart logrotate
service: name=logrotate state=restarted
sudo: True
---
- name: common | Add user www-data
# This is the default user for nginx
user: name="{{ common_web_user }}"
user: >
name="{{ common_web_user }}"
shell=/bin/false
- name: common | Create common directories
file: >
......
......@@ -98,14 +98,13 @@ edxapp_log_dir: "{{ log_dir }}/edxapp"
edxapp_venvs_dir: "{{ app_dir }}/venvs"
edxapp_venv_dir: "{{ edxapp_venvs_dir }}/edxapp"
edxapp_venv_bin: "{{ edxapp_venv_dir }}/bin"
edxapp_rbenvs_dir: "{{ app_dir }}/rbenvs"
edxapp_rbenv_dir: "{{ edxapp_rbenvs_dir }}/edxapp"
edxapp_user: edxapp
edxapp_rbenv_dir: "{{ edxapp_app_dir }}"
edxapp_rbenv_root: "{{ edxapp_rbenv_dir }}/.rbenv"
edxapp_gem_root: "{{ edxapp_rbenv_dir }}/.gem"
edxapp_gem_bin: "{{ edxapp_gem_root }}/bin"
edxapp_rbenv_shims: "{{ edxapp_rbenv_root }}/shims"
edxapp_rbenv_bin: "{{ edxapp_rbenv_root }}/bin"
edxapp_gem_root: "{{ edxapp_rbenv_dir }}/.gem"
edxapp_gem_bin: "{{ edxapp_gem_root }}/bin"
edxapp_user: edxapp
edxapp_deploy_path: "{{ edxapp_venv_bin }}:{{ edxapp_code_dir }}/bin:{{ edxapp_rbenv_bin }}:{{ edxapp_rbenv_shims }}:{{ edxapp_gem_bin }}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
edxapp_staticfile_dir: "{{ edxapp_data_dir }}/staticfiles"
edxapp_course_data_dir: "{{ edxapp_data_dir }}/data"
......
......@@ -2,5 +2,5 @@
dependencies:
- role: rbenv
rbenv_user: "{{ edxapp_user }}"
rbenv_user_home: "{{ edxapp_rbenv_dir }}"
rbenv_dir: "{{ edxapp_app_dir }}"
rbenv_ruby_version: "{{ edxapp_ruby_version }}"
......@@ -72,6 +72,7 @@
- name: edxapp | Install edx-platform npm dependencies
shell: npm install chdir={{ edxapp_code_dir }}
sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_deploy_environment }}"
tags:
- deploy
......
......@@ -9,7 +9,11 @@
notify: common | restart logrotate
- name: edxapp | create application user
user: name="{{ edxapp_user }}"
user: >
name="{{ edxapp_user }}"
home="{{ edxapp_app_dir }}"
createhome=no
shell=/bin/false
- name: edxapp | create edxapp app dir
file: >
......
......@@ -8,22 +8,22 @@
# * elasticsearch
# * oraclejdk
# * rbenv
#
#
#
#
# Example play:
# roles:
# - common
# - oraclejdk
# - elasticsearch
# - elasticsearch
# - role: rbenv
# rbenv_user: "{{ forum_user }}"
# rbenv_user_home: "{{ forum_rbenv_dir }}"
# rbenv_dir: "{{ forum_rbenv_dir }}"
# rbenv_ruby_version: "{{ forum_ruby_version }}"
# - forum
- name: forum | setup the forum env
template: src=forum_env.j2 dest={{ forum_home }}/forum_env owner={{ forum_user }} group={{ forum_user }}
notify:
notify:
- forum | restart the forum service
tags:
- forum
......@@ -31,7 +31,7 @@
- name: forum | ensure .bashrc exists
shell: touch {{ forum_home }}/.bashrc
sudo: true
sudo: true
sudo_user: "{{ forum_user }}"
tags:
- forum
......@@ -40,9 +40,9 @@
- name: forum | add source of ruby_env to .bashrc
lineinfile:
dest="{{ forum_home }}/.bashrc"
regexp='. {{ forum_home }}/forum_env'
regexp='. {{ forum_home }}/forum_env'
line='. {{ forum_home }}/forum_env'
notify:
notify:
- forum | restart the forum service
tags:
- forum
......@@ -51,7 +51,7 @@
- name: forum | copy cs_comments_service SysVunit script
template: src=cs_comments_service.j2 dest=/etc/init.d/cs_comments_service owner=root group=root mode=750
notify:
notify:
- forum | restart the forum service
tags:
- forum
......@@ -61,7 +61,7 @@
- name: forum | copy cs_comments_service upstart script
template: src=cs_comments_service.conf.j2 dest=/etc/init/cs_comments_service.conf owner=root group=root mode=644
notify:
notify:
- forum | restart the forum service
tags:
- forum
......
......@@ -67,14 +67,12 @@
- name: nginx | Set up nginx access log rotation
template: dest=/etc/logrotate.d/nginx-access src=edx_logrotate_nginx_access.j2 owner=root group=root mode=644
notify: common | restart logrotate
tags:
- logging
- update
- name: nginx | Set up nginx access log rotation
template: dest=/etc/logrotate.d/nginx-error src=edx_logrotate_nginx_error.j2 owner=root group=root mode=644
notify: common | restart logrotate
tags:
- logging
- update
......@@ -85,7 +83,7 @@
tags:
- nginx
- update
# If tasks that notify restart nginx don't change the state of the remote system
# their corresponding notifications don't get run. If nginx has been stopped for
# any reason, this will ensure that it is started up again.
......
......@@ -2,4 +2,22 @@
rbenv_version: 'v0.4.0'
rbenv_bundler_version: '1.3.2'
rbenv_root: "{{ rbenv_user_home }}/.rbenv"
rbenv_root: "{{ rbenv_dir }}/.rbenv"
rbenv_gem_root: "{{ rbenv_root }}/.gem"
rbenv_gem_bin: "{{ rbenv_gem_root }}/bin"
rbenv_bin: "{{ rbenv_dir }}/.rbenv/bin"
rbenv_shims: "{{ rbenv_root }}/shims"
rbenv_path: "{{ rbenv_bin }}:{{ rbenv_shims }}:{{ rbenv_gem_bin }}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
rbenv_debian_pkgs:
- build-essential
- libcurl4-openssl-dev
- libreadline-dev
- libssl-dev
- libxml2-dev
- libxslt1-dev
- zlib1g-dev
rbenv_environment:
RBENV_ROOT: $rbenv_root
GEM_ROOT: $rbenv_gem_root
GEM_HOME: $rbenv_gem_root
PATH: $rbenv_path
......@@ -12,13 +12,13 @@
# - common
# - role: rbenv
# rbenv_user: "{{ forum_user }}"
# rbenv_user_home: "{{ forum_rbenv_dir }}"
# rbenv_dir: "{{ forum_rbenv_dir }}"
# rbenv_ruby_version: "{{ forum_ruby_version }}"
#
# Parameters:
#
# * rbenv_user
# * rbenv_user_home
# * rbenv_dir
# * rbenv_ruby_version
#
# cribbed from https://github.com/mmoya/ansible-playbooks/blob/master/rbenv/main.yml
......@@ -28,196 +28,97 @@
- fail: rbenv_user required for role
when: rbenv_user is not defined
- fail: rbenv_user_home required for role
when: rbenv_user_home is not defined
- fail: rbenv_dir required for role
when: rbenv_dir is not defined
- fail: rbenv_ruby_version required for role
when: rbenv_ruby_version is not defined
- name: rbenv | create {{ rbenv_user_home }}
# workaround for the case where the parent
# directory doesn't exist
file: >
path={{ rbenv_user_home }}
state=directory
- name: rbenv | create rbenv user {{ rbenv_user }}
user: >
name={{ rbenv_user }}
state=present
shell=/bin/bash
home={{ rbenv_user_home }}
createhome=yes
tags:
- forum
- update
- name: rbenv | ensure homedir permissions {{ rbenv_user_home }}
# workaround for the case where the parent
# directory doesn't exist
home={{ rbenv_dir }}
shell=/bin/false
createhome=no
- name: rbenv | create rbenv dir if it does not exist
file: >
path={{ rbenv_user_home }}
owner={{ rbenv_user }}
group={{ rbenv_user }}
path="{{ rbenv_dir }}"
owner="{{ rbenv_user }}"
state=directory
recurse=yes
- name: rbenv | install build depends
apt: pkg={{ item }} state=present install_recommends=no
with_items:
- build-essential
- git
- libcurl4-openssl-dev
- libmysqlclient-dev
- libreadline-dev
- libssl-dev
- libxml2-dev
- libxslt1-dev
- zlib1g-dev
tags:
- ruby
- install
apt: pkg={{ ",".join(rbenv_debian_pkgs) }} state=present install_recommends=no
with_items: rbenv_debian_pkgs
- name: rbenv | update rbenv repo
git: >
repo=https://github.com/sstephenson/rbenv.git
dest={{ rbenv_user_home }}/.rbenv
dest={{ rbenv_dir }}/.rbenv
version={{ rbenv_version }}
sudo: true
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- install
- name: rbenv | ensure .bashrc exists
shell: touch {{ rbenv_user_home }}/.bashrc
sudo: true
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- update
- name: rbenv | drop a bash_profile
copy: >
src=../../common/files/bash_profile
dest={{ rbenv_user_home }}/.bash_profile
owner={{ rbenv_user }}
group={{ rbenv_user }}
- name: rbenv | ensure ruby_env exists
template: >
src=ruby_env.j2
dest={{ rbenv_user_home }}/ruby_env
owner={{ rbenv_user }}
group={{ rbenv_user }}
tags:
- ruby
- update
- name: rebenv | add source of ruby_env to .bashrc
lineinfile:
dest="{{ rbenv_user_home }}/.bashrc"
regexp='. {{ rbenv_user_home }}/ruby_env'
line='. {{ rbenv_user_home }}/ruby_env'
- name: rbenv | drop a bash_profile
copy: >
src=../../common/files/bash_profile
dest={{ rbenv_user_home }}/.bash_profile
owner={{ rbenv_user }}
group={{ rbenv_user }}
dest={{ rbenv_dir }}/ruby_env
sudo_user: "{{ rbenv_user }}"
- name: rbenv | check ruby-build installed
command: test -x /usr/local/bin/ruby-build
register: rbuild_present
ignore_errors: yes
tags:
- ruby
- install
- name: rbenv | if ruby-build exists, which versions we can install
command: /usr/local/bin/ruby-build --definitions
when: rbuild_present|success
register: installable_ruby_vers
ignore_errors: yes
tags:
- ruby
- install
### in this block, we (re)install ruby-build if it doesn't exist or if it can't install the requested version
- name: rbenv | create temporary directory
command: mktemp -d
register: tempdir
sudo: true
sudo_user: "{{ rbenv_user }}"
when: rbuild_present|failed or (installable_ruby_vers is defined and rbenv_ruby_version not in installable_ruby_vers)
tags:
- ruby
- install
- name: rbenv | clone ruby-build repo
git: repo=https://github.com/sstephenson/ruby-build.git dest={{ tempdir.stdout }}/ruby-build
when: rbuild_present|failed or (installable_ruby_vers is defined and rbenv_ruby_version not in installable_ruby_vers)
sudo: true
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- install
- name: rbenv | install ruby-build
command: ./install.sh chdir={{ tempdir.stdout }}/ruby-build
when: rbuild_present|failed or (installable_ruby_vers is defined and rbenv_ruby_version not in installable_ruby_vers)
tags:
- ruby
- install
- name: rbenv | remove temporary directory
file: path={{ tempdir.stdout }} state=absent
when: rbuild_present|failed or (installable_ruby_vers is defined and rbenv_ruby_version not in installable_ruby_vers)
tags:
- ruby
- install
- name: rbenv | check ruby {{ rbenv_ruby_version }} installed
shell: "{{ rbenv_user_home }}/.rbenv/bin/rbenv versions | grep {{ rbenv_ruby_version }}"
shell: "rbenv versions | grep {{ rbenv_ruby_version }}"
register: ruby_installed
sudo: true
sudo_user: "{{ rbenv_user }}"
environment: "{{ rbenv_environment }}"
ignore_errors: yes
tags:
- ruby
- install
- name: rbenv | install ruby {{ rbenv_ruby_version }}
shell: "{{ rbenv_user_home }}/.rbenv/bin/rbenv install {{ rbenv_ruby_version }} creates={{rbenv_user_home}}/.rbenv/versions/{{rbenv_ruby_version}}"
shell: "rbenv install {{ rbenv_ruby_version }} creates={{ rbenv_dir }}/.rbenv/versions/{{ rbenv_ruby_version }}"
when: ruby_installed|failed
sudo: true
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- install
environment: "{{ rbenv_environment }}"
- name: rbenv | set global ruby {{ rbenv_ruby_version }}
shell: "{{rbenv_user_home }}/.rbenv/bin/rbenv global {{ rbenv_ruby_version }}"
sudo: true
shell: "rbenv global {{ rbenv_ruby_version }}"
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- install
environment: "{{ rbenv_environment }}"
- name: rbenv | install bundler
shell: "{{ rbenv_user_home }}/.rbenv/shims/gem install bundler -v {{ rbenv_bundler_version }}"
sudo: true
shell: "gem install bundler -v {{ rbenv_bundler_version }}"
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- install
environment: "{{ rbenv_environment }}"
- name: rbenv | rehash
shell: "{{rbenv_user_home}}/.rbenv/bin/rbenv rehash"
sudo: true
shell: "rbenv rehash"
sudo_user: "{{ rbenv_user }}"
tags:
- ruby
- install
environment: "{{ rbenv_environment }}"
##
## Managed by Ansible, do not edit.
##
export RBENV_ROOT="{{ rbenv_root }}"
export PATH=$RBENV_ROOT/bin/:$PATH
# {{ ansible_managed }}
{% for name,value in rbenv_environment.items() %}
{% if value %}
export {{ name }}="{{ value }}"
{% endif %}
{% endfor %}
eval "$(rbenv init -)"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment