Commit 4934e562 by John Jarvis

forum role cleanup

* consistent jinja variable syntax
* comment blocks on the tasks/main.yml files
* some syntax errors, variable name issues
* indenting, breaking up long lines
* various bug fixes
parent 4a5a7d19
- name: elasticsearch | check for elasticsearch
command: test -f /var/tmp/elasticsearch-${elasticsearch_version}.deb
ignore_errors: true
register: elasticsearch_present
---
- name: elasticsearch | download elasticsearch
get_url: url={{ elasticsearch_url }} dest=/var/tmp/{{ elasticsearch_file }}
when: elasticsearch_present|failed
tags:
- elasticsearch
- install
# elasticsearch
#
# Dependencies:
#
# * common
# * oraclejdk
#
# Example play:
#
# roles:
# - common
# - oraclejdk
# - elasticsearch
- name: elasticsearch | check elasticsearch version
shell: test -n "$(dpkg --list elasticsearch | grep {{ elasticsearch_version }})"
ignore_errors: true
register: elasticsearch_installed
- name: elasticsearch | download elasticsearch
get_url: >
url={{ elasticsearch_url }}
dest=/var/tmp/{{ elasticsearch_file }}
force=no
- name: elasticsearch | install elasticsearch from local package
shell: executable=/bin/bash dpkg -i /var/tmp/elasticsearch-${elasticsearch_version}.deb
when: elasticsearch_installed|failed
shell: >
dpkg -i /var/tmp/elasticsearch-{{ elasticsearch_version }}.deb
executable=/bin/bash
creates=/usr/share/elasticsearch/bin/elasticsearch
tags:
- elasticsearch
- install
......@@ -2,5 +2,5 @@
elasticsearch_version: "0.90.2"
elasticsearch_sha: "397227ce37f616734f39f6e93539c9eaa82bec9"
elasticsearch_file: "elasticsearch-${elastic_search_version}.deb"
elasticsearch_url: "https://download.elasticsearch.org/elasticsearch/elasticsearch/{{ elastic_search_file }}"
\ No newline at end of file
elasticsearch_file: "elasticsearch-{{ elasticsearch_version }}.deb"
elasticsearch_url: "https://download.elasticsearch.org/elasticsearch/elasticsearch/{{ elasticsearch_file }}"
---
- name: forum | restart the forum service
service: name=cs_comments_service state=restarted
\ No newline at end of file
service: name=cs_comments_service state=restarted
---
- name: forum | stop the forum service
service: name=cs_comments_service state=stopped
tags:
- deploy
- name: forum | git checkout forum repo into {{ forum_code_dir }}
git: dest={{ forum_code_dir }} repo={{ forum_source_repo }} version={{ forum_version }}
sudo: yes
sudo_user: "{{ forum_user }} "
sudo_user: "{{ forum_user }}"
notify:
- forum | restart the forum service
tags:
......@@ -12,8 +19,11 @@
shell: executable=/bin/bash {{ forum_home }}/.rbenv/shims/bundle install chdir={{ forum_code_dir }}
sudo: yes
sudo_user: "{{ forum_user }}"
notify:
- forum | restart the forum service
tags:
- forum
- deploy
\ No newline at end of file
- forum
- deploy
- name: forum | restart the forum service
service: name=cs_comments_service state=restarted
tags:
- deploy
---
# forum
#
# This role depends upon the rbenv role which needs to
# be included in the same playbook prior to this role.
# Dependencies:
#
# * common
# * elasticsearch
# * oraclejdk
# * rbenv
#
#
# Example play:
# roles:
# - common
# - oraclejdk
# - elasticsearch
# - role: rbenv
# rbenv_user: "{{ forum_user }}"
# rbenv_user_home: "{{ 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 }}
......@@ -40,17 +56,17 @@
tags:
- forum
- install
only_if: "'${ansible_distribution}' == 'Debian'"
when: ansible_distribution == 'Debian'
- 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=750
template: src=cs_comments_service.conf.j2 dest=/etc/init/cs_comments_service.conf owner=root group=root mode=644
notify:
- forum | restart the forum service
tags:
- forum
- install
only_if: "'${ansible_distribution}' == 'Ubuntu'"
when: ansible_distribution == 'Ubuntu'
- include: deploy.yml
- include: test.yml
\ No newline at end of file
- include: test.yml
---
- name: forum | test that the required service are listening
wait_for: port={{ item.port }} timeout=1
wait_for: port={{ item.port }} timeout=10
with_items: "{{ forum_services }}"
tags:
- forum
- test
\ No newline at end of file
- test
---
forum_user: "forum"
forum_home: "/opt/forum"
forum_home: "/opt/wwc/forum"
forum_ruby_version: "1.9.3-p448"
forum_code_dir: "{{ forum_home }}/cs_comments_service"
forum_source_repo: "https://github.com/edx/cs_comments_service.git"
......@@ -31,4 +31,4 @@ forum_services:
- {service: "mongo", host: "{{ forum_mongo_host }}", port: "27017"}
- {service: "mongo", host: "{{ forum_mongo_host }}", port: "28017"}
- {service: "elasticsearch", host: "{{ forum_elasticsearch_host }}", port: "9200"}
- {service: "elasticsearch", host: "{{ forum_elasticsearch_host }}", port: "9300"}
\ No newline at end of file
- {service: "elasticsearch", host: "{{ forum_elasticsearch_host }}", port: "9300"}
---
# oraclejdk
#
# Dependencies:
#
# * common
#
# Example play:
#
# roles:
# - common
# - oraclejdk
- name: oraclejdk | check for Oracle Java version {{ oraclejdk_base }}
command: test -d /usr/lib/jvm/{{ oraclejdk_base }}
ignore_errors: true
......@@ -7,11 +21,19 @@
- install
- name: oraclejdk | download Oracle Java
shell: executable="/bin/bash curl -b gpw_e24=http%3A%2F%2Fwww.oracle.com -O -L {{ oraclejdk_url }} chdir=/var/tmp" creates="/var/tmp/{ oraclejdk_file }"
shell: >
curl -b gpw_e24=http%3A%2F%2Fwww.oracle.com -O -L {{ oraclejdk_url }}
executable=/bin/bash
chdir=/var/tmp
creates=/var/tmp/{{ oraclejdk_file }}
when: oraclejdk_present|failed
- name: oraclejdk | install Oracle Java
shell: exectuable=/bin/bash mkdir -p /usr/lib/jvm && tar -C /usr/lib/jvm -zxvf /var/tmp/{{ oraclejdk_file }} creates="/usr/lib/jvm/{{ oraclejdk_base }}"
shell: >
mkdir -p /usr/lib/jvm && tar -C /usr/lib/jvm -zxvf /var/tmp/{{ oraclejdk_file }}
creates=/usr/lib/jvm/{{ oraclejdk_base }}
exectuable=/bin/bash
sudo: true
when: oraclejdk_present|failed
tags:
......@@ -30,4 +52,4 @@
when: oraclejdk_present|failed
tags:
- oraclejdk
- install
\ No newline at end of file
- install
---
# rbenv
#
# Dependencies:
#
# * common
#
# Example play:
#
# roles:
# - common
# - role: rbenv
# rbenv_user: "{{ forum_user }}"
# rbenv_user_home: "{{ forum_rbenv_dir }}"
# rbenv_ruby_version: "{{ forum_ruby_version }}"
#
# Parameters:
#
# * rbenv_user
# * rbenv_user_home
# * rbenv_ruby_version
#
# cribbed from https://github.com/mmoya/ansible-playbooks/blob/master/rbenv/main.yml
# with a number of changes.
......@@ -12,21 +34,35 @@
- fail: rbenv_ruby_version required for role
when: rbenv_ruby_version is not defined
#
# It's unfortunate that this needs to happen here,
# but the rbenv needs to exist when the service
# that relies on it is provisioned and the service
# user and it's home needs to exist for rbenv to
# install into.
#
- name: rbenv | create rbenv owner $forum_user
user: name=$forum_user state=present shell=/bin/bash home=$forum_home
- 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
file: >
path={{ rbenv_user_home }}
owner={{ rbenv_user }}
group={{ rbenv_user }}
state=directory
- name: rbenv | install build depends
apt: pkg=$item state=present install_recommends=no
apt: pkg={{ item }} state=present install_recommends=no
with_items:
- build-essential
- git
......@@ -42,7 +78,10 @@
- install
- name: rbenv | update rbenv repo
git: repo=https://github.com/sstephenson/rbenv.git dest={{ rbenv_user_home }}/.rbenv version={{ rbenv_version }}
git: >
repo=https://github.com/sstephenson/rbenv.git
dest={{ rbenv_user_home }}/.rbenv
version={{ rbenv_version }}
sudo: true
sudo_user: "{{ rbenv_user }}"
tags:
......@@ -58,11 +97,19 @@
- 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 }}
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 }}
template: >
src=ruby_env.j2
dest={{ rbenv_user_home }}/ruby_env
owner={{ rbenv_user }}
group={{ rbenv_user }}
tags:
- ruby
- update
......@@ -74,7 +121,11 @@
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 }}
copy: >
src=../../common/files/bash_profile
dest={{ rbenv_user_home }}/.bash_profile
owner={{ rbenv_user }}
group={{ rbenv_user }}
- name: rbenv | check ruby-build installed
command: test -x /usr/local/bin/ruby-build
......@@ -95,7 +146,7 @@
- install
- name: rbenv | clone ruby-build repo
git: repo=https://github.com/sstephenson/ruby-build.git dest=${tempdir.stdout}/ruby-build
git: repo=https://github.com/sstephenson/ruby-build.git dest={{ tempdir.stdout }}/ruby-build
when: rbuild_present|failed
sudo: true
sudo_user: "{{ rbenv_user }}"
......@@ -160,4 +211,4 @@
when: ruby_installed|failed
tags:
- ruby
- install
\ No newline at end of file
- install
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