diff --git a/.gitignore b/.gitignore index 2931d08a..02f9b0d7 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ # ignore the Ruby Version manager (rvm) .rvmrc -.ruby-version .ruby-gemset .rbenv bundler_stubs/* diff --git a/.rspec b/.rspec index 83e16f80..de758c7a 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --color +--tty --require spec_helper diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..21bb5e15 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.2.5 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f4fec07c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM ruby:2.2.5 + +RUN gem update --system 2.6.1 +RUN gem install bundler --version $BUNDLER_VERSION + +RUN apt-get update -qq && apt-get install -y build-essential + +# ImageMagick +RUN apt-get install -y imagemagick + +# PostgreSQL +RUN apt-get install -y libpq-dev + +# Node.js runtime +RUN apt-get install -y nodejs + +# Set directory for our app +ENV APP_HOME /code-corps-api +RUN mkdir $APP_HOME + +# Copy Gemfile and bundle +WORKDIR $APP_HOME +COPY Gemfile $APP_HOME/Gemfile +COPY Gemfile.lock $APP_HOME/Gemfile.lock +RUN bundle install + +# Copy code +ADD . $APP_HOME diff --git a/Gemfile b/Gemfile index fda3c486..c0270fb1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source "https://rubygems.org" -ruby "2.2.3" +ruby "2.2.5" gem "rails", "5.0.0" @@ -57,7 +57,9 @@ end group :development do gem "foreman" + gem "guard-rspec", require: false gem "sinatra", github: "sinatra", require: nil # for Sidekiq UI to work in development + gem "spring-commands-rspec" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 84a59f5c..a73315ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,12 +158,28 @@ GEM redis (~> 3.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) + ffi (1.9.13) foreman (0.82.0) thor (~> 0.19.1) + formatador (0.2.5) full-name-splitter (0.1.2) github-markdown (0.6.9) globalid (0.3.6) activesupport (>= 4.1.0) + guard (2.14.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rspec (4.7.2) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) hashdiff (0.3.0) hashie (3.4.4) html-pipeline (1.11.0) @@ -190,8 +206,13 @@ GEM addressable faraday multi_json + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) loofah (2.0.3) nokogiri (>= 1.5.9) + lumberjack (1.0.10) mail (2.6.4) mime-types (>= 1.16, < 4) method_source (0.8.2) @@ -206,11 +227,15 @@ GEM multipart-post (2.0.0) mustermann (0.4.0) tool (~> 0.2) + nenv (0.3.0) newrelic_rpm (3.16.0.318) nio4r (1.2.1) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) + notiffany (0.1.0) + nenv (~> 0.1) + shellany (~> 0.0) oauth2 (1.2.0) faraday (>= 0.8, < 0.10) jwt (~> 1.0) @@ -282,6 +307,9 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (11.2.2) + rb-fsevent (0.9.7) + rb-inotify (0.9.7) + ffi (>= 0.5.0) redis (3.3.0) rouge (1.11.1) rspec (3.5.0) @@ -308,6 +336,7 @@ GEM rspec (~> 3.0, >= 3.0.0) sidekiq (>= 2.4.0) rspec-support (3.5.0) + ruby_dep (1.3.1) safe_yaml (1.0.4) searchkick (1.3.0) activemodel @@ -321,6 +350,7 @@ GEM sequenced (3.1.1) activerecord (>= 3.0) activesupport (>= 3.0) + shellany (0.0.1) shoulda-matchers (3.0.1) activesupport (>= 4.0.0) sidekiq (4.1.2) @@ -334,6 +364,8 @@ GEM simplecov-html (0.10.0) slop (3.6.0) spring (1.7.2) + spring-commands-rspec (1.0.4) + spring (>= 0.9.1) sprockets (3.6.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -388,6 +420,7 @@ DEPENDENCIES foreman full-name-splitter github-markdown + guard-rspec hashie html-pipeline html-pipeline-rouge_filter @@ -420,6 +453,7 @@ DEPENDENCIES sidekiq sinatra! spring + spring-commands-rspec strip_attributes vcr webmock diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000..3215f013 --- /dev/null +++ b/Guardfile @@ -0,0 +1,70 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +# directories %w(app lib config test spec features) \ +# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch "config/Guardfile" instead of "Guardfile" + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separately) +# * 'just' rspec: 'rspec' + +guard :rspec, cmd: "bundle exec rspec" do + require "guard/rspec/dsl" + dsl = Guard::RSpec::Dsl.new(self) + + # Feel free to open issues for suggestions and improvements + + # RSpec files + rspec = dsl.rspec + watch(rspec.spec_helper) { rspec.spec_dir } + watch(rspec.spec_support) { rspec.spec_dir } + watch(rspec.spec_files) + + # Ruby files + ruby = dsl.ruby + dsl.watch_spec_files_for(ruby.lib_files) + + # Rails files + rails = dsl.rails(view_extensions: %w(erb haml slim)) + dsl.watch_spec_files_for(rails.app_files) + dsl.watch_spec_files_for(rails.views) + + watch(rails.controllers) do |m| + [ + rspec.spec.call("routing/#{m[1]}_routing"), + rspec.spec.call("controllers/#{m[1]}_controller"), + rspec.spec.call("acceptance/#{m[1]}") + ] + end + + # Rails config changes + watch(rails.spec_helper) { rspec.spec_dir } + watch(rails.routes) { "#{rspec.spec_dir}/routing" } + watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } + + # Capybara features specs + watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") } + watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| + Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" + end +end diff --git a/Procfile.dev b/Procfile.dev index c706ab29..a10fa2f4 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,3 +1,2 @@ web: bundle exec puma -C config/puma.rb worker: bundle exec sidekiq -q high -q default -q low -redis: redis-server diff --git a/README.md b/README.md index f14b5ff9..36b4b576 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,20 @@ We'd love to have you contribute to Code Corps directly! To do so, please read the guidelines in our [`CONTRIBUTING.md`](CONTRIBUTING.md). -Then head over to [Code Corps](https://codecorps.org), where we manage contributions. +Then check out some GitHub issues to see where you can help out. ## Developer installation guide ### Recommended install -To make your life easier, you can just clone this repository and use our Vagrant development box. [Follow this guide to get started.](docs/DEFAULT_INSTALL.md) +To make your life easier, you can just clone this repository and use our Docker container. [Follow this guide to get started.](docs/DEFAULT_INSTALL.md) #### Custom install We wholeheartedly recommend against doing a custom install. You'll be spending more time configuring and less time being productive. But if you'd like to work that way, you can read our [custom install guide](docs/CUSTOM_INSTALL.md). -### Working with Ember + +### Serving Ember The Code Corps API is intended to work alongside a client written in Ember. For that purpose, the Rails application exposes all of its API endpoints behind an `api.` subdomain. @@ -42,7 +43,7 @@ Any server request pointing to the main domain and not the `api.` subdomain is r * a plain text string containing "INDEX NOT FOUND" if a revision was specified, but the key for the specified revision was not found by redis -### Debugging the API +### Debugging Because the app is running `foreman`, debugging using `pry` won't work the same way. If you want to use `pry`, you'll need to [debug remotely](https://github.com/nixme/pry-debugger#remote-debugging). @@ -60,11 +61,15 @@ end Load a page or make a request that triggers the code. Connect to the session: ```shell -$ bundle exec pry-remote +$ docker-compose run web pry-remote ``` ## Built with -- [Rails::API](https://github.com/rails-api/rails-api) — Our backend API is a Rails::API app which uses JSON API to respond RESTfully to requests. -- [Ember.js](https://github.com/emberjs/ember.js) — Our frontend is an Ember.js app that communicates with the Rails API. -- [PostgreSQL](http://www.postgresql.org/) — Our primary data store uses Postgres. +- [Rails](http://edgeguides.rubyonrails.org/api_app.html) — Our backend API uses Rails 5 in its API-only configuration. +- [ActiveModelSerializers](https://github.com/rails-api/active_model_serializers) - We use AMS to serialize the JSON responses from our API. +- [Ember.js](https://github.com/emberjs/ember.js) — Our frontend is an Ember.js app that communicates with the Rails JSON API. +- [PostgreSQL](http://www.postgresql.org/) — Our primary data store. +- [Redis](http://redis.io/) — Redis for a variety of NoSQL uses. +- [Elasticsearch](https://www.elastic.co/products/elasticsearch) — Elasticsearch for searching documents. +- [Docker](https://www.docker.com) — Docker for containerized development environments. diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 8cae56de..00000000 --- a/Vagrantfile +++ /dev/null @@ -1,108 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.require_version ">= 1.5" - -def require_plugins(plugins = {}) - needs_restart = false - plugins.each do |plugin, version| - next if Vagrant.has_plugin?(plugin) - cmd = - [ - "vagrant plugin install", - plugin - ] - cmd << "--plugin-version #{version}" if version - system(cmd.join(" ")) || exit! - needs_restart = true - end - exit system("vagrant", *ARGV) if needs_restart -end - -require_plugins \ - "vagrant-bindfs" => "0.3.2", - "vagrant-hostmanager" => "1.8.2" - -def ansible_installed? - exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""] - ENV["PATH"].split(File::PATH_SEPARATOR).any? do |p| - exts.any? do |ext| - full_path = File.join(p, "ansible-playbook#{ext}") - File.executable?(full_path) && File.file?(full_path) - end - end -end - -Vagrant.configure("2") do |config| - config.vm.provider :virtualbox do |vb| - host = RbConfig::CONFIG["host_os"] - - if host =~ /darwin/ # OS X - # sysctl returns bytes, convert to MB - vb.memory = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 3 - vb.cpus = `sysctl -n hw.ncpu`.to_i - elsif host =~ /linux/ # Linux - # meminfo returns kilobytes, convert to MB - memtotal = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i - vb.memory = memtotal / 1024 / 2 - vb.cpus = `nproc`.to_i - end - - vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] - end - - if Vagrant.has_plugin? "vagrant-hostmanager" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.aliases = %w(api.codecorps.dev codecorps.dev www.codecorps.dev) - else - fail_with_message "vagrant-hostmanager missing" - end - - config.vm.define "code-corps-api" do |machine| - machine.vm.box = "ubuntu/trusty64" - - machine.vm.hostname = "localhost" - - machine.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true - machine.vm.network "forwarded_port", guest: 443, host: 8081, auto_correct: true - machine.vm.network "forwarded_port", guest: 5000, host: 5000, auto_correct: true - machine.vm.network "forwarded_port", guest: 6379, host: 6379, auto_correct: true - machine.vm.network "private_network", ip: "192.168.20.50" - - mount_options = ["rw", "vers=3", "tcp", "fsc", "actimeo=2"] - - machine.vm.synced_folder ".", - "/code-corps-api", - type: "nfs", - mount_options: mount_options - machine.bindfs.bind_folder "/code-corps-api", "/code-corps-api" - end - - config.ssh.forward_agent = true - - if ansible_installed? - config.vm.provision :hostmanager - - config.vm.provision "ansible" do |ansible| - ansible.playbook = "ansible/site.yml" - ansible.sudo = true - ansible.groups = { - "application" => %w(code-corps-api), - "vm" => %w(code-corps-api), - "postgresql" => %w(code-corps-api), - "elasticsearch" => %w(code-corps-api), - "sidekiq" => %w(code-corps-api), - "foreman" => %w(code-corps-api), - "development:children" => %w(application vm postgresql elasticsearch sidekiq foreman), - } - ansible.tags = ENV["TAGS"] - ansible.raw_arguments = ENV["ANSIBLE_ARGS"] - end - else - Dir["shell/*.sh"].each do |script| - config.vm.provision "shell", path: script, privileged: false, args: ENV["ANSIBLE_ARGS"] - end - end -end diff --git a/ansible.cfg b/ansible.cfg deleted file mode 100644 index 2c0b5b57..00000000 --- a/ansible.cfg +++ /dev/null @@ -1,8 +0,0 @@ -[defaults] -remote_user = vagrant -hostfile = .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -private_key_file = ~/.vagrant.d/insecure_private_key -hash_behaviour = merge - -[ssh_connection] -ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s diff --git a/ansible/deploy.yml b/ansible/deploy.yml deleted file mode 100644 index e44bd0c9..00000000 --- a/ansible/deploy.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- hosts: application - sudo: no - remote_user: '{{ user_name }}' - roles: - - deploy diff --git a/ansible/group_vars/all/config.yml b/ansible/group_vars/all/config.yml deleted file mode 100644 index 8358c536..00000000 --- a/ansible/group_vars/all/config.yml +++ /dev/null @@ -1,74 +0,0 @@ ---- -vm_name: code-corps-api -path: /code-corps-api -git_branch: develop -vm_os: ubuntu/trusty64 -environments: - - development -package_bundles: - - curl - - graphics - - qt -packages: - - curl - - libcurl3 - - libcurl3-gnutls - - libcurl4-openssl-dev - - imagemagick - - qt5-default - - libqt5webkit5-dev - -server_name: localhost -manual_ruby_version: 2.2.3 -rails_version: 4 -ruby_install: rbenv -ruby_version: 2.2-head -environment_file: /code-corps-api/.envrc -databases: - - postgresql -background_jobs: - - sidekiq -postgresql_orm: none -redis_orm: none -postgresql_db_name: code-corps-api -postgresql_db_user: vagrant -postgresql_db_password: password -postgresql_extensions: - - hstore -delayed_job_command: script/delayed_job run -sidekiq_command: sidekiq -redis_port: 6379 -redis_bind_interface: 0.0.0.0 -resque_command: rake resque:work -server_type: nginx_puma -git_url: -sidekiq_app_name: code-corps-api-sidekiq - -app_name: '{{ vm_name }}' -user_name: '{{ "vagrant" if target == "virtualbox" else app_name }}' -group_name: '{{ user_name }}' - -user_home_path: '/home/{{ user_name }}' - -ssl_certificate_path: /etc/nginx/ssl/{{ server_name }}.crt -ssl_certificate_key_path: /etc/nginx/ssl/{{ server_name }}.key - -releases_path: '{{ path }}/releases' -shared_path: '{{ path }}/shared' - -app_path: '{{ path }}{{ "/current" if target != "virtualbox" else "" }}' -app_public_path: "{{ app_path }}/public" -app_config_path: '{{ app_path }}/config' -shared_config_path: '{{ app_path if target == "virtualbox" else shared_path }}/config' -app_temp_path: "/tmp{{ app_path }}" -app_logs_path: "{{ app_path }}/log" - -puma_bind_path: "unix://{{ app_temp_path }}/sockets/puma.{{ rails_env }}.sock" -puma_config_path: "{{ app_config_path }}/puma.{{ rails_env }}.rb" -puma_pidfile_path: "{{ app_temp_path }}/pids/puma.{{ rails_env }}.pid" -puma_stderr_redirect_path: "{{ app_logs_path }}/puma.{{ rails_env }}.err.log" -puma_stdout_redirect_path: "{{ app_logs_path }}/puma.{{ rails_env }}.log" - -ruby_user_name: '{{ "root" if ruby_install == "package" else user_name }}' - -use_apt_proxy: false diff --git a/ansible/group_vars/development/config.yml b/ansible/group_vars/development/config.yml deleted file mode 100644 index 6da98ddd..00000000 --- a/ansible/group_vars/development/config.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -rails_env: development -target: virtualbox -autoconf: true -vm_memory: 1024 -vm_swap: 1024 -vm_cores: 2 -vm_share_type: nfs -vm_ip: 192.168.20.50 -host: -port: -username: diff --git a/ansible/roles/apt_proxy/tasks/main.yml b/ansible/roles/apt_proxy/tasks/main.yml deleted file mode 100644 index 3bd50380..00000000 --- a/ansible/roles/apt_proxy/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Setup apt-get proxy - template: src=01proxy.j2 dest=/etc/apt/apt.conf.d/01proxy diff --git a/ansible/roles/apt_proxy/templates/01proxy.j2 b/ansible/roles/apt_proxy/templates/01proxy.j2 deleted file mode 100644 index 4b234993..00000000 --- a/ansible/roles/apt_proxy/templates/01proxy.j2 +++ /dev/null @@ -1,8 +0,0 @@ -Acquire::http { Proxy "http://192.168.59.103:8000"; }; - -Acquire::http::Proxy::oss-binaries.phusionpassenger.com DIRECT; -Acquire::http::Proxy::ppa.launchpad.net DIRECT; -Acquire::http::Proxy::ftp.osuosl.org DIRECT; -Acquire::http::Proxy::ppa:nginx/stable DIRECT; -Acquire::http::Proxy::ppa:brightbox/ruby-ng DIRECT; -Acquire::http::Proxy::ppa:ansible/ansible DIRECT; diff --git a/ansible/roles/base/defaults/main.yml b/ansible/roles/base/defaults/main.yml deleted file mode 100644 index 95b6a8ec..00000000 --- a/ansible/roles/base/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -profile_d_path: '{{ user_home_path }}/profile.d' diff --git a/ansible/roles/base/tasks/main.yml b/ansible/roles/base/tasks/main.yml deleted file mode 100644 index 596cc924..00000000 --- a/ansible/roles/base/tasks/main.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- name: Update apt cache - apt: - update_cache: yes - cache_valid_time: 3600 - - -- name: Install apt dependencies - apt: name={{ item }} - with_items: - - autoconf - - bison - - build-essential - - libssl-dev - - libyaml-dev - - libreadline6-dev - - zlib1g-dev - - libncurses5-dev - - nodejs - - python-pip - - python-dev - - htop - - git - - libgmp-dev - - libpq-dev - -- name: Install additional packages - apt: name={{ item }} - with_items: packages - when: packages - -- name: Create application group - group: name={{ group_name }} - -- name: Create application user - user: name={{ user_name }} group={{ group_name }} shell=/bin/bash home={{ user_home_path }} - -- name: Setup script to read application environment - template: src=read_environment.sh.j2 dest=/etc/profile.d/read_environment.sh - notify: - - restart application - - restart sidekiq - -- name: Create temp directory - file: path={{ app_temp_path }} state=directory - sudo: no - -- name: Create profile.d directory - file: path={{ profile_d_path }} state=directory owner={{ user_name }} group={{ group_name }} - -- name: Create ~/.bash_profile which loads all from ~/profile.d - template: src=bash_profile.j2 dest={{ user_home_path }}/.bash_profile owner={{ user_name }} group={{ group_name }} diff --git a/ansible/roles/base/templates/bash_profile.j2 b/ansible/roles/base/templates/bash_profile.j2 deleted file mode 100644 index 431bdaa7..00000000 --- a/ansible/roles/base/templates/bash_profile.j2 +++ /dev/null @@ -1,14 +0,0 @@ -# {{ ansible_managed }} - -if [ -f ~/.bashrc ]; then - . ~/.bashrc -fi - -if [ -d {{ profile_d_path }} ]; then - for i in {{ profile_d_path }}/*.sh; do - if [ -r $i ]; then - . $i - fi - done - unset i -fi diff --git a/ansible/roles/base/templates/read_environment.sh.j2 b/ansible/roles/base/templates/read_environment.sh.j2 deleted file mode 100644 index 5d6b3cbe..00000000 --- a/ansible/roles/base/templates/read_environment.sh.j2 +++ /dev/null @@ -1,5 +0,0 @@ -# {{ ansible_managed }} - -if [ -f {{ environment_file }} ]; then - . {{ environment_file }} -fi diff --git a/ansible/roles/deploy/defaults/main.yml b/ansible/roles/deploy/defaults/main.yml deleted file mode 100644 index 993cfaaf..00000000 --- a/ansible/roles/deploy/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -keep_releases: 5 diff --git a/ansible/roles/deploy/handlers/main.yml b/ansible/roles/deploy/handlers/main.yml deleted file mode 100644 index ab5dee2a..00000000 --- a/ansible/roles/deploy/handlers/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- include: ../../sidekiq/handlers/main.yml diff --git a/ansible/roles/deploy/tasks/main.yml b/ansible/roles/deploy/tasks/main.yml deleted file mode 100644 index 2a7a7319..00000000 --- a/ansible/roles/deploy/tasks/main.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -- include_vars: ../../puma/defaults/main.yml -- include_vars: ../../sidekiq/defaults/main.yml - -- set_fact: this_release_path={{ releases_path }}/{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }} - -- debug: msg='New release path {{ this_release_path }}' - -- name: Create new release dir - file: path={{ this_release_path }} state=directory - -- name: Update code - git: repo={{ git_url }} dest={{ this_release_path }} version={{ git_branch }} accept_hostkey=yes - register: git - notify: - - restart sidekiq - -- debug: msg='Updated repo from {{ git.before }} to {{ git.after }}' - -- name: Delete log directory - file: path={{ this_release_path }}/log state=absent - -- name: Symlink shared files - file: src={{ shared_path }}/{{ item }} dest={{ this_release_path }}/{{ item }} state=link force=yes - with_items: - - config/database.yml - - config/secrets.yml - - config/puma.{{ rails_env }}.rb - - log - - tmp - - vendor/bundle - -- name: Install gems - command: /bin/bash -lc 'bundle install --deployment --without="development test"' - args: - chdir: '{{ this_release_path }}' - -- name: Precompile assets - command: /bin/bash -lc 'bundle exec rake assets:precompile' - environment: - RAILS_ENV: '{{ rails_env }}' - args: - chdir: '{{ this_release_path }}' - -- name: Migrate database - command: /bin/bash -lc 'bundle exec rake db:migrate' - environment: - RAILS_ENV: '{{ rails_env }}' - args: - chdir: '{{ this_release_path }}' - -- name: Symlink new release - file: src={{ this_release_path }} dest={{ app_path }} state=link force=yes - -- name: Restart webserver - command: sudo {{ server_restart_command }} - -- name: Cleanup - shell: "ls -1t {{ releases_path }}|tail -n +{{ keep_releases + 1 }}|xargs rm -rf" - args: - chdir: '{{ releases_path }}' diff --git a/ansible/roles/geerlingguy.elasticsearch/.travis.yml b/ansible/roles/geerlingguy.elasticsearch/.travis.yml deleted file mode 100644 index dcd413c4..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ ---- -sudo: required - -env: - - distribution: centos - version: 6 - init: /sbin/init - run_opts: "" - - distribution: centos - version: 7 - init: /usr/lib/systemd/systemd - run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - - distribution: ubuntu - version: 14.04 - init: /sbin/init - run_opts: "" - - distribution: ubuntu - version: 12.04 - init: /sbin/init - run_opts: "" - -services: - - docker - -before_install: - # Pull container - - 'sudo docker pull ${distribution}:${version}' - # Customize container - - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' - -script: - - container_id=$(mktemp) - # Run container in detached state - - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"' - - # Install required Galaxy roles. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-galaxy install geerlingguy.java' - - # Ansible syntax check. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' - - # Test role. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' - - # TODO: Test if elasticsearch is working. - - # Test role idempotence. - - > - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - # Clean up - - 'sudo docker stop "$(cat ${container_id})"' - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/ansible/roles/geerlingguy.elasticsearch/README.md b/ansible/roles/geerlingguy.elasticsearch/README.md deleted file mode 100644 index 3f6527b2..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Ansible Role: Elasticsearch - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-elasticsearch.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-elasticsearch) - -An Ansible Role that installs Elasticsearch on RedHat/CentOS or Debian/Ubuntu. - -## Requirements - -None. - -## Role Variables - -None. - -## Dependencies - - - geerlingguy.java - -## Example Playbook - - - hosts: search - roles: - - { role: geerlingguy.java } - - { role: geerlingguy.elasticsearch } - -## License - -MIT / BSD - -## Author Information - -This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/). diff --git a/ansible/roles/geerlingguy.elasticsearch/files/elasticsearch.repo b/ansible/roles/geerlingguy.elasticsearch/files/elasticsearch.repo deleted file mode 100644 index e9d28a61..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/files/elasticsearch.repo +++ /dev/null @@ -1,6 +0,0 @@ -[elasticsearch-2.x] -name=Elasticsearch repository for 2.x packages -baseurl=http://packages.elastic.co/elasticsearch/2.x/centos -gpgcheck=1 -gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch -enabled=1 diff --git a/ansible/roles/geerlingguy.elasticsearch/handlers/main.yml b/ansible/roles/geerlingguy.elasticsearch/handlers/main.yml deleted file mode 100644 index a4c1162a..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: restart elasticsearch - service: name=elasticsearch state=restarted diff --git a/ansible/roles/geerlingguy.elasticsearch/meta/.galaxy_install_info b/ansible/roles/geerlingguy.elasticsearch/meta/.galaxy_install_info deleted file mode 100644 index 54c7ae5c..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/meta/.galaxy_install_info +++ /dev/null @@ -1 +0,0 @@ -{install_date: 'Tue Jul 5 20:00:11 2016', version: 2.0.1} diff --git a/ansible/roles/geerlingguy.elasticsearch/meta/main.yml b/ansible/roles/geerlingguy.elasticsearch/meta/main.yml deleted file mode 100644 index 8285a4b9..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/meta/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -dependencies: - - { role: geerlingguy.java } - -galaxy_info: - author: geerlingguy - description: Elasticsearch for Linux. - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 1.8 - platforms: - - name: EL - versions: - - all - - name: Debian - versions: - - all - - name: Ubuntu - versions: - - all - galaxy_tags: - - web - - system - - monitoring diff --git a/ansible/roles/geerlingguy.elasticsearch/tasks/main.yml b/ansible/roles/geerlingguy.elasticsearch/tasks/main.yml deleted file mode 100644 index 0c342640..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tasks/main.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- include: setup-RedHat.yml - when: ansible_os_family == 'RedHat' - -- include: setup-Debian.yml - when: ansible_os_family == 'Debian' - -- name: Configure Elasticsearch. - lineinfile: > - dest=/etc/elasticsearch/elasticsearch.yml - regexp="{{ item.regexp }}" - line="{{ item.line }}" - state=present - with_items: - - { regexp: '^script\.inline', line: 'script.inline: on' } - - { regexp: '^script\.indexed', line: 'script.indexed: on' } - - { regexp: 'network\.host', line: 'network.host: localhost' } - notify: restart elasticsearch - -- name: Start Elasticsearch. - service: name=elasticsearch state=started enabled=yes diff --git a/ansible/roles/geerlingguy.elasticsearch/tasks/setup-Debian.yml b/ansible/roles/geerlingguy.elasticsearch/tasks/setup-Debian.yml deleted file mode 100644 index bafa0d5a..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tasks/setup-Debian.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Add Elasticsearch apt key. - apt_key: - url: https://packages.elastic.co/GPG-KEY-elasticsearch - state: present - -- name: Add Elasticsearch repository. - apt_repository: - repo: 'deb http://packages.elastic.co/elasticsearch/2.x/debian stable main' - state: present - update_cache: yes - -- name: Install Elasticsearch. - apt: pkg=elasticsearch state=present diff --git a/ansible/roles/geerlingguy.elasticsearch/tasks/setup-RedHat.yml b/ansible/roles/geerlingguy.elasticsearch/tasks/setup-RedHat.yml deleted file mode 100644 index 543cce2f..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tasks/setup-RedHat.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Add Elasticsearch GPG key. - rpm_key: - key: https://packages.elastic.co/GPG-KEY-elasticsearch - state: present - -- name: Add Elasticsearch repository. - copy: - src: elasticsearch.repo - dest: /etc/yum.repos.d/elasticsearch.repo - mode: 0644 - -- name: Install Elasticsearch. - yum: pkg=elasticsearch state=installed diff --git a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.centos-6 b/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.centos-6 deleted file mode 100644 index 4a4e7b8d..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.centos-6 +++ /dev/null @@ -1,15 +0,0 @@ -FROM centos:6 - -# Install Ansible -RUN yum -y update; yum clean all; -RUN yum -y install epel-release -RUN yum -y install git ansible sudo -RUN yum clean all - -# Disable requiretty -RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers - -# Install Ansible inventory file -RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts - -CMD ["/usr/sbin/init"] diff --git a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.centos-7 b/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.centos-7 deleted file mode 100644 index 8aa06549..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.centos-7 +++ /dev/null @@ -1,27 +0,0 @@ -FROM centos:7 - -# Install systemd -- See https://hub.docker.com/_/centos/ -RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs -RUN yum -y update; yum clean all; \ -(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ -rm -f /lib/systemd/system/multi-user.target.wants/*; \ -rm -f /etc/systemd/system/*.wants/*; \ -rm -f /lib/systemd/system/local-fs.target.wants/*; \ -rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ -rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ -rm -f /lib/systemd/system/basic.target.wants/*; \ -rm -f /lib/systemd/system/anaconda.target.wants/*; - -# Install Ansible -RUN yum -y install epel-release -RUN yum -y install git ansible sudo -RUN yum clean all - -# Disable requiretty -RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers - -# Install Ansible inventory file -RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts - -VOLUME ["/sys/fs/cgroup"] -CMD ["/usr/sbin/init"] diff --git a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.ubuntu-12.04 b/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.ubuntu-12.04 deleted file mode 100644 index d0c130cd..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.ubuntu-12.04 +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:12.04 -RUN apt-get update - -# Install Ansible -RUN apt-get install -y software-properties-common python-software-properties git -RUN apt-add-repository -y ppa:ansible/ansible -RUN apt-get update -RUN apt-get install -y ansible - -# Install Ansible inventory file -RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts diff --git a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.ubuntu-14.04 b/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.ubuntu-14.04 deleted file mode 100644 index ca332871..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tests/Dockerfile.ubuntu-14.04 +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:14.04 -RUN apt-get update - -# Install Ansible -RUN apt-get install -y software-properties-common git -RUN apt-add-repository -y ppa:ansible/ansible -RUN apt-get update -RUN apt-get install -y ansible - -# Install Ansible inventory file -RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts diff --git a/ansible/roles/geerlingguy.elasticsearch/tests/test.yml b/ansible/roles/geerlingguy.elasticsearch/tests/test.yml deleted file mode 100644 index a289f8d1..00000000 --- a/ansible/roles/geerlingguy.elasticsearch/tests/test.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- hosts: all - - pre_tasks: - - name: Ensure build dependencies are installed (RedHat). - yum: name=which state=present - when: ansible_os_family == 'RedHat' - - roles: - - geerlingguy.java - - role_under_test diff --git a/ansible/roles/geerlingguy.java/.travis.yml b/ansible/roles/geerlingguy.java/.travis.yml deleted file mode 100644 index e14ea79f..00000000 --- a/ansible/roles/geerlingguy.java/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -sudo: required - -env: - - distribution: centos - version: 6 - init: /sbin/init - run_opts: "" - - distribution: centos - version: 7 - init: /usr/lib/systemd/systemd - run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - - distribution: ubuntu - version: 14.04 - init: /sbin/init - run_opts: "" - - distribution: ubuntu - version: 12.04 - init: /sbin/init - run_opts: "" - -services: - - docker - -before_install: - # Pull container - - 'sudo docker pull ${distribution}:${version}' - # Customize container - - 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' - -script: - - container_id=$(mktemp) - # Run container in detached state - - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"' - - # Ansible syntax check. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' - - # Test role. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml' - - # Test role idempotence. - - > - sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - # Ensure daemonize is available. - - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm which java' - - # Clean up - - 'sudo docker stop "$(cat ${container_id})"' - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ - diff --git a/ansible/roles/geerlingguy.java/README.md b/ansible/roles/geerlingguy.java/README.md deleted file mode 100644 index 483ad3f5..00000000 --- a/ansible/roles/geerlingguy.java/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# Ansible Role: Java - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-java.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-java) - -Installs Java for RedHat/CentOS and Debian/Ubuntu linux servers. - -## Requirements - -None. - -## Role Variables - -Available variables are listed below, along with default values: - - # The defaults provided by this role are specific to each distribution. - java_packages: - - java-1.7.0-openjdk - -Set the version/development kit of Java to install, along with any other necessary Java packages. Some other options include are included in the distribution-specific files in this role's 'defaults' folder. - -## Dependencies - -None. - -## Example Playbook (using default package, usually OpenJDK 7) - - - hosts: servers - roles: - - geerlingguy.java - -## Example Playbook (install OpenJDK 8) - -For RHEL / CentOS: - - - hosts: server - roles: - - role: geerlingguy.java - when: "ansible_os_family == 'RedHat'" - java_packages: - - java-1.8.0-openjdk - -For Ubuntu < 16.04: - - - hosts: server - tasks: - - name: installing repo for Java 8 in Ubuntu - apt_repository: repo='ppa:openjdk-r/ppa' - - - hosts: server - roles: - - role: geerlingguy.java - when: "ansible_os_family == 'Debian'" - java_packages: - - openjdk-8-jdk - -## License - -MIT / BSD - -## Author Information - -This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/). diff --git a/ansible/roles/geerlingguy.java/defaults/main.yml b/ansible/roles/geerlingguy.java/defaults/main.yml deleted file mode 100644 index 43a7a022..00000000 --- a/ansible/roles/geerlingguy.java/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -# Set java_packages if you would like to use a different version than the -# default (OpenJDK 1.7). -# java_packages: [] diff --git a/ansible/roles/geerlingguy.java/meta/.galaxy_install_info b/ansible/roles/geerlingguy.java/meta/.galaxy_install_info deleted file mode 100644 index db3b5bd1..00000000 --- a/ansible/roles/geerlingguy.java/meta/.galaxy_install_info +++ /dev/null @@ -1 +0,0 @@ -{install_date: 'Tue Jul 5 20:00:14 2016', version: 1.4.0} diff --git a/ansible/roles/geerlingguy.java/meta/main.yml b/ansible/roles/geerlingguy.java/meta/main.yml deleted file mode 100644 index 526ffadc..00000000 --- a/ansible/roles/geerlingguy.java/meta/main.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -dependencies: [] - -galaxy_info: - author: geerlingguy - description: Java for Linux - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 1.9 - platforms: - - name: EL - versions: - - 6 - - 7 - - name: Debian - versions: - - all - - name: Ubuntu - versions: - - all - - name: FreeBSD - versions: - - 10.2 - galaxy_tags: - - development - - system - - web diff --git a/ansible/roles/geerlingguy.java/tasks/main.yml b/ansible/roles/geerlingguy.java/tasks/main.yml deleted file mode 100644 index 95f5b56b..00000000 --- a/ansible/roles/geerlingguy.java/tasks/main.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Include OS-specific variables. - include_vars: "{{ ansible_os_family }}.yml" - when: ansible_distribution != 'Ubuntu' - -- name: Include version-specific variables for Ubuntu. - include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml" - when: ansible_distribution == 'Ubuntu' - -- name: Define java_packages. - set_fact: - java_packages: "{{ __java_packages | list }}" - when: java_packages is not defined - -# Setup/install tasks. -- include: setup-RedHat.yml - when: ansible_os_family == 'RedHat' - -- include: setup-Debian.yml - when: ansible_os_family == 'Debian' - -- include: setup-FreeBSD.yml - when: ansible_os_family == 'FreeBSD' diff --git a/ansible/roles/geerlingguy.java/tasks/setup-Debian.yml b/ansible/roles/geerlingguy.java/tasks/setup-Debian.yml deleted file mode 100644 index f1adc757..00000000 --- a/ansible/roles/geerlingguy.java/tasks/setup-Debian.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Update apt cache. - apt: update_cache=yes cache_valid_time=86400 - -- name: Ensure Java is installed. - apt: "name={{ item }} state=installed" - with_items: "{{ java_packages }}" diff --git a/ansible/roles/geerlingguy.java/tasks/setup-FreeBSD.yml b/ansible/roles/geerlingguy.java/tasks/setup-FreeBSD.yml deleted file mode 100644 index f3d1fa31..00000000 --- a/ansible/roles/geerlingguy.java/tasks/setup-FreeBSD.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Ensure Java is installed. - pkgng: "name={{ item }} state=present" - with_items: "{{ java_packages }}" - -- name: ensure proc is mounted - mount: name=/proc fstype=procfs src=proc opts=rw state=mounted - -- name: ensure fdesc is mounted - mount: name=/dev/fd fstype=fdescfs src=fdesc opts=rw state=mounted diff --git a/ansible/roles/geerlingguy.java/tasks/setup-RedHat.yml b/ansible/roles/geerlingguy.java/tasks/setup-RedHat.yml deleted file mode 100644 index 4a616adc..00000000 --- a/ansible/roles/geerlingguy.java/tasks/setup-RedHat.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: Ensure Java is installed. - yum: "name={{ item }} state=installed" - with_items: "{{ java_packages }}" diff --git a/ansible/roles/geerlingguy.java/tests/Dockerfile.centos-6 b/ansible/roles/geerlingguy.java/tests/Dockerfile.centos-6 deleted file mode 100644 index 4a4e7b8d..00000000 --- a/ansible/roles/geerlingguy.java/tests/Dockerfile.centos-6 +++ /dev/null @@ -1,15 +0,0 @@ -FROM centos:6 - -# Install Ansible -RUN yum -y update; yum clean all; -RUN yum -y install epel-release -RUN yum -y install git ansible sudo -RUN yum clean all - -# Disable requiretty -RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers - -# Install Ansible inventory file -RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts - -CMD ["/usr/sbin/init"] diff --git a/ansible/roles/geerlingguy.java/tests/Dockerfile.centos-7 b/ansible/roles/geerlingguy.java/tests/Dockerfile.centos-7 deleted file mode 100644 index 8aa06549..00000000 --- a/ansible/roles/geerlingguy.java/tests/Dockerfile.centos-7 +++ /dev/null @@ -1,27 +0,0 @@ -FROM centos:7 - -# Install systemd -- See https://hub.docker.com/_/centos/ -RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs -RUN yum -y update; yum clean all; \ -(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ -rm -f /lib/systemd/system/multi-user.target.wants/*; \ -rm -f /etc/systemd/system/*.wants/*; \ -rm -f /lib/systemd/system/local-fs.target.wants/*; \ -rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ -rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ -rm -f /lib/systemd/system/basic.target.wants/*; \ -rm -f /lib/systemd/system/anaconda.target.wants/*; - -# Install Ansible -RUN yum -y install epel-release -RUN yum -y install git ansible sudo -RUN yum clean all - -# Disable requiretty -RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers - -# Install Ansible inventory file -RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts - -VOLUME ["/sys/fs/cgroup"] -CMD ["/usr/sbin/init"] diff --git a/ansible/roles/geerlingguy.java/tests/Dockerfile.ubuntu-12.04 b/ansible/roles/geerlingguy.java/tests/Dockerfile.ubuntu-12.04 deleted file mode 100644 index d0c130cd..00000000 --- a/ansible/roles/geerlingguy.java/tests/Dockerfile.ubuntu-12.04 +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:12.04 -RUN apt-get update - -# Install Ansible -RUN apt-get install -y software-properties-common python-software-properties git -RUN apt-add-repository -y ppa:ansible/ansible -RUN apt-get update -RUN apt-get install -y ansible - -# Install Ansible inventory file -RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts diff --git a/ansible/roles/geerlingguy.java/tests/Dockerfile.ubuntu-14.04 b/ansible/roles/geerlingguy.java/tests/Dockerfile.ubuntu-14.04 deleted file mode 100644 index ca332871..00000000 --- a/ansible/roles/geerlingguy.java/tests/Dockerfile.ubuntu-14.04 +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:14.04 -RUN apt-get update - -# Install Ansible -RUN apt-get install -y software-properties-common git -RUN apt-add-repository -y ppa:ansible/ansible -RUN apt-get update -RUN apt-get install -y ansible - -# Install Ansible inventory file -RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts diff --git a/ansible/roles/geerlingguy.java/tests/test.yml b/ansible/roles/geerlingguy.java/tests/test.yml deleted file mode 100644 index b2946540..00000000 --- a/ansible/roles/geerlingguy.java/tests/test.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- hosts: all - - pre_tasks: - - name: Ensure build dependencies are installed (RedHat). - yum: name=which state=present - when: ansible_os_family == 'RedHat' - - roles: - - role_under_test diff --git a/ansible/roles/geerlingguy.java/vars/Debian.yml b/ansible/roles/geerlingguy.java/vars/Debian.yml deleted file mode 100644 index 8d620e47..00000000 --- a/ansible/roles/geerlingguy.java/vars/Debian.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# JDK version options include: -# - java -# - openjdk-6-jdk -# - openjdk-7-jdk -__java_packages: - - openjdk-7-jdk diff --git a/ansible/roles/geerlingguy.java/vars/FreeBSD.yml b/ansible/roles/geerlingguy.java/vars/FreeBSD.yml deleted file mode 100644 index 0d712eb4..00000000 --- a/ansible/roles/geerlingguy.java/vars/FreeBSD.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# JDK version options for FreeBSD include: -# - openjdk -# - openjdk6 -# - openjdk8 -__java_packages: - - openjdk diff --git a/ansible/roles/geerlingguy.java/vars/RedHat.yml b/ansible/roles/geerlingguy.java/vars/RedHat.yml deleted file mode 100644 index 70694b7a..00000000 --- a/ansible/roles/geerlingguy.java/vars/RedHat.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# JDK version options include: -# - java -# - java-1.6.0-openjdk -# - java-1.7.0-openjdk -__java_packages: - - java-1.7.0-openjdk diff --git a/ansible/roles/geerlingguy.java/vars/Ubuntu-12.04.yml b/ansible/roles/geerlingguy.java/vars/Ubuntu-12.04.yml deleted file mode 100644 index 8d620e47..00000000 --- a/ansible/roles/geerlingguy.java/vars/Ubuntu-12.04.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# JDK version options include: -# - java -# - openjdk-6-jdk -# - openjdk-7-jdk -__java_packages: - - openjdk-7-jdk diff --git a/ansible/roles/geerlingguy.java/vars/Ubuntu-14.04.yml b/ansible/roles/geerlingguy.java/vars/Ubuntu-14.04.yml deleted file mode 100644 index 8d620e47..00000000 --- a/ansible/roles/geerlingguy.java/vars/Ubuntu-14.04.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# JDK version options include: -# - java -# - openjdk-6-jdk -# - openjdk-7-jdk -__java_packages: - - openjdk-7-jdk diff --git a/ansible/roles/geerlingguy.java/vars/Ubuntu-16.04.yml b/ansible/roles/geerlingguy.java/vars/Ubuntu-16.04.yml deleted file mode 100644 index 0a0bd820..00000000 --- a/ansible/roles/geerlingguy.java/vars/Ubuntu-16.04.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# JDK version options include: -# - java -# - openjdk-8-jdk -# - openjdk-9-jdk -__java_packages: - - openjdk-8-jdk diff --git a/ansible/roles/geerlingguy.redis/.travis.yml b/ansible/roles/geerlingguy.redis/.travis.yml deleted file mode 100644 index 70111384..00000000 --- a/ansible/roles/geerlingguy.redis/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -sudo: required -language: python -python: "2.7" - -env: - - SITE=test.yml - -before_install: - - sudo apt-get update -qq - - # Remove pre-existing Redis installation. - - sudo apt-get remove -y --purge redis-server - - sudo rm -rf /etc/redis - -install: - # Install Ansible. - - pip install ansible - - # Add ansible.cfg to pick up roles path. - - "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg" - -script: - # Check the role/playbook's syntax. - - "ansible-playbook -i tests/inventory tests/$SITE --syntax-check" - - # Run the role/playbook with ansible-playbook. - - "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo" - - # Run the role/playbook again, checking to make sure it's idempotent. - - > - ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo - | grep -q 'changed=0.*failed=0' - && (echo 'Idempotence test: pass' && exit 0) - || (echo 'Idempotence test: fail' && exit 1) - - # Make sure Redis is running, and can be stopped and started cleanly. - - sudo service redis-server status - - sudo service redis-server stop - - sudo service redis-server start - -after_failure: - - sudo cat /var/log/redis/redis-server.log - - sudo cat /etc/redis/redis.conf - -notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/ansible/roles/geerlingguy.redis/README.md b/ansible/roles/geerlingguy.redis/README.md deleted file mode 100644 index 4f746790..00000000 --- a/ansible/roles/geerlingguy.redis/README.md +++ /dev/null @@ -1,92 +0,0 @@ -# Ansible Role: Redis - -[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-redis.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-redis) - -Installs [Redis](http://redis.io/) on RHEL/CentOS or Debian/Ubuntu. - -## Requirements - -On RedHat-based distributions, requires the EPEL repository (you can simply add the role `geerlingguy.repo-epel` to install ensure EPEL is available). - -## Role Variables - -Available variables are listed below, along with default values (see `defaults/main.yml`): - - redis_port: 6379 - redis_bind_interface: 127.0.0.1 - -Port and interface on which Redis will listen. Set the interface to `0.0.0.0` to listen on all interfaces. - - redis_unixsocket: '' - -If set, Redis will also listen on a local Unix socket. - - redis_timeout: 300 - -Close a connection after a client is idle `N` seconds. Set to `0` to disable timeout. - - redis_loglevel: "notice" - redis_logfile: /var/log/redis/redis-server.log - -Log level and log location (valid levels are `debug`, `verbose`, `notice`, and `warning`). - - redis_databases: 16 - -The number of Redis databases. - - # Set to an empty set to disable persistence (saving the DB to disk). - redis_save: - - 900 1 - - 300 10 - - 60 10000 - -Snapshotting configuration; setting values in this list will save the database to disk if the given number of seconds (e.g. `900`) and the given number of write operations (e.g. `1`) have occurred. - - redis_rdbcompression: "yes" - redis_dbfilename: dump.rdb - redis_dbdir: /var/lib/redis - -Database compression and location configuration. - - redis_maxmemory: 0 - -Limit memory usage to the specified amount of bytes. Leave at 0 for unlimited. - - redis_maxmemory_policy: "noeviction" - -The method to use to keep memory usage below the limit, if specified. See [Using Redis as an LRU cache](http://redis.io/topics/lru-cache). - - redis_maxmemory_samples: 5 - -Number of samples to use to approximate LRU. See [Using Redis as an LRU cache](http://redis.io/topics/lru-cache). - - redis_appendonly: "no" - -The appendonly option, if enabled, affords better data durability guarantees, at the cost of slightly slower performance. - - redis_appendfsync: "everysec" - -Valid values are `always` (slower, safest), `everysec` (happy medium), or `no` (let the filesystem flush data when it wants, most risky). - - # Add extra include files for local configuration/overrides. - redis_includes: [] - -Add extra include file paths to this list to include more/localized Redis configuration. - -## Dependencies - -None. - -## Example Playbook - - - hosts: all - roles: - - { role: geerlingguy.redis } - -## License - -MIT / BSD - -## Author Information - -This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/). diff --git a/ansible/roles/geerlingguy.redis/defaults/main.yml b/ansible/roles/geerlingguy.redis/defaults/main.yml deleted file mode 100644 index 15e94a2f..00000000 --- a/ansible/roles/geerlingguy.redis/defaults/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -redis_port: 6379 -redis_bind_interface: 127.0.0.1 -redis_unixsocket: '' -redis_timeout: 300 - -redis_loglevel: "notice" -redis_logfile: /var/log/redis/redis-server.log - -redis_databases: 16 - -# Set to an empty set to disable persistence (saving the DB to disk). -redis_save: - - 900 1 - - 300 10 - - 60 10000 - -redis_rdbcompression: "yes" -redis_dbfilename: dump.rdb -redis_dbdir: /var/lib/redis - -redis_maxmemory: 0 -redis_maxmemory_policy: "noeviction" -redis_maxmemory_samples: 5 - -redis_appendonly: "no" -redis_appendfsync: "everysec" - -# Add extra include files for local configuration/overrides. -redis_includes: [] diff --git a/ansible/roles/geerlingguy.redis/handlers/main.yml b/ansible/roles/geerlingguy.redis/handlers/main.yml deleted file mode 100644 index 9a212039..00000000 --- a/ansible/roles/geerlingguy.redis/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: restart redis - service: "name={{ redis_daemon }} state=restarted" diff --git a/ansible/roles/geerlingguy.redis/meta/.galaxy_install_info b/ansible/roles/geerlingguy.redis/meta/.galaxy_install_info deleted file mode 100644 index 97932632..00000000 --- a/ansible/roles/geerlingguy.redis/meta/.galaxy_install_info +++ /dev/null @@ -1 +0,0 @@ -{install_date: 'Tue Jul 5 20:48:29 2016', version: 1.2.0} diff --git a/ansible/roles/geerlingguy.redis/meta/main.yml b/ansible/roles/geerlingguy.redis/meta/main.yml deleted file mode 100644 index 109a5d75..00000000 --- a/ansible/roles/geerlingguy.redis/meta/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -dependencies: [] - -galaxy_info: - author: geerlingguy - description: Redis for Linux - company: "Midwestern Mac, LLC" - license: "license (BSD, MIT)" - min_ansible_version: 1.8 - platforms: - - name: EL - versions: - - 6 - - 7 - - name: Debian - versions: - - all - - name: Ubuntu - versions: - - all - galaxy_tags: - - database - - development - - web diff --git a/ansible/roles/geerlingguy.redis/tasks/main.yml b/ansible/roles/geerlingguy.redis/tasks/main.yml deleted file mode 100644 index ec8de513..00000000 --- a/ansible/roles/geerlingguy.redis/tasks/main.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -# Variable setup. -- name: Include OS-specific variables. - include_vars: "{{ ansible_os_family }}.yml" - -# Setup/install tasks. -- include: setup-RedHat.yml - when: ansible_os_family == 'RedHat' - -- include: setup-Debian.yml - when: ansible_os_family == 'Debian' - -- name: Ensure Redis is configured. - template: - src: redis.conf.j2 - dest: "{{ redis_conf_path }}" - mode: 0644 - notify: restart redis - -- name: Ensure redis is running and enabled on boot. - service: "name={{ redis_daemon }} state=started enabled=yes" diff --git a/ansible/roles/geerlingguy.redis/tasks/setup-Debian.yml b/ansible/roles/geerlingguy.redis/tasks/setup-Debian.yml deleted file mode 100644 index c105caf1..00000000 --- a/ansible/roles/geerlingguy.redis/tasks/setup-Debian.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Ensure redis is installed. - apt: name=redis-server state=installed diff --git a/ansible/roles/geerlingguy.redis/tasks/setup-RedHat.yml b/ansible/roles/geerlingguy.redis/tasks/setup-RedHat.yml deleted file mode 100644 index 85ed9091..00000000 --- a/ansible/roles/geerlingguy.redis/tasks/setup-RedHat.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Ensure redis is installed. - yum: name=redis state=installed enablerepo=epel diff --git a/ansible/roles/geerlingguy.redis/templates/redis.conf.j2 b/ansible/roles/geerlingguy.redis/templates/redis.conf.j2 deleted file mode 100644 index f7a7c5f0..00000000 --- a/ansible/roles/geerlingguy.redis/templates/redis.conf.j2 +++ /dev/null @@ -1,45 +0,0 @@ -daemonize yes -pidfile /var/run/redis/{{ redis_daemon }}.pid -port {{ redis_port }} -bind {{ redis_bind_interface }} - -{% if redis_unixsocket %} -unixsocket {{ redis_unixsocket }} -{% endif %} - -timeout {{ redis_timeout }} - -loglevel {{ redis_loglevel }} -logfile {{ redis_logfile }} - -# To enable logging to the system logger, just set 'syslog-enabled' to yes, -# and optionally update the other syslog parameters to suit your needs. -# syslog-enabled no -# syslog-ident redis -# syslog-facility local0 - -databases {{ redis_databases }} - -{% for save in redis_save %} -save {{ save }} -{% endfor %} - -rdbcompression {{ redis_rdbcompression }} -dbfilename {{ redis_dbfilename }} -dir {{ redis_dbdir }} - -# maxclients 128 - -{% if redis_maxmemory %} -maxmemory {{ redis_maxmemory }} -maxmemory-policy {{ redis_maxmemory_policy }} -maxmemory-samples {{ redis_maxmemory_samples }} -{% endif %} - -appendonly {{ redis_appendonly }} -appendfsync {{ redis_appendfsync }} -no-appendfsync-on-rewrite no - -{% for include in redis_includes %} -include {{ include }} -{% endfor %} diff --git a/ansible/roles/geerlingguy.redis/tests/inventory b/ansible/roles/geerlingguy.redis/tests/inventory deleted file mode 100644 index 2fbb50c4..00000000 --- a/ansible/roles/geerlingguy.redis/tests/inventory +++ /dev/null @@ -1 +0,0 @@ -localhost diff --git a/ansible/roles/geerlingguy.redis/tests/test.yml b/ansible/roles/geerlingguy.redis/tests/test.yml deleted file mode 100644 index d24c0a9c..00000000 --- a/ansible/roles/geerlingguy.redis/tests/test.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- hosts: localhost - remote_user: root - - roles: - - ansible-role-redis diff --git a/ansible/roles/geerlingguy.redis/vars/Debian.yml b/ansible/roles/geerlingguy.redis/vars/Debian.yml deleted file mode 100644 index 517d91a1..00000000 --- a/ansible/roles/geerlingguy.redis/vars/Debian.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -redis_daemon: redis-server -redis_conf_path: /etc/redis/redis.conf diff --git a/ansible/roles/geerlingguy.redis/vars/RedHat.yml b/ansible/roles/geerlingguy.redis/vars/RedHat.yml deleted file mode 100644 index d4f603ce..00000000 --- a/ansible/roles/geerlingguy.redis/vars/RedHat.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -redis_daemon: redis -redis_conf_path: /etc/redis.conf diff --git a/ansible/roles/nginx/handlers/main.yml b/ansible/roles/nginx/handlers/main.yml deleted file mode 100644 index 92971d2c..00000000 --- a/ansible/roles/nginx/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: restart nginx - service: name=nginx state=restarted diff --git a/ansible/roles/nginx/tasks/main.yml b/ansible/roles/nginx/tasks/main.yml deleted file mode 100644 index 152d2d5c..00000000 --- a/ansible/roles/nginx/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- name: Install nginx - apt: name=nginx - tags: nginx - -- name: Disable default nginx site - file: path=/etc/nginx/sites-enabled/default state=absent - notify: restart nginx - tags: nginx - -- name: Copy nginx configuration - template: src={{ server_type }}.conf.j2 dest=/etc/nginx/sites-available/{{ server_name }}.conf - notify: restart nginx - tags: nginx - -- name: Symlink nginx configuration - file: src=/etc/nginx/sites-available/{{ server_name }}.conf dest=/etc/nginx/sites-enabled/{{ server_name }}.conf state=link - notify: restart nginx - tags: nginx - -- name: Create nginx.conf - template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf - notify: restart nginx - tags: nginx - -- name: Create certificates directory - file: path={{ ssl_certificate_path|dirname }} recurse=yes state=directory - tags: nginx - -- name: Create self-signed SSL cert - command: openssl req -new -nodes -x509 -subj "/C=US/ST=California/L=MountainView/O=IT/CN=${server_name}" -days 3650 -keyout {{ ssl_certificate_key_path }} -out {{ ssl_certificate_path }} -extensions v3_ca creates={{ ssl_certificate_path }} - notify: restart nginx - tags: nginx diff --git a/ansible/roles/nginx/templates/nginx.conf.j2 b/ansible/roles/nginx/templates/nginx.conf.j2 deleted file mode 100644 index 93d0a93c..00000000 --- a/ansible/roles/nginx/templates/nginx.conf.j2 +++ /dev/null @@ -1,77 +0,0 @@ -user {{ user_name }}; -worker_processes auto; -pid /run/nginx.pid; - -env PATH; - -events { - worker_connections 768; - # multi_accept on; -} - -http { - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 70; - types_hash_max_size 2048; - # server_tokens off; - -{% if server_type == 'nginx_passenger' %} - passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; -{% endif %} - - ssl_session_cache shared:SSL:10m; - ssl_session_timeout 10m; - - # server_names_hash_bucket_size 64; - # server_name_in_redirect off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - ## - # Logging Settings - ## - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - gzip_disable "msie6"; - - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; - - ## - # nginx-naxsi config - ## - # Uncomment it if you installed nginx-naxsi - ## - - #include /etc/nginx/naxsi_core.rules; - - ## - # nginx-passenger config - ## - # Uncomment it if you installed nginx-passenger - ## - - #passenger_root /usr; - #passenger_ruby /usr/bin/ruby; - - ## - # Virtual Host Configs - ## - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} diff --git a/ansible/roles/nginx/templates/nginx_passenger.conf.j2 b/ansible/roles/nginx/templates/nginx_passenger.conf.j2 deleted file mode 100644 index 0b6d8a9a..00000000 --- a/ansible/roles/nginx/templates/nginx_passenger.conf.j2 +++ /dev/null @@ -1,22 +0,0 @@ -# {{ ansible_managed }} - -server { - listen 80; - listen 443 ssl; - - passenger_enabled on; - passenger_app_env {{ rails_env }}; - - sendfile off; - - server_name {{ server_name }}; - - ssl_certificate {{ ssl_certificate_path }}; - ssl_certificate_key {{ ssl_certificate_key_path }}; - - root {{ app_public_path }}; - - error_page 500 502 503 504 /500.html; - client_max_body_size 4G; - keepalive_timeout 10; -} diff --git a/ansible/roles/nginx/templates/nginx_puma.conf.j2 b/ansible/roles/nginx/templates/nginx_puma.conf.j2 deleted file mode 100644 index d04df42b..00000000 --- a/ansible/roles/nginx/templates/nginx_puma.conf.j2 +++ /dev/null @@ -1,34 +0,0 @@ -# {{ ansible_managed }} - -upstream app { - server {{ puma_bind_path }} fail_timeout=0; -} - -server { - listen 80; - listen 443 ssl; - - sendfile off; - - server_name {{ server_name }}; - - ssl_certificate {{ ssl_certificate_path }}; - ssl_certificate_key {{ ssl_certificate_key_path }}; - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE - - root {{ app_public_path }}; - - try_files $uri/index.html $uri @app; - - location @app { - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_pass http://app; - } - - error_page 500 502 503 504 /500.html; - client_max_body_size 4G; - keepalive_timeout 10; -} diff --git a/ansible/roles/nginx/templates/nginx_unicorn.conf.j2 b/ansible/roles/nginx/templates/nginx_unicorn.conf.j2 deleted file mode 100644 index 1b1c1090..00000000 --- a/ansible/roles/nginx/templates/nginx_unicorn.conf.j2 +++ /dev/null @@ -1,34 +0,0 @@ -# {{ ansible_managed }} - -upstream app { - server unix:{{ unicorn_sock_path }} fail_timeout=0; -} - -server { - listen 80; - listen 443 ssl; - - sendfile off; - - server_name {{ server_name }}; - - ssl_certificate {{ ssl_certificate_path }}; - ssl_certificate_key {{ ssl_certificate_key_path }}; - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE - - root {{ app_public_path }}; - - try_files $uri/index.html $uri @app; - - location @app { - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_pass http://app; - } - - error_page 500 502 503 504 /500.html; - client_max_body_size 4G; - keepalive_timeout 10; -} diff --git a/ansible/roles/passenger/defaults/main.yml b/ansible/roles/passenger/defaults/main.yml deleted file mode 100644 index 8620319a..00000000 --- a/ansible/roles/passenger/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -server_restart_command: /etc/init.d/nginx restart diff --git a/ansible/roles/passenger/handlers/main.yml b/ansible/roles/passenger/handlers/main.yml deleted file mode 100644 index 7007ccf7..00000000 --- a/ansible/roles/passenger/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: restart application - service: name=nginx state=restarted - when: "'application' in group_names" diff --git a/ansible/roles/passenger/tasks/main.yml b/ansible/roles/passenger/tasks/main.yml deleted file mode 100644 index dd0c474a..00000000 --- a/ansible/roles/passenger/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- name: Add Passenger apt server key - apt_key: keyserver=hkp://keyserver.ubuntu.com:80 id=561F9B9CAC40B2F7 - -- name: Add HTTPS support for apt - apt: name={{ item }} - with_items: - - apt-transport-https - - ca-certificates - -- name: Add Passenger apt repo - apt_repository: repo='deb https://oss-binaries.phusionpassenger.com/apt/passenger {{ ansible_lsb.codename }} main' - -- name: Install Passenger - apt: pkg={{ item }} - with_items: - - nginx-extras - - passenger - notify: restart application diff --git a/ansible/roles/postgresql/defaults/main.yml b/ansible/roles/postgresql/defaults/main.yml deleted file mode 100644 index 697fa6d0..00000000 --- a/ansible/roles/postgresql/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -postgresql_version: 9.3 -postgresql_ext_postgis_version: 2.1 -postgresql_extensions: [] -postgresql_admin_user: postgres diff --git a/ansible/roles/postgresql/handlers/main.yml b/ansible/roles/postgresql/handlers/main.yml deleted file mode 100644 index c51e7d1c..00000000 --- a/ansible/roles/postgresql/handlers/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: restart postgresql - service: name=postgresql state=restarted diff --git a/ansible/roles/postgresql/tasks/main.yml b/ansible/roles/postgresql/tasks/main.yml deleted file mode 100644 index 8e7d4d39..00000000 --- a/ansible/roles/postgresql/tasks/main.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- -- name: Install packages - apt: name={{ item }} - with_items: - - libpq-dev - - postgresql - - postgresql-contrib - - python-pip - - python-dev - -- name: Configure PostgreSQL - postgresql.conf - template: src=postgresql.conf.j2 dest=/etc/postgresql/{{ postgresql_version }}/main/postgresql.conf - notify: restart postgresql - -- name: Configure PostgreSQL - pg_hba.conf - template: src=pg_hba.conf.j2 dest=/etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf - notify: restart postgresql - - -- name: Install required Python modules - pip: name=psycopg2 - -- name: Create postgresql user - postgresql_user: name={{ postgresql_db_user }} password={{ postgresql_db_password }} role_attr_flags=CREATEDB,SUPERUSER,CREATEROLE - sudo_user: postgres - -- name: Create postgresql database - postgresql_db: name={{ postgresql_db_name }} owner={{ postgresql_db_user }} - sudo_user: postgres - -- name: Create postgresql test database - postgresql_db: name={{ postgresql_db_name }}_test owner={{ postgresql_db_user }} - sudo_user: postgres - -- name: Assure that config dir exists - file: path={{ shared_config_path }} state=directory - -- name: Create config/database.yml - template: src=database.yml.j2 dest={{ shared_config_path }}/database.yml owner={{ user_name }} mode=0600 backup=yes - when: postgresql_orm in ['activerecord', 'sequel', 'datamapper'] - -- name: Make sure the postgis extensions are installed - apt: name={{ item }} - with_items: - - libgeos-c1 - - 'postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}' - notify: restart postgresql - when: "postgresql_extensions and 'postgis' in postgresql_extensions" - -- name: Create extensions - sudo_user: '{{ postgresql_admin_user }}' - shell: "psql {{ postgresql_db_name }} -c 'CREATE EXTENSION IF NOT EXISTS {{ item }};'" - with_items: postgresql_extensions - when: postgresql_extensions diff --git a/ansible/roles/postgresql/templates/database.yml.j2 b/ansible/roles/postgresql/templates/database.yml.j2 deleted file mode 100644 index d46bbded..00000000 --- a/ansible/roles/postgresql/templates/database.yml.j2 +++ /dev/null @@ -1,16 +0,0 @@ -# {{ ansible_managed }} - -default: &default - adapter: postgresql - pool: 5 - -{{ rails_env }}: - <<: *default - database: {{ postgresql_db_name }} - - username: {{ postgresql_db_user }} - password: {{ postgresql_db_password }} - -test: - <<: *default - database: {{ postgresql_db_name }}_test diff --git a/ansible/roles/postgresql/templates/my_init.sh.j2 b/ansible/roles/postgresql/templates/my_init.sh.j2 deleted file mode 100644 index e77fceba..00000000 --- a/ansible/roles/postgresql/templates/my_init.sh.j2 +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/etc/init.d/postgresql start diff --git a/ansible/roles/postgresql/templates/pg_hba.conf.j2 b/ansible/roles/postgresql/templates/pg_hba.conf.j2 deleted file mode 100644 index 1c1ada2e..00000000 --- a/ansible/roles/postgresql/templates/pg_hba.conf.j2 +++ /dev/null @@ -1,101 +0,0 @@ -# PostgreSQL Client Authentication Configuration File -# =================================================== -# -# Refer to the "Client Authentication" section in the PostgreSQL -# documentation for a complete description of this file. A short -# synopsis follows. -# -# This file controls: which hosts are allowed to connect, how clients -# are authenticated, which PostgreSQL user names they can use, which -# databases they can access. Records take one of these forms: -# -# local DATABASE USER METHOD [OPTIONS] -# host DATABASE USER ADDRESS METHOD [OPTIONS] -# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] -# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] -# -# (The uppercase items must be replaced by actual values.) -# -# The first field is the connection type: "local" is a Unix-domain -# socket, "host" is either a plain or SSL-encrypted TCP/IP socket, -# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a -# plain TCP/IP socket. -# -# DATABASE can be "all", "sameuser", "samerole", "replication", a -# database name, or a comma-separated list thereof. The "all" -# keyword does not match "replication". Access to replication -# must be enabled in a separate record (see example below). -# -# USER can be "all", a user name, a group name prefixed with "+", or a -# comma-separated list thereof. In both the DATABASE and USER fields -# you can also write a file name prefixed with "@" to include names -# from a separate file. -# -# ADDRESS specifies the set of hosts the record matches. It can be a -# host name, or it is made up of an IP address and a CIDR mask that is -# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that -# specifies the number of significant bits in the mask. A host name -# that starts with a dot (.) matches a suffix of the actual host name. -# Alternatively, you can write an IP address and netmask in separate -# columns to specify the set of hosts. Instead of a CIDR-address, you -# can write "samehost" to match any of the server's own IP addresses, -# or "samenet" to match any address in any subnet that the server is -# directly connected to. -# -# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", -# "krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that -# "password" sends passwords in clear text; "md5" is preferred since -# it sends encrypted passwords. -# -# OPTIONS are a set of options for the authentication in the format -# NAME=VALUE. The available options depend on the different -# authentication methods -- refer to the "Client Authentication" -# section in the documentation for a list of which options are -# available for which authentication methods. -# -# Database and user names containing spaces, commas, quotes and other -# special characters must be quoted. Quoting one of the keywords -# "all", "sameuser", "samerole" or "replication" makes the name lose -# its special character, and just match a database or username with -# that name. -# -# This file is read on server startup and when the postmaster receives -# a SIGHUP signal. If you edit the file on a running system, you have -# to SIGHUP the postmaster for the changes to take effect. You can -# use "pg_ctl reload" to do that. - -# Put your actual configuration here -# ---------------------------------- -# -# If you want to allow non-local connections, you need to add more -# "host" records. In that case you will also need to make PostgreSQL -# listen on a non-local interface via the listen_addresses -# configuration parameter, or via the -i or -h command line switches. - - - - -# DO NOT DISABLE! -# If you change this first entry you will need to make sure that the -# database superuser can access the database using some other method. -# Noninteractive access to all databases is required during automatic -# maintenance (custom daily cronjobs, replication, and similar tasks). -# -# Database administrative login by Unix domain socket -local all postgres peer - -# TYPE DATABASE USER ADDRESS METHOD - -# "local" is for Unix domain socket connections only -local all all peer -# IPv4 all connections: -host all all 127.0.0.1/32 md5 -# Trust docker hosts -host all all 172.17.0.6/12 trust -# IPv6 local connections: -host all all ::1/128 md5 -# Allow replication connections from localhost, by a user with the -# replication privilege. -#local replication postgres peer -#host replication postgres 127.0.0.1/32 md5 -#host replication postgres ::1/128 md5 diff --git a/ansible/roles/postgresql/templates/postgresql.conf.j2 b/ansible/roles/postgresql/templates/postgresql.conf.j2 deleted file mode 100644 index 41ad6aec..00000000 --- a/ansible/roles/postgresql/templates/postgresql.conf.j2 +++ /dev/null @@ -1,596 +0,0 @@ -# ----------------------------- -# PostgreSQL configuration file -# ----------------------------- -# -# This file consists of lines of the form: -# -# name = value -# -# (The "=" is optional.) Whitespace may be used. Comments are introduced with -# "#" anywhere on a line. The complete list of parameter names and allowed -# values can be found in the PostgreSQL documentation. -# -# The commented-out settings shown in this file represent the default values. -# Re-commenting a setting is NOT sufficient to revert it to the default value; -# you need to reload the server. -# -# This file is read on server startup and when the server receives a SIGHUP -# signal. If you edit the file on a running system, you have to SIGHUP the -# server for the changes to take effect, or use "pg_ctl reload". Some -# parameters, which are marked below, require a server shutdown and restart to -# take effect. -# -# Any parameter can also be given as a command-line option to the server, e.g., -# "postgres -c log_connections=on". Some parameters can be changed at run time -# with the "SET" SQL command. -# -# Memory units: kB = kilobytes Time units: ms = milliseconds -# MB = megabytes s = seconds -# GB = gigabytes min = minutes -# h = hours -# d = days - - -#------------------------------------------------------------------------------ -# FILE LOCATIONS -#------------------------------------------------------------------------------ - -# The default values of these variables are driven from the -D command-line -# option or PGDATA environment variable, represented here as ConfigDir. - -data_directory = '/var/lib/postgresql/{{ postgresql_version }}/main' # use data in another directory - # (change requires restart) -hba_file = '/etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf' # host-based authentication file - # (change requires restart) -ident_file = '/etc/postgresql/{{ postgresql_version }}/main/pg_ident.conf' # ident configuration file - # (change requires restart) - -# If external_pid_file is not explicitly set, no extra PID file is written. -external_pid_file = '/var/run/postgresql/{{ postgresql_version }}-main.pid' # write an extra PID file - # (change requires restart) - - -#------------------------------------------------------------------------------ -# CONNECTIONS AND AUTHENTICATION -#------------------------------------------------------------------------------ - -# - Connection Settings - - -listen_addresses = '0.0.0.0' # what IP address(es) to listen on; - # comma-separated list of addresses; - # defaults to 'localhost'; use '*' for all - # (change requires restart) -port = 5432 # (change requires restart) -max_connections = 100 # (change requires restart) -# Note: Increasing max_connections costs ~400 bytes of shared memory per -# connection slot, plus lock space (see max_locks_per_transaction). -#superuser_reserved_connections = 3 # (change requires restart) -unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories - # (change requires restart) -#unix_socket_group = '' # (change requires restart) -#unix_socket_permissions = 0777 # begin with 0 to use octal notation - # (change requires restart) -#bonjour = off # advertise server via Bonjour - # (change requires restart) -#bonjour_name = '' # defaults to the computer name - # (change requires restart) - -# - Security and Authentication - - -#authentication_timeout = 1min # 1s-600s -#ssl = off # (change requires restart) -#ssl_ciphers = 'DEFAULT:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers - # (change requires restart) -#ssl_renegotiation_limit = 512MB # amount of data between renegotiations -#ssl_cert_file = 'server.crt' # (change requires restart) -#ssl_key_file = 'server.key' # (change requires restart) -#ssl_ca_file = '' # (change requires restart) -#ssl_crl_file = '' # (change requires restart) -#password_encryption = on -#db_user_namespace = off - -# Kerberos and GSSAPI -#krb_server_keyfile = '' -#krb_srvname = 'postgres' # (Kerberos only) -#krb_caseins_users = off - -# - TCP Keepalives - -# see "man 7 tcp" for details - -#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds; - # 0 selects the system default -#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds; - # 0 selects the system default -#tcp_keepalives_count = 0 # TCP_KEEPCNT; - # 0 selects the system default - - -#------------------------------------------------------------------------------ -# RESOURCE USAGE (except WAL) -#------------------------------------------------------------------------------ - -# - Memory - - -shared_buffers = 128MB # min 128kB - # (change requires restart) -#temp_buffers = 8MB # min 800kB -#max_prepared_transactions = 0 # zero disables the feature - # (change requires restart) -# Note: Increasing max_prepared_transactions costs ~600 bytes of shared memory -# per transaction slot, plus lock space (see max_locks_per_transaction). -# It is not advisable to set max_prepared_transactions nonzero unless you -# actively intend to use prepared transactions. -#work_mem = 1MB # min 64kB -#maintenance_work_mem = 16MB # min 1MB -#max_stack_depth = 2MB # min 100kB - -# - Disk - - -#temp_file_limit = -1 # limits per-session temp file space - # in kB, or -1 for no limit - -# - Kernel Resource Usage - - -#max_files_per_process = 1000 # min 25 - # (change requires restart) -#shared_preload_libraries = '' # (change requires restart) - -# - Cost-Based Vacuum Delay - - -#vacuum_cost_delay = 0 # 0-100 milliseconds -#vacuum_cost_page_hit = 1 # 0-10000 credits -#vacuum_cost_page_miss = 10 # 0-10000 credits -#vacuum_cost_page_dirty = 20 # 0-10000 credits -#vacuum_cost_limit = 200 # 1-10000 credits - -# - Background Writer - - -#bgwriter_delay = 200ms # 10-10000ms between rounds -#bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round -#bgwriter_lru_multiplier = 2.0 # 0-10.0 multipler on buffers scanned/round - -# - Asynchronous Behavior - - -#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching - - -#------------------------------------------------------------------------------ -# WRITE AHEAD LOG -#------------------------------------------------------------------------------ - -# - Settings - - -#wal_level = minimal # minimal, archive, or hot_standby - # (change requires restart) -#fsync = on # turns forced synchronization on or off -#synchronous_commit = on # synchronization level; - # off, local, remote_write, or on -#wal_sync_method = fsync # the default is the first option - # supported by the operating system: - # open_datasync - # fdatasync (default on Linux) - # fsync - # fsync_writethrough - # open_sync -#full_page_writes = on # recover from partial page writes -#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers - # (change requires restart) -#wal_writer_delay = 200ms # 1-10000 milliseconds - -#commit_delay = 0 # range 0-100000, in microseconds -#commit_siblings = 5 # range 1-1000 - -# - Checkpoints - - -#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each -#checkpoint_timeout = 5min # range 30s-1h -#checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 -#checkpoint_warning = 30s # 0 disables - -# - Archiving - - -#archive_mode = off # allows archiving to be done - # (change requires restart) -#archive_command = '' # command to use to archive a logfile segment - # placeholders: %p = path of file to archive - # %f = file name only - # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' -#archive_timeout = 0 # force a logfile segment switch after this - # number of seconds; 0 disables - - -#------------------------------------------------------------------------------ -# REPLICATION -#------------------------------------------------------------------------------ - -# - Sending Server(s) - - -# Set these on the master and on any standby that will send replication data. - -#max_wal_senders = 0 # max number of walsender processes - # (change requires restart) -#wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables -#wal_sender_timeout = 60s # in milliseconds; 0 disables - -# - Master Server - - -# These settings are ignored on a standby server. - -#synchronous_standby_names = '' # standby servers that provide sync rep - # comma-separated list of application_name - # from standby(s); '*' = all -#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed - -# - Standby Servers - - -# These settings are ignored on a master server. - -#hot_standby = off # "on" allows queries during recovery - # (change requires restart) -#max_standby_archive_delay = 30s # max delay before canceling queries - # when reading WAL from archive; - # -1 allows indefinite delay -#max_standby_streaming_delay = 30s # max delay before canceling queries - # when reading streaming WAL; - # -1 allows indefinite delay -#wal_receiver_status_interval = 10s # send replies at least this often - # 0 disables -#hot_standby_feedback = off # send info from standby to prevent - # query conflicts -#wal_receiver_timeout = 60s # time that receiver waits for - # communication from master - # in milliseconds; 0 disables - - -#------------------------------------------------------------------------------ -# QUERY TUNING -#------------------------------------------------------------------------------ - -# - Planner Method Configuration - - -#enable_bitmapscan = on -#enable_hashagg = on -#enable_hashjoin = on -#enable_indexscan = on -#enable_indexonlyscan = on -#enable_material = on -#enable_mergejoin = on -#enable_nestloop = on -#enable_seqscan = on -#enable_sort = on -#enable_tidscan = on - -# - Planner Cost Constants - - -#seq_page_cost = 1.0 # measured on an arbitrary scale -#random_page_cost = 4.0 # same scale as above -#cpu_tuple_cost = 0.01 # same scale as above -#cpu_index_tuple_cost = 0.005 # same scale as above -#cpu_operator_cost = 0.0025 # same scale as above -#effective_cache_size = 128MB - -# - Genetic Query Optimizer - - -#geqo = on -#geqo_threshold = 12 -#geqo_effort = 5 # range 1-10 -#geqo_pool_size = 0 # selects default based on effort -#geqo_generations = 0 # selects default based on effort -#geqo_selection_bias = 2.0 # range 1.5-2.0 -#geqo_seed = 0.0 # range 0.0-1.0 - -# - Other Planner Options - - -#default_statistics_target = 100 # range 1-10000 -#constraint_exclusion = partition # on, off, or partition -#cursor_tuple_fraction = 0.1 # range 0.0-1.0 -#from_collapse_limit = 8 -#join_collapse_limit = 8 # 1 disables collapsing of explicit - # JOIN clauses - - -#------------------------------------------------------------------------------ -# ERROR REPORTING AND LOGGING -#------------------------------------------------------------------------------ - -# - Where to Log - - -#log_destination = 'stderr' # Valid values are combinations of - # stderr, csvlog, syslog, and eventlog, - # depending on platform. csvlog - # requires logging_collector to be on. - -# This is used when logging to stderr: -#logging_collector = off # Enable capturing of stderr and csvlog - # into log files. Required to be on for - # csvlogs. - # (change requires restart) - -# These are only used if logging_collector is on: -#log_directory = 'pg_log' # directory where log files are written, - # can be absolute or relative to PGDATA -#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern, - # can include strftime() escapes -#log_file_mode = 0600 # creation mode for log files, - # begin with 0 to use octal notation -#log_truncate_on_rotation = off # If on, an existing log file with the - # same name as the new log file will be - # truncated rather than appended to. - # But such truncation only occurs on - # time-driven rotation, not on restarts - # or size-driven rotation. Default is - # off, meaning append to existing files - # in all cases. -#log_rotation_age = 1d # Automatic rotation of logfiles will - # happen after that time. 0 disables. -#log_rotation_size = 10MB # Automatic rotation of logfiles will - # happen after that much log output. - # 0 disables. - -# These are relevant when logging to syslog: -#syslog_facility = 'LOCAL0' -#syslog_ident = 'postgres' - -# This is only relevant when logging to eventlog (win32): -#event_source = 'PostgreSQL' - -# - When to Log - - -#client_min_messages = notice # values in order of decreasing detail: - # debug5 - # debug4 - # debug3 - # debug2 - # debug1 - # log - # notice - # warning - # error - -#log_min_messages = warning # values in order of decreasing detail: - # debug5 - # debug4 - # debug3 - # debug2 - # debug1 - # info - # notice - # warning - # error - # log - # fatal - # panic - -#log_min_error_statement = error # values in order of decreasing detail: - # debug5 - # debug4 - # debug3 - # debug2 - # debug1 - # info - # notice - # warning - # error - # log - # fatal - # panic (effectively off) - -#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements - # and their durations, > 0 logs only - # statements running at least this number - # of milliseconds - - -# - What to Log - - -#debug_print_parse = off -#debug_print_rewritten = off -#debug_print_plan = off -#debug_pretty_print = on -#log_checkpoints = off -#log_connections = off -#log_disconnections = off -#log_duration = off -#log_error_verbosity = default # terse, default, or verbose messages -#log_hostname = off -log_line_prefix = '%t ' # special values: - # %a = application name - # %u = user name - # %d = database name - # %r = remote host and port - # %h = remote host - # %p = process ID - # %t = timestamp without milliseconds - # %m = timestamp with milliseconds - # %i = command tag - # %e = SQL state - # %c = session ID - # %l = session line number - # %s = session start timestamp - # %v = virtual transaction ID - # %x = transaction ID (0 if none) - # %q = stop here in non-session - # processes - # %% = '%' - # e.g. '<%u%%%d> ' -#log_lock_waits = off # log lock waits >= deadlock_timeout -#log_statement = 'none' # none, ddl, mod, all -#log_temp_files = -1 # log temporary files equal or larger - # than the specified size in kilobytes; - # -1 disables, 0 logs all temp files -log_timezone = 'UTC' - - -#------------------------------------------------------------------------------ -# RUNTIME STATISTICS -#------------------------------------------------------------------------------ - -# - Query/Index Statistics Collector - - -#track_activities = on -#track_counts = on -#track_io_timing = off -#track_functions = none # none, pl, all -#track_activity_query_size = 1024 # (change requires restart) -#update_process_title = on -#stats_temp_directory = 'pg_stat_tmp' - - -# - Statistics Monitoring - - -#log_parser_stats = off -#log_planner_stats = off -#log_executor_stats = off -#log_statement_stats = off - - -#------------------------------------------------------------------------------ -# AUTOVACUUM PARAMETERS -#------------------------------------------------------------------------------ - -#autovacuum = on # Enable autovacuum subprocess? 'on' - # requires track_counts to also be on. -#log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and - # their durations, > 0 logs only - # actions running at least this number - # of milliseconds. -#autovacuum_max_workers = 3 # max number of autovacuum subprocesses - # (change requires restart) -#autovacuum_naptime = 1min # time between autovacuum runs -#autovacuum_vacuum_threshold = 50 # min number of row updates before - # vacuum -#autovacuum_analyze_threshold = 50 # min number of row updates before - # analyze -#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum -#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze -#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum - # (change requires restart) -#autovacuum_multixact_freeze_max_age = 400000000 # maximum Multixact age - # before forced vacuum - # (change requires restart) -#autovacuum_vacuum_cost_delay = 20ms # default vacuum cost delay for - # autovacuum, in milliseconds; - # -1 means use vacuum_cost_delay -#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for - # autovacuum, -1 means use - # vacuum_cost_limit - - -#------------------------------------------------------------------------------ -# CLIENT CONNECTION DEFAULTS -#------------------------------------------------------------------------------ - -# - Statement Behavior - - -#search_path = '"$user",public' # schema names -#default_tablespace = '' # a tablespace name, '' uses the default -#temp_tablespaces = '' # a list of tablespace names, '' uses - # only default tablespace -#check_function_bodies = on -#default_transaction_isolation = 'read committed' -#default_transaction_read_only = off -#default_transaction_deferrable = off -#session_replication_role = 'origin' -#statement_timeout = 0 # in milliseconds, 0 is disabled -#lock_timeout = 0 # in milliseconds, 0 is disabled -#vacuum_freeze_min_age = 50000000 -#vacuum_freeze_table_age = 150000000 -#vacuum_multixact_freeze_min_age = 5000000 -#vacuum_multixact_freeze_table_age = 150000000 -#bytea_output = 'hex' # hex, escape -#xmlbinary = 'base64' -#xmloption = 'content' - -# - Locale and Formatting - - -datestyle = 'iso, mdy' -#intervalstyle = 'postgres' -timezone = 'UTC' -#timezone_abbreviations = 'Default' # Select the set of available time zone - # abbreviations. Currently, there are - # Default - # Australia - # India - # You can create your own file in - # share/timezonesets/. -#extra_float_digits = 0 # min -15, max 3 -#client_encoding = sql_ascii # actually, defaults to database - # encoding - -# These settings are initialized by initdb, but they can be changed. -lc_messages = 'en_US.UTF-8' # locale for system error message - # strings -lc_monetary = 'en_US.UTF-8' # locale for monetary formatting -lc_numeric = 'en_US.UTF-8' # locale for number formatting -lc_time = 'en_US.UTF-8' # locale for time formatting - -# default configuration for text search -default_text_search_config = 'pg_catalog.english' - -# - Other Defaults - - -#dynamic_library_path = '$libdir' -#local_preload_libraries = '' - - -#------------------------------------------------------------------------------ -# LOCK MANAGEMENT -#------------------------------------------------------------------------------ - -#deadlock_timeout = 1s -#max_locks_per_transaction = 64 # min 10 - # (change requires restart) -# Note: Each lock table slot uses ~270 bytes of shared memory, and there are -# max_locks_per_transaction * (max_connections + max_prepared_transactions) -# lock table slots. -#max_pred_locks_per_transaction = 64 # min 10 - # (change requires restart) - - -#------------------------------------------------------------------------------ -# VERSION/PLATFORM COMPATIBILITY -#------------------------------------------------------------------------------ - -# - Previous PostgreSQL Versions - - -#array_nulls = on -#backslash_quote = safe_encoding # on, off, or safe_encoding -#default_with_oids = off -#escape_string_warning = on -#lo_compat_privileges = off -#quote_all_identifiers = off -#sql_inheritance = on -#standard_conforming_strings = on -#synchronize_seqscans = on - -# - Other Platforms and Clients - - -#transform_null_equals = off - - -#------------------------------------------------------------------------------ -# ERROR HANDLING -#------------------------------------------------------------------------------ - -#exit_on_error = off # terminate session on any error? -#restart_after_crash = on # reinitialize after backend crash? - - -#------------------------------------------------------------------------------ -# CONFIG FILE INCLUDES -#------------------------------------------------------------------------------ - -# These options allow settings to be loaded from files other than the -# default postgresql.conf. - -#include_dir = 'conf.d' # include files ending in '.conf' from - # directory 'conf.d' -#include_if_exists = 'exists.conf' # include file only if it exists -#include = 'special.conf' # include file - - -#------------------------------------------------------------------------------ -# CUSTOMIZED OPTIONS -#------------------------------------------------------------------------------ - -# Add settings for extensions here \ No newline at end of file diff --git a/ansible/roles/puma/defaults/main.yml b/ansible/roles/puma/defaults/main.yml deleted file mode 100644 index 8284f49e..00000000 --- a/ansible/roles/puma/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -puma_app_name: "{{ app_name }}" -server_restart_command: /sbin/restart {{ app_name }} diff --git a/ansible/roles/puma/handlers/main.yml b/ansible/roles/puma/handlers/main.yml deleted file mode 100644 index 01377e2e..00000000 --- a/ansible/roles/puma/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: restart application - service: name={{ puma_app_name }} state=restarted - when: "'application' in group_names" diff --git a/ansible/roles/puma/tasks/main.yml b/ansible/roles/puma/tasks/main.yml deleted file mode 100644 index 1e18ae31..00000000 --- a/ansible/roles/puma/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: Configure puma - template: src=puma.rb.j2 dest={{ puma_config_path }} - -- name: Install puma - command: /bin/bash -l -c 'gem install puma --no-ri --no-rdoc' chdir={{ app_path }} - sudo: no - -- name: Create directories for sockets and pids - file: path={{ app_temp_path }}/{{ item }} state=directory - with_items: - - pids - - sockets - sudo: no - -- name: Create upstart config - template: src=upstart.conf.j2 dest=/etc/init/{{ puma_app_name }}.conf - notify: restart application diff --git a/ansible/roles/puma/templates/puma.rb.j2 b/ansible/roles/puma/templates/puma.rb.j2 deleted file mode 100644 index 3ec3e8fd..00000000 --- a/ansible/roles/puma/templates/puma.rb.j2 +++ /dev/null @@ -1,49 +0,0 @@ -# {{ ansible_managed }} - -# Feel free to experiment with this, 0/16 is a good starting point. -threads_count = Integer(ENV['MAX_THREADS'] || 5) -threads threads_count, threads_count - -# Go with at least 1 per CPU core, a higher amount will usually help for fast -# responses such as reading from a cache. -workers Integer(ENV['WEB_CONCURRENCY'] || 2) - -# Listen on a tcp port or unix socket. -bind "{{ puma_bind_path }}" - -# Set Port/Rack/Env -rackup DefaultRackup -port 3000 -environment "{{ rails_env }}" - -# The path where the pid file will be written to. -pidfile "{{ puma_pidfile_path }}" - -# Use a shorter timeout instead of the 60s default. If you are handling large -# uploads you may want to increase this. -worker_timeout 30 - -# The file that gets logged to. -stdout_redirect "{{ puma_stdout_redirect_path }}", "{{ puma_stderr_redirect_path }}" - -# Preload the application before starting the workers. -preload_app! - -# The path to the puma binary without any arguments, it will inherit everything -# from the original process. -restart_command 'bin/puma' - -on_worker_boot do - # Don't bother having the master process hang onto older connections. - defined?(ActiveRecord::Base) and - ActiveRecord::Base.connection.disconnect! - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.establish_connection - -{% if 'redis' in databases %} - # Connect to Redis - $redis.client.reconnect -{% endif %} - -end diff --git a/ansible/roles/puma/templates/upstart.conf.j2 b/ansible/roles/puma/templates/upstart.conf.j2 deleted file mode 100644 index aca29f39..00000000 --- a/ansible/roles/puma/templates/upstart.conf.j2 +++ /dev/null @@ -1,21 +0,0 @@ -# {{ ansible_managed }} - -description "{{ app_name }} puma app" - -start on runlevel [2] -stop on runlevel [016] - -env PATH=$PATH:/usr/local/bin:/usr/bin:/bin -env HOME={{ user_home_path }} - -respawn - -setuid {{ user_name }} -setgid {{ group_name }} - -chdir {{ app_path }} - -script - /bin/bash -l -c 'bundle exec puma -C {{ puma_config_path }}' - sleep 5 -end script diff --git a/ansible/roles/ruby/defaults/main.yml b/ansible/roles/ruby/defaults/main.yml deleted file mode 100644 index eb2664ee..00000000 --- a/ansible/roles/ruby/defaults/main.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -rvm1_install_path: '/home/{{ ansible_ssh_user }}/.rvm' -rvm1_rvm: '{{ rvm1_install_path }}/bin/rvm' -rvm1_install_flags: '--auto-dotfiles --user-install' -rvm1_user: '{{ user_name }}' -rvm1_rvm_latest_installer: 'https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer' -rvm1_rvm_version: 'stable' -rvm1_rvm_check_for_updates: no -rvm1_gpg_keys: 'D39DC0E3' -rvm1_gpg_key_server: 'hkp://keys.gnupg.net' -rvm1_temp_download_path: '/tmp' -rvm1_default_ruby_version: '{{ manual_ruby_version or ruby_version }}' -rvm1_symlink_binaries: - - 'bundle' - - 'bundler' - - 'erb' - - 'executable-hooks-uninstaller' - - 'gem' - - 'irb' - - 'rake' - - 'rdoc' - - 'ri' - - 'ruby' - - 'testrb' -rvm1_symlink_to: '/usr/local/bin' -rvm1_rubies: - - "{{ rvm1_default_ruby_version }}" - -rbenv_repo: https://github.com/sstephenson/rbenv.git -rbenv_version: master -rbenv_path: '{{ user_home_path }}/.rbenv' -rbenv_bin: '{{ rbenv_path }}/bin/rbenv' -rbenv_plugins_path: '{{ rbenv_path }}/plugins' -rbenv_plugins: - - name: ruby-build - git: https://github.com/sstephenson/ruby-build.git - version: master -rbenv_ruby_version: '{{ manual_ruby_version or ruby_version }}' diff --git a/ansible/roles/ruby/tasks/main.yml b/ansible/roles/ruby/tasks/main.yml deleted file mode 100644 index 0377554a..00000000 --- a/ansible/roles/ruby/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- include: package.yml - when: ruby_install == 'package' - -- include: rvm.yml - when: ruby_install == 'rvm' - -- include: rbenv.yml - when: ruby_install == 'rbenv' - -- name: Install bundler - command: /bin/bash -l -c 'gem install bundler --no-ri --no-rdoc' - sudo_user: '{{ ruby_user_name }}' - -- name: bundle install - command: /bin/bash -l -c 'bundle install' chdir={{ app_path }} - sudo_user: '{{ ruby_user_name }}' - when: target == 'virtualbox' diff --git a/ansible/roles/ruby/tasks/package.yml b/ansible/roles/ruby/tasks/package.yml deleted file mode 100644 index 0cd69ca2..00000000 --- a/ansible/roles/ruby/tasks/package.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- name: Add brightbox/ruby-ng repository - apt_repository: repo='ppa:brightbox/ruby-ng' - -- name: Install ruby - apt: name={{ item }} - with_items: - - "{{ ruby_version }}" - - "{{ ruby_version }}-dev" - - ruby-switch diff --git a/ansible/roles/ruby/tasks/rbenv.yml b/ansible/roles/ruby/tasks/rbenv.yml deleted file mode 100644 index f1e8251b..00000000 --- a/ansible/roles/ruby/tasks/rbenv.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- name: Install libffi-dev - apt: name=libffi-dev - -- name: Clone rbenv repository to ~/.rbenv - git: repo={{ rbenv_repo }} dest={{ rbenv_path }} version={{ rbenv_version }} accept_hostkey=yes - sudo_user: '{{ user_name }}' - -- name: Create rbenv.sh - template: src=rbenv.sh.j2 dest={{ profile_d_path }}/rbenv.sh owner={{ user_name }} group={{ group_name }} - -- name: Create plugins directory - file: path={{ rbenv_plugins_path }} state=directory owner={{ user_name }} group={{ group_name }} - -- name: Install plugins - git: repo={{ item.git }} dest={{ rbenv_plugins_path }}/{{ item.name }} version={{ item.version }} accept_hostkey=yes - sudo_user: '{{ user_name }}' - with_items: rbenv_plugins - -- name: Check if ruby installed - shell: '{{ rbenv_bin }} versions | grep -q {{ rbenv_ruby_version }}' - register: ruby_installed - ignore_errors: yes - sudo_user: '{{ user_name }}' - -- name: Install ruby - command: '{{ rbenv_bin }} install {{ rbenv_ruby_version }}' - sudo_user: '{{ user_name }}' - when: ruby_installed|failed - -- name: Set global ruby version - command: '{{ rbenv_bin }} global {{ rbenv_ruby_version }}' - sudo_user: '{{ user_name }}' - -- name: Rehash rbenv - command: '{{ rbenv_bin }} rehash' - sudo_user: '{{ user_name }}' diff --git a/ansible/roles/ruby/tasks/rvm.yml b/ansible/roles/ruby/tasks/rvm.yml deleted file mode 100644 index dce27119..00000000 --- a/ansible/roles/ruby/tasks/rvm.yml +++ /dev/null @@ -1,97 +0,0 @@ ---- -- name: Detect rvm binary - stat: path='{{ rvm1_rvm }}' - register: rvm_binary - -- name: Detect rvm installer - stat: path='{{ rvm1_temp_download_path }}/rvm-installer.sh' - register: rvm_installer - -- name: Detect current rvm version - command: '{{ rvm1_rvm}} version' - changed_when: False - register: rvm_current_version - when: rvm_binary.stat.exists - -- name: Install rvm installer - get_url: - url: '{{ rvm1_rvm_latest_installer }}' - dest: '{{ rvm1_temp_download_path }}/rvm-installer.sh' - when: not rvm_installer.stat.exists - -- name: Configure rvm installer - file: - path: '{{ rvm1_temp_download_path }}/rvm-installer.sh' - mode: 0755 - when: not rvm_binary.stat.exists - -- name: Import GPG keys - command: 'gpg --keyserver {{ rvm1_gpg_key_server }} --recv-keys {{ rvm1_gpg_keys }}' - changed_when: False - when: rvm1_gpg_keys != '' - sudo_user: '{{ rvm1_user }}' - -- name: Install rvm - command: > - {{ rvm1_temp_download_path }}/rvm-installer.sh {{ rvm1_rvm_version }} - --path {{ rvm1_install_path }} {{ rvm1_install_flags }} - when: not rvm_binary.stat.exists - sudo_user: '{{ rvm1_user }}' - -- name: Update rvm - shell: '{{ rvm1_rvm }} get {{ rvm1_rvm_version }} && {{ rvm1_rvm }} reload' - changed_when: False - when: rvm_binary.stat.exists and rvm1_rvm_check_for_updates - sudo_user: '{{ rvm1_user }}' - -- name: Configure rvm - command: '{{ rvm1_rvm }} autolibs 3' - when: not rvm_binary.stat.exists - sudo_user: '{{ rvm1_user }}' - -- name: Detect if rubies are installed - command: '{{ rvm1_rvm }} {{ item }} do true' - changed_when: False - failed_when: False - register: detect_rubies - with_items: rvm1_rubies - -- name: Install rubies - command: '{{ rvm1_rvm }} install {{ item.item }} --binary' - when: item.rc != 0 - with_items: detect_rubies.results - sudo_user: '{{ rvm1_user }}' - register: install_rubies - ignore_errors: yes - -# Try to install non-binary version if previous command failed -# https://github.com/andreychernih/railsbox/issues/13 -- name: Install rubies (non-binary) - command: '{{ rvm1_rvm }} install {{ item.item }}' - when: item.rc != 0 and install_rubies.results[0].rc != 0 - with_items: detect_rubies.results - sudo_user: '{{ rvm1_user }}' - -- name: Detect default ruby version - command: '{{ rvm1_rvm }} alias list default' - changed_when: False - register: detect_default_ruby_version - -- name: Select default ruby - command: '{{ rvm1_rvm }} alias create default {{ rvm1_default_ruby_version }}' - when: detect_default_ruby_version.stdout == '' or - rvm1_default_ruby_version not in detect_default_ruby_version.stdout - -- name: Symlink ruby related binaries on the system path - file: - state: 'link' - src: '{{ rvm1_install_path }}/wrappers/default/{{ item }}' - dest: '{{ rvm1_symlink_to }}/{{ item }}' - owner: 'root' - group: 'root' - force: yes - when: not '--user-install' in rvm1_install_flags - with_items: rvm1_symlink_binaries - -- name: Create rvm.sh - template: src=rvm.sh.j2 dest={{ profile_d_path }}/rvm.sh owner={{ user_name }} group={{ group_name }} diff --git a/ansible/roles/ruby/templates/rbenv.sh.j2 b/ansible/roles/ruby/templates/rbenv.sh.j2 deleted file mode 100644 index be3c533c..00000000 --- a/ansible/roles/ruby/templates/rbenv.sh.j2 +++ /dev/null @@ -1,4 +0,0 @@ -# {{ ansible_managed }} - -export PATH="{{ rbenv_path }}/bin:$PATH" -eval "$(rbenv init -)" diff --git a/ansible/roles/ruby/templates/rvm.sh.j2 b/ansible/roles/ruby/templates/rvm.sh.j2 deleted file mode 100644 index b545b779..00000000 --- a/ansible/roles/ruby/templates/rvm.sh.j2 +++ /dev/null @@ -1,3 +0,0 @@ -# {{ ansible_managed }} - -source $HOME/.rvm/scripts/rvm \ No newline at end of file diff --git a/ansible/roles/sidekiq/defaults/main.yml b/ansible/roles/sidekiq/defaults/main.yml deleted file mode 100644 index 75d28373..00000000 --- a/ansible/roles/sidekiq/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -sidekiq: true diff --git a/ansible/roles/sidekiq/handlers/main.yml b/ansible/roles/sidekiq/handlers/main.yml deleted file mode 100644 index 85e0730c..00000000 --- a/ansible/roles/sidekiq/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: restart sidekiq - service: name={{ sidekiq_app_name }} state=restarted - when: sidekiq|default(false) diff --git a/ansible/roles/sidekiq/tasks/main.yml b/ansible/roles/sidekiq/tasks/main.yml deleted file mode 100644 index 74870c99..00000000 --- a/ansible/roles/sidekiq/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: Create upstart config - template: src=upstart.conf.j2 dest=/etc/init/{{ sidekiq_app_name }}.conf - notify: restart sidekiq diff --git a/ansible/roles/sidekiq/templates/upstart.conf.j2 b/ansible/roles/sidekiq/templates/upstart.conf.j2 deleted file mode 100644 index caeb0ff3..00000000 --- a/ansible/roles/sidekiq/templates/upstart.conf.j2 +++ /dev/null @@ -1,21 +0,0 @@ -# {{ ansible_managed }} - -description "{{ app_name }} sidekiq" - -start on runlevel [2] -stop on runlevel [016] - -env PATH=$PATH:/usr/local/bin:/usr/bin:/bin -env HOME={{ user_home_path }} - -respawn - -setuid {{ user_name }} -setgid {{ group_name }} - -chdir {{ app_path }} - -script - /bin/bash -l -c 'bundle exec {{ sidekiq_command }}' - sleep 5 -end script diff --git a/ansible/roles/swap/defaults/main.yml b/ansible/roles/swap/defaults/main.yml deleted file mode 100644 index e1014207..00000000 --- a/ansible/roles/swap/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -swap_file_path: /swapfile \ No newline at end of file diff --git a/ansible/roles/swap/tasks/main.yml b/ansible/roles/swap/tasks/main.yml deleted file mode 100644 index e79172f8..00000000 --- a/ansible/roles/swap/tasks/main.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Create swap file - command: fallocate -l {{ vm_swap }}M {{ swap_file_path }} creates={{ swap_file_path }} - -- name: Change swap permissions - file: path={{ swap_file_path }} mode=0600 - -- name: Check swap file type - command: file {{ swap_file_path }} - register: swapfile - -- name: Make swap file - command: mkswap {{ swap_file_path }} - when: swapfile.stdout.find('swap file') == -1 - -- name: Write swap entry in fstab - mount: name=none - src={{ swap_file_path }} - fstype=swap - opts=sw - passno=0 - dump=0 - state=present - register: write_swap_entry - -- name: Mount swap - command: "swapon {{ swap_file_path }}" - when: write_swap_entry|changed diff --git a/ansible/roles/unicorn/defaults/main.yml b/ansible/roles/unicorn/defaults/main.yml deleted file mode 100644 index c5d7e3ca..00000000 --- a/ansible/roles/unicorn/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -unicorn_app_name: "{{ app_name }}" -server_restart_command: /sbin/restart {{ app_name }} diff --git a/ansible/roles/unicorn/handlers/main.yml b/ansible/roles/unicorn/handlers/main.yml deleted file mode 100644 index cabbfacb..00000000 --- a/ansible/roles/unicorn/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: restart application - service: name={{ unicorn_app_name }} state=restarted - when: "'application' in group_names" diff --git a/ansible/roles/unicorn/tasks/main.yml b/ansible/roles/unicorn/tasks/main.yml deleted file mode 100644 index a8e570f6..00000000 --- a/ansible/roles/unicorn/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- name: Configure unicorn - template: src=unicorn.rb.j2 dest={{ unicorn_config_path }} - -- name: Install unicorn - command: /bin/bash -l -c 'gem install unicorn --no-ri --no-rdoc' chdir={{ app_path }} - sudo: no - -- name: Create upstart config - template: src=upstart.conf.j2 dest=/etc/init/{{ unicorn_app_name }}.conf - notify: restart application diff --git a/ansible/roles/unicorn/templates/unicorn.rb.j2 b/ansible/roles/unicorn/templates/unicorn.rb.j2 deleted file mode 100644 index 51e2d345..00000000 --- a/ansible/roles/unicorn/templates/unicorn.rb.j2 +++ /dev/null @@ -1,14 +0,0 @@ -# {{ ansible_managed }} - -working_directory '{{ app_path }}' - -pid '{{ unicorn_pid_path }}' - -stderr_path '{{ unicorn_stderr_path }}' -stdout_path '{{ unicorn_stdout_path }}' - -listen '{{ unicorn_sock_path }}' - -worker_processes 2 - -timeout 30 diff --git a/ansible/roles/unicorn/templates/upstart.conf.j2 b/ansible/roles/unicorn/templates/upstart.conf.j2 deleted file mode 100644 index f76df735..00000000 --- a/ansible/roles/unicorn/templates/upstart.conf.j2 +++ /dev/null @@ -1,21 +0,0 @@ -# {{ ansible_managed }} - -description "{{ app_name }} unicorn app" - -start on runlevel [2] -stop on runlevel [016] - -env PATH=$PATH:/usr/local/bin:/usr/bin:/bin -env HOME={{ user_home_path }} - -respawn - -setuid {{ user_name }} -setgid {{ group_name }} - -chdir {{ app_path }} - -script - /bin/bash -l -c 'bundle exec unicorn -c {{ unicorn_config_path }}' - sleep 5 -end script diff --git a/ansible/roles/vim/defaults/main.yml b/ansible/roles/vim/defaults/main.yml deleted file mode 100644 index 7feb950c..00000000 --- a/ansible/roles/vim/defaults/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -vim_autoload_path: '{{ user_home_path }}/.vim/autoload' -vim_bundle_path: '{{ user_home_path }}/.vim/bundle' -vim_plugins: - - name: vim-sensible - git: git://github.com/tpope/vim-sensible.git - - name: vim-rails - git: git://github.com/tpope/vim-rails.git - - name: vim-bundler - git: git://github.com/tpope/vim-bundler.git diff --git a/ansible/roles/vim/tasks/main.yml b/ansible/roles/vim/tasks/main.yml deleted file mode 100644 index 816b9a9c..00000000 --- a/ansible/roles/vim/tasks/main.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Install vim - apt: name=vim - -- name: Prepare dirs for pathogen.vim - file: path={{ item }} state=directory owner={{ user_name }} group={{ group_name }} recurse=yes - with_items: - - '{{ vim_autoload_path }}' - - '{{ vim_bundle_path }}' - -- name: Install pathogen.vim - get_url: url=https://tpo.pe/pathogen.vim dest={{ vim_autoload_path }}/pathogen.vim - sudo_user: '{{ user_name }}' - -- name: Create ~/.vimrc - template: src=vimrc.j2 dest={{ user_home_path }}/.vimrc owner={{ user_name }} group={{ group_name }} - -- name: Install plugins - git: repo={{ item.git }} dest={{ vim_bundle_path }}/{{ item.name }} version=master accept_hostkey=yes - sudo_user: '{{ user_name }}' - with_items: vim_plugins diff --git a/ansible/roles/vim/templates/vimrc.j2 b/ansible/roles/vim/templates/vimrc.j2 deleted file mode 100644 index 71d5cb88..00000000 --- a/ansible/roles/vim/templates/vimrc.j2 +++ /dev/null @@ -1,5 +0,0 @@ -" {{ ansible_managed }} - -execute pathogen#infect() -syntax on -filetype plugin indent on diff --git a/ansible/roles/webserver/meta/main.yml b/ansible/roles/webserver/meta/main.yml deleted file mode 100644 index d30011f3..00000000 --- a/ansible/roles/webserver/meta/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -dependencies: - - nginx - - puma diff --git a/ansible/roles/webserver/tasks/main.yml b/ansible/roles/webserver/tasks/main.yml deleted file mode 100644 index 9951ef66..00000000 --- a/ansible/roles/webserver/tasks/main.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- include: remote.yml - when: target == 'server' - -- name: Create and migrate DB - command: /bin/bash -l -c 'rake db:create db:migrate' chdir={{ app_path }} - sudo_user: '{{ user_name }}' - ignore_errors: yes - tags: - - rails - - db - -- name: Echo cd into .bashrc - command: /bin/bash -l -c 'echo "cd /code-corps-api" >> /home/vagrant/.bashrc' diff --git a/ansible/roles/webserver/tasks/remote.yml b/ansible/roles/webserver/tasks/remote.yml deleted file mode 100644 index 538384d0..00000000 --- a/ansible/roles/webserver/tasks/remote.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -- name: Authorize current user - authorized_key: user={{ user_name }} key='{{ lookup('file', '~/.ssh/id_rsa.pub') }}' - -- name: Allow to start / stop app with sudo - template: src=sudoers.d.conf.j2 dest=/etc/sudoers.d/{{ app_name }} validate='visudo -cf %s' - -- name: Create directories - file: path={{ item }} state=directory owner={{ user_name }} group={{ group_name }} - with_items: - - '{{ path }}' - - '{{ releases_path }}' - - '{{ shared_path }}' - - '{{ shared_path }}/tmp' - - '{{ shared_path }}/log' - - '{{ shared_path }}/config' - - '{{ shared_path }}/vendor' - - '{{ shared_path }}/vendor/bundle' - -- name: Check if config/{{ item }}.yml exists - stat: - path: ../../config/{{ item }}.yml - connection: local - sudo: no - register: configs - with_items: - - database - - secrets - -- name: Copy config/{{ item.item }}.yml to {{ shared_path }}/config - copy: - src: ../../../../../config/{{ item.item }}.yml - dest: '{{ shared_path }}/config/{{ item.item }}.yml' - owner: '{{ user_name }}' - group: '{{ group_name }}' - mode: 0600 - with_items: configs.results - when: item.stat.exists diff --git a/ansible/roles/webserver/templates/sudoers.d.conf.j2 b/ansible/roles/webserver/templates/sudoers.d.conf.j2 deleted file mode 100644 index 00437f90..00000000 --- a/ansible/roles/webserver/templates/sudoers.d.conf.j2 +++ /dev/null @@ -1 +0,0 @@ -{{ user_name }} ALL=NOPASSWD: /sbin/start {{ app_name }}, /sbin/stop {{ app_name }}, {{ server_restart_command }} diff --git a/ansible/site.retry b/ansible/site.retry deleted file mode 100644 index d36b528c..00000000 --- a/ansible/site.retry +++ /dev/null @@ -1 +0,0 @@ -code-corps-api diff --git a/ansible/site.yml b/ansible/site.yml deleted file mode 100644 index 917f0d84..00000000 --- a/ansible/site.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- -- hosts: vm - roles: - - swap - -- hosts: all - gather_facts: no - roles: - - { role: apt_proxy, when: use_apt_proxy } - tasks: - - name: Update apt cache - apt: - update_cache: yes - cache_valid_time: 3600 - -- hosts: postgresql - roles: - - postgresql - -- hosts: elasticsearch - become: yes - become_user: root - roles: - - { role: geerlingguy.elasticsearch } - -- hosts: application - handlers: - - include: roles/sidekiq/handlers/main.yml - roles: - - base - - { role: ruby, tags: ruby } - - vim - - webserver - -- hosts: sidekiq - handlers: - - include: roles/puma/handlers/main.yml - roles: - - base - - ruby - - { role: geerlingguy.redis } - - { role: sidekiq, tags: sidekiq } - -- hosts: application - handlers: - - include: roles/sidekiq/handlers/main.yml - roles: - - base - - { role: ruby, tags: ruby } - - vim - - webserver diff --git a/bin/colors b/bin/colors new file mode 100755 index 00000000..a4800d75 --- /dev/null +++ b/bin/colors @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +export red=$'\e[1;31m' +export green=$'\e[0;32m' +export yellow=$'\e[1;33m' +export blue=$'\e[1;34m' diff --git a/bin/migrate b/bin/migrate new file mode 100755 index 00000000..8f23cb57 --- /dev/null +++ b/bin/migrate @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Exit if any subcommand fails +set -e + +# Import colors +. bin/colors + +# Check for tools that need to be installed +dependencies='docker-compose' +for name in $dependencies +do + if ! which "$name" > /dev/null; then + echo -e "${red}\xE2\x9D\x8C $name not installed! Exiting.${end}" + echo "${yellow}You'll need to reinstall $name to continue.${end}" + exit 1 + fi +done + +printf "\nMigrating database...\n" +docker-compose run web rake db:migrate db:test:prepare + +echo "" +echo "🙌 ${green}Migrate complete.${end}" +exit 0 diff --git a/bin/reseed b/bin/reseed new file mode 100755 index 00000000..8d8e3133 --- /dev/null +++ b/bin/reseed @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Exit if any subcommand fails +set -e + +# Import colors +. bin/colors + +# Check for tools that need to be installed +dependencies='docker-compose' +for name in $dependencies +do + if ! which "$name" > /dev/null; then + echo -e "${red}\xE2\x9D\x8C $name not installed! Exiting.${end}" + echo "${yellow}You'll need to reinstall $name to continue.${end}" + exit 1 + fi +done + +printf "\nMigrating database...\n" +docker-compose run web rake db:migrate db:test:prepare + +printf "\nSeeding database...\n" +docker-compose run web rake db:seed_fu + +printf "\nReindexing elasticsearch...\n" +docker-compose run web rake searchkick:reindex CLASS=Skill + +echo "" +echo "🌱 ${green}Reseed complete.${end}" +exit 0 diff --git a/bin/setup b/bin/setup index 761fd0f4..bc37412a 100755 --- a/bin/setup +++ b/bin/setup @@ -3,41 +3,37 @@ # Exit if any subcommand fails set -e +# Import colors +. bin/colors -# Set up configurable environment variables -# if [ ! -f './config/.env' ]; then -# echo '==| creating .env' -# cp config/.env.sample config/.env -# fi - - - # Check for tools that need to be installed -dependencies='redis-server postgres foreman heroku' +# Check for tools that need to be installed +dependencies='docker-compose' for name in $dependencies do if ! which "$name" > /dev/null; then - echo "== $name not installed! Exiting." + echo -e "${red}\xE2\x9D\x8C $name not installed! Exiting.${end}" exit 1 fi done -echo "== Installing dependencies ==" -gem install bundler --conservative -bundle check || bundle install +if docker-compose run web rake db:exists > /dev/null; then + echo -e "${red}\xE2\x9D\x8C Database already exists! Exiting.${end}" + exit 1 +fi + +printf "\nPreparing database...\n" +# Creates the database. +docker-compose run web rake db:create db:migrate db:test:prepare +printf "\nSeeding database...\n" +docker-compose run web rake db:seed_fu -echo "== Preparing database ==" -# Drops & recreates the database if it already exists. -bundle exec rake db:drop db:create db:migrate db:test:prepare db:seed -bundle exec rake db:seed_fu +printf "\nReindexing elasticsearch...\n" +docker-compose run web rake searchkick:reindex CLASS=Skill -echo "== Removing old logs and tempfiles ==" +printf "\nRemoving old logs and tempfiles...\n" rm -f log/* rm -rf tmp/cache -echo "== Restarting application server ==" -touch tmp/restart.txt - - -echo "== Setup complete." +printf "\n🌤 ${green}Setup complete.${end}" exit 0 diff --git a/bin/update b/bin/update deleted file mode 100755 index a8e4462f..00000000 --- a/bin/update +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -require 'pathname' -require 'fileutils' -include FileUtils - -# path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) - -def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") -end - -chdir APP_ROOT do - # This script is a way to update your development environment automatically. - # Add necessary update steps to this file. - - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') - - puts "\n== Updating database ==" - system! 'bin/rails db:migrate' - - puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' - - puts "\n== Restarting application server ==" - system! 'bin/rails restart' -end diff --git a/config/database.yml b/config/database.yml index 6179ad48..4f7984c1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,11 +1,13 @@ -test: +default: &default adapter: postgresql + username: postgres + host: db + port: 5432 + role: postgres + +test: + <<: *default database: code_corps_test - host: localhost - password: password development: - adapter: postgresql + <<: *default database: code_corps_dev - role: postgres - password: password - host: localhost diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index 124383f1..40e25a2d 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -1,6 +1,6 @@ if ENV["REDISCLOUD_URL"] ENV["REDIS_URL"] = ENV["REDISCLOUD_URL"] - $redis = Redis.new(:url => ENV["REDISCLOUD_URL"]) + $redis = Redis.new(url: ENV["REDIS_URL"]) elsif Rails.env.test? $redis = Redis.new -end \ No newline at end of file +end diff --git a/config/puma.development.rb b/config/puma.development.rb deleted file mode 100644 index 3b1a799a..00000000 --- a/config/puma.development.rb +++ /dev/null @@ -1,45 +0,0 @@ -# Ansible managed: /Users/joshsmith/apis/code-corps-api/ansible/roles/puma/templates/puma.rb.j2 modified on 2016-07-05 14:27:54 by joshsmith on Joshs-MacBook-Pro.local - -# Feel free to experiment with this, 0/16 is a good starting point. -threads_count = Integer(ENV['MAX_THREADS'] || 5) -threads threads_count, threads_count - -# Go with at least 1 per CPU core, a higher amount will usually help for fast -# responses such as reading from a cache. -workers Integer(ENV['WEB_CONCURRENCY'] || 2) - -# Listen on a tcp port or unix socket. -bind "unix:///tmp/code-corps-api/sockets/puma.development.sock" - -# Set Port/Rack/Env -rackup DefaultRackup -port 3000 -environment "development" - -# The path where the pid file will be written to. -pidfile "/tmp/code-corps-api/pids/puma.development.pid" - -# Use a shorter timeout instead of the 60s default. If you are handling large -# uploads you may want to increase this. -worker_timeout 30 - -# The file that gets logged to. -stdout_redirect "/code-corps-api/log/puma.development.log", "/code-corps-api/log/puma.development.err.log" - -# Preload the application before starting the workers. -preload_app! - -# The path to the puma binary without any arguments, it will inherit everything -# from the original process. -restart_command 'bin/puma' - -on_worker_boot do - # Don't bother having the master process hang onto older connections. - defined?(ActiveRecord::Base) and - ActiveRecord::Base.connection.disconnect! - - defined?(ActiveRecord::Base) and - ActiveRecord::Base.establish_connection - - -end diff --git a/db/fixtures/001_users.rb b/db/fixtures/001_users.rb index 1ebc5a12..658a6eb2 100644 --- a/db/fixtures/001_users.rb +++ b/db/fixtures/001_users.rb @@ -8,8 +8,8 @@ User.seed do |user| user.id = 2 - user.username = "codecorpsguy" - user.email = "guy@codecorps.com" - user.password = "codecorps" + user.username = "testuser" + user.email = "test@example.com" + user.password = "test" user.admin = false end diff --git a/db/fixtures/007_skills.rb b/db/fixtures/007_skills.rb new file mode 100644 index 00000000..afb0ad47 --- /dev/null +++ b/db/fixtures/007_skills.rb @@ -0,0 +1,27 @@ +skills = [ + { + title: "Ember.js", + }, + { + title: "HTML", + }, + { + title: "CSS", + }, + { + title: "Ruby", + }, + { + title: "Ruby on Rails", + }, + { + title: "Docker", + }, +] + +skills.each do |skill| + Skill.seed_once(:title) do |s| + s.title = skill[:title] + s.slug = skill[:title].parameterize + end +end diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..c4b43be7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,63 @@ +version: "2" + +services: + db: + image: postgres + expose: + - "5432" + volumes: + - postgres-data:/var/lib/postgresql + + elasticsearch: + image: elasticsearch + expose: + - "9200" + + proxy: + image: jwilder/nginx-proxy:latest + ports: + - 80:80 + volumes: + - "/var/run/docker.sock:/tmp/docker.sock" + + redis: + image: redis + ports: + - 6380:6379 + volumes: + - redis-data:/var/lib/redis + + web: &api_base + build: . + command: foreman s -f Procfile.dev + depends_on: + - db + - elasticsearch + - redis + environment: &api_environment + ELASTICSEARCH_URL: http://elasticsearch:9200 + RACK_ENV: development + RAILS_ENV: development + REDIS_URL: redis://redis:6379 + VIRTUAL_HOST: lvh.me,api.lvh.me + links: + - db + - elasticsearch + ports: + - 5001:5000 + volumes: + - .:/code-corps-api + + test: + <<: *api_base + command: guard start --no-bundler-warning --no-interactions + environment: + <<: *api_environment + RACK_ENV: test + RAILS_ENV: test + ports: [] + +volumes: + postgres-data: + redis-data: + diff --git a/docs/DEFAULT_INSTALL.md b/docs/DEFAULT_INSTALL.md index 88726991..468224d3 100644 --- a/docs/DEFAULT_INSTALL.md +++ b/docs/DEFAULT_INSTALL.md @@ -2,16 +2,11 @@ ### Requirements -You will need [VirtualBox](https://www.virtualbox.org/wiki/Downloads), [Vagrant](https://www.vagrantup.com/downloads.html) and [Ansible](http://docs.ansible.com/intro_installation.html) to be installed. Ansible also requires Python and some Python modules to be installed. +You will need to install [Docker](https://docs.docker.com/engine/installation/). -The fastest way to install VirtualBox and Vagrant is to use [`brew cask`](https://github.com/caskroom/homebrew-cask). Ansible can be installed with Homebrew as well: +Here are some direct links if you're on [Mac OS X](https://docs.docker.com/docker-for-mac/) or [Windows](https://docs.docker.com/docker-for-windows/). -```shell -brew install caskroom/cask/brew-cask -brew cask install virtualbox -brew cask install vagrant -brew install ansible -``` +Follow those download instructions. Once you can run the `docker` command, you can safely move on. ### Clone this repository @@ -20,46 +15,89 @@ You'll want to [clone this repository](https://help.github.com/articles/cloning- The directory structure will look like the following: ```shell -code-corps-api/ # → Root folder for this project -├── ansible/ # → Ansible root, containing playbooks for provisioning +code-corps-api/ # → Root folder for this project ├── app/ ├── bin/ -├── ... # → More standard Rails files -├── ansible.cfg # → Ansible configuration file; should not need to touch this -└── Vagrantfile # → Configuration file for your virtual machine +├── ... # → More standard Rails files +├── docker-compose.yml # → Compose file for configuring Docker containers +└── Dockerfile # → Creates base Ruby Docker container ``` -### Start the VM +### Setup your Docker containers and run the server + +> Note: We bind to ports 6380 for `redis` and 5001 for `foreman`. Make sure you're not running anything on those ports. We do not expose port 5432 for `postgres` or 9200 for `elasticsearch`. Go to the `code-corps-api` directory and type: ```shell -vagrant up +docker-compose up ``` -Vagrant will download a `trusty64` Linux box and provision it using the Ansible configuration provided in `code-corps-api/ansible`. +Docker will set up your base Ruby container, as well as containers for: + +- `postgres` +- `elasticsearch` +- `redis` +- `web` runs `foreman s` with the `Procfile.dev` +- `test` runs `guard start` + +You can view more detailed information about these services in the `docker-compose.yml` file, but you shouldn't need to edit it unless you're intentionally contributing changes to our Docker workflow. + +### Setup your database -Vagrant will likely for a `sudo` password. This is normal. It's required when doing NFS folder synchronization. +You can now create and seed your database in the `web` container with our helpful bash script: -When Vagrant has fully provisioned, you can log into the machine by running: +```shell +bin/setup +``` + +At its heart, this script is running: ```shell -vagrant ssh +docker-compose run web rake db:create db:migrate db:test:prepare db:seed_fu ``` -We'll automatically `cd` you into the `/code-corps-api` project directory, which is file synced to your cloned repository on your own machine. Changes made in `vagrant` will reflect on your machine, and vice versa. +Point your browser (or make a direct request) to `http://api.lvh.me/ping`. There should be a `{"ping":"pong"}` response from it. If you hit the index route instead, you'll probably get `INDEX NOT FOUND` since it's not serving up our Ember app yet. +`lvh.me` resolves to `localhost` so you can use subdomains, like our `api` subdomain. -### Start the server +### Interacting with the app -Now you can simply run: +You'll notice we wrapped `docker-compose` earlier, but you'll generally want to use this to interact with the app. -```shell -foreman s -f Procfile.dev -``` +- `bundle exec rails console` → `docker-compose run web rails console` +- `bundle exec rake db:migrate` → `docker-compose run web rake db:migrate` +- `bundle exec rake db:test:prepare` → `docker-compose run web rake db:test:prepare` +- and so on... + +We do have a couple other helper scripts: -Point your browser (or make a direct request) to http://api.codecorps.dev:5000/ping. There should be a `{"ping":"pong"}` response from it. +- `bin/setup` → sets up the app +- `bin/migrate` → migrates your database +- `bin/reseed` → re-runs `rake db:seed_fu` to re-seed your database + +### Guard and tests + +You'll also notice that the `test` container we mentioned above is running `guard`. This means that file changes will be observed and tests re-run on those files. + +You can certainly run `docker-console run test rspec spec`, but `guard` can help you by constantly watching for failing specs. + +### Stopping, starting, and rebuilding + +Need to stop the containers? Either `Ctrl+C` or in a seperate prompt run `docker-compose stop`. + +To start the services again you can run `docker-compose up`, or `docker-compose start` to start the containers in a detached state. + +If you ever need to rebuild you can run `docker-compose up --build`. Unless you've destroyed your Docker container images, this should be faster than the first run. ### Pushing changes -You can use `git` as you normally would, either on the guest `vagrant` machine or on your own host machine. +You can use `git` as you normally would, either on your own host machine or in Docker's `web` container. + +### Issues + +Having trouble? + +Create an issue in this repo and we'll look into it. + +Docker's a bit new for us, so there may be some hiccups at first. But hopefully this makes for a less painful developer environment for you in the long run. diff --git a/lib/tasks/db_exists.rake b/lib/tasks/db_exists.rake new file mode 100644 index 00000000..253edbfb --- /dev/null +++ b/lib/tasks/db_exists.rake @@ -0,0 +1,13 @@ +namespace :db do + desc "Checks to see if the database exists" + task :exists do + begin + Rake::Task["environment"].invoke + ActiveRecord::Base.connection + rescue + exit 1 + else + exit 0 + end + end +end diff --git a/log/.keep b/log/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/shell/1-install-ansible.sh b/shell/1-install-ansible.sh deleted file mode 100755 index dab571dc..00000000 --- a/shell/1-install-ansible.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -e - -if ! command -v ansible >/dev/null; then - sudo apt-get update - - sudo add-apt-repository -y ppa:ansible/ansible - sudo apt-get update - sudo apt-get install -y ansible -fi diff --git a/shell/2-configure-ansible.sh b/shell/2-configure-ansible.sh deleted file mode 100755 index d2551368..00000000 --- a/shell/2-configure-ansible.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -e - -cat > /tmp/hosts << "EOF" -[all] -127.0.0.1 - -[application] -127.0.0.1 - -[vm] -127.0.0.1 - -[development] -127.0.0.1 - -[postgresql] -127.0.0.1 - -[sidekiq] -127.0.0.1 - -EOF - -sudo mv -f /tmp/hosts /etc/ansible/hosts diff --git a/shell/3-provision.sh b/shell/3-provision.sh deleted file mode 100755 index d15ea0d9..00000000 --- a/shell/3-provision.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -e - -ansible-playbook $@ /ansible/site.yml --connection=local -s diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb index becd3201..af4340a2 100644 --- a/spec/support/vcr.rb +++ b/spec/support/vcr.rb @@ -10,5 +10,7 @@ c.default_cassette_options = { :serialize_with => :psych } + c.ignore_hosts "elasticsearch" + ignore_localhost = true end