From bd0a241c6ded93f1f7cc6cb032a7c69149c06420 Mon Sep 17 00:00:00 2001 From: Mark Heiges Date: Wed, 20 Dec 2017 22:03:02 -0500 Subject: [PATCH] updates for redmine-install 2.0.2, rvm_io.ruby,et al. --- .gitignore | 2 + README.md | 11 +- Vagrantfile | 2 + config.yml | 9 +- playbook.yml | 5 +- requirements.yml | 2 + roles/easyredmine/files/rvm_install | 888 ------------------ roles/easyredmine/tasks/main.yml | 12 +- roles/easyredmine/tasks/redmine.yml | 18 +- roles/easyredmine/tasks/system.yml | 2 +- .../easyredmine/templates/install_wrapper.j2 | 69 +- roles/easyredmine/templates/passenger.conf.j2 | 2 +- roles/rvm_io.ruby.patch/README.md | 23 + roles/rvm_io.ruby.patch/defaults/main.yml | 2 + roles/rvm_io.ruby.patch/files/rvm.sh | 47 + roles/rvm_io.ruby.patch/handlers/main.yml | 2 + roles/rvm_io.ruby.patch/meta/main.yml | 57 ++ roles/rvm_io.ruby.patch/tasks/main.yml | 9 + roles/rvm_io.ruby.patch/tests/inventory | 2 + roles/rvm_io.ruby.patch/tests/test.yml | 5 + roles/rvm_io.ruby.patch/vars/main.yml | 2 + 21 files changed, 217 insertions(+), 954 deletions(-) create mode 100644 requirements.yml delete mode 100644 roles/easyredmine/files/rvm_install create mode 100644 roles/rvm_io.ruby.patch/README.md create mode 100644 roles/rvm_io.ruby.patch/defaults/main.yml create mode 100644 roles/rvm_io.ruby.patch/files/rvm.sh create mode 100644 roles/rvm_io.ruby.patch/handlers/main.yml create mode 100644 roles/rvm_io.ruby.patch/meta/main.yml create mode 100644 roles/rvm_io.ruby.patch/tasks/main.yml create mode 100644 roles/rvm_io.ruby.patch/tests/inventory create mode 100644 roles/rvm_io.ruby.patch/tests/test.yml create mode 100644 roles/rvm_io.ruby.patch/vars/main.yml diff --git a/.gitignore b/.gitignore index a924d1f..294d9ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ production_inventory production_config.yml .DS_Store +roles/rvm_io.ruby .vagrant scratch/* +playbook.retry !.gitignore diff --git a/README.md b/README.md index 0c01150..9ccd4e7 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,11 @@ Once provisioned, Redmine should be available at http://redmine.vm.apidb.org/ - Ansible [installed on your local host](http://docs.ansible.com/ansible/intro_installation.html) -- `rvm1-ansible` Ansible module installed on your local host +- `rvm_io.ruby` Ansible module installed on your local host + + $ ansible-galaxy install rvm_io.ruby + $ ansible-galaxy install rvm_io.ruby --roles-path=roles/ - $ ansible-galaxy install rvm_io.rvm1-ruby - Vagrant `landrush` plugin @@ -42,8 +44,6 @@ does local authentication, so no VPN is needed in such case. ## Provisioning -Start the virtual machine with `vagrant up`. - Vagrant provisions the VM using Ansible. See `config.yml` for configuration options. Especially, @@ -65,6 +65,9 @@ hang indefinitely waiting for input that the non-interactive script cannot provide. The `~/install.log` captures the stdout of the process and should be consulted to check for running state. +Start the virtual machine with `vagrant up`. This boots the VM and +starts provisioning. + ## Production Installation See https://wiki.apidb.org/index.php/EasyRedmineVM for instructions for diff --git a/Vagrantfile b/Vagrantfile index e02b8a8..3d096cc 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -23,6 +23,8 @@ Vagrant.configure(2) do |config| config.vm.provision 'deploy', type: 'ansible' do |ansible| ansible.playbook = 'playbook.yml' + ansible.galaxy_role_file = 'requirements.yml' + ansible.galaxy_roles_path = 'roles' end end diff --git a/config.yml b/config.yml index 500aef4..3d81488 100644 --- a/config.yml +++ b/config.yml @@ -10,7 +10,7 @@ do_redmine_db_import: True # no import unless do_database_management is also tru do_redmine_installer: True remote_scratch_path: /vagrant/scratch nginx_pem: redmine.vm-rsa.pem -installer_package_name: easyredmine_2016_stable_u2072_v2016_03_07.zip +installer_package_name: easyredmine_2016_stable_u2072_v2016_08_08___2018_00_08_.zip installer_package_path: '{{ remote_scratch_path }}/{{ installer_package_name }}' installer_package_url: 'http://software.apidb.org/source/{{ installer_package_name }}' redmine_db_dump_file: '{{ remote_scratch_path }}/redmine_dump.sql.gz' @@ -31,8 +31,9 @@ smtp_username: smtpuser smtp_password: smtppassword smtp_authentication: plain smtp_enable_starttls: true +smtp_openssl_verify_mode: peer swap_add_mb: 512 -ruby_version: 2.1.3 +ruby_version: 2.4.1 is_production_vm: False redmine_files_nfs_mount: '' # /mnt/redminefiles redmine_files_nfs_source: '' # 171.26.20.75:/srv/easyredmine @@ -43,5 +44,7 @@ _redmine_install_wrapper: '/home/{{ redmine_owner }}/install_wrapper' # rvm1-ansible module vars rvm1_rubies: - 'ruby-{{ ruby_version }}' +rvm1_bundler_install: yes +rvm1_install_path: '/home/{{ redmine_owner }}/.rvm' rvm1_rvm_check_for_updates: False - +rvm1_user: '{{ redmine_owner }}' diff --git a/playbook.yml b/playbook.yml index 7b5da60..bf89acf 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,12 +1,13 @@ --- - hosts: all become: yes - gather_facts: True + gather_facts: yes vars_files: - config.yml roles: - - { role: rvm_io.rvm1-ruby, tags: ruby, become: True } + - { role: rvm_io.ruby, tags: ruby, become: yes } + - { role: rvm_io.ruby.patch, tags: ruby, become: yes } - { role: easyredmine, become: no } tasks: diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..6d61266 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ + +- src: rvm_io.ruby \ No newline at end of file diff --git a/roles/easyredmine/files/rvm_install b/roles/easyredmine/files/rvm_install deleted file mode 100644 index 491801b..0000000 --- a/roles/easyredmine/files/rvm_install +++ /dev/null @@ -1,888 +0,0 @@ -#!/usr/bin/env bash - -# RVM install script from https://get.rvm.io/ - -shopt -s extglob -set -o errtrace -set -o errexit - -rvm_install_initialize() -{ - DEFAULT_SOURCES=(github.com/rvm/rvm bitbucket.org/mpapis/rvm) - - BASH_MIN_VERSION="3.2.25" - if - [[ -n "${BASH_VERSION:-}" && - "$(\printf "%b" "${BASH_VERSION:-}\n${BASH_MIN_VERSION}\n" | LC_ALL=C \sort -t"." -k1,1n -k2,2n -k3,3n | \head -n1)" != "${BASH_MIN_VERSION}" - ]] - then - echo "BASH ${BASH_MIN_VERSION} required (you have $BASH_VERSION)" - exit 1 - fi - - export HOME PS4 - export rvm_trace_flag rvm_debug_flag rvm_user_install_flag rvm_ignore_rvmrc rvm_prefix rvm_path - - PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > " -} - -log() { printf "%b\n" "$*"; } -debug(){ [[ ${rvm_debug_flag:-0} -eq 0 ]] || printf "%b\n" "Running($#): $*"; } -fail() { log "\nERROR: $*\n" ; exit 1 ; } - -rvm_install_commands_setup() -{ - \which which >/dev/null 2>&1 || fail "Could not find 'which' command, make sure it's available first before continuing installation." - if - [[ -z "${rvm_tar_command:-}" ]] && builtin command -v gtar >/dev/null - then - rvm_tar_command=gtar - elif - ${rvm_tar_command:-tar} --help 2>&1 | GREP_OPTIONS="" \grep -- --strip-components >/dev/null - then - rvm_tar_command="${rvm_tar_command:-tar}" - else - case "$(uname)" in - (OpenBSD) - log "Trying to install GNU version of tar, might require sudo password" - if (( UID )) - then sudo pkg_add -z gtar-1 - else pkg_add -z gtar-1 - fi - rvm_tar_command=gtar - ;; - (Darwin|FreeBSD|DragonFly) # it's not possible to autodetect on OSX, the help/man does not mention all flags - rvm_tar_command=tar - ;; - (SunOS) - case "$(uname -r)" in - (5.10) - log "Trying to install GNU version of tar, might require sudo password" - if (( UID )) - then - if \which sudo >/dev/null 2>&1 - then sudo_10=sudo - elif \which /opt/csw/bin/sudo >/dev/null 2>&1 - then sudo_10=/opt/csw/bin/sudo - else fail "sudo is required but not found. You may install sudo from OpenCSW repository (http://opencsw.org/about)" - fi - pkginfo -q CSWpkgutil || $sudo_10 pkgadd -a $rvm_path/config/solaris/noask -d http://get.opencsw.org/now CSWpkgutil - sudo /opt/csw/bin/pkgutil -iy CSWgtar -t http://mirror.opencsw.org/opencsw/unstable - else - pkginfo -q CSWpkgutil || pkgadd -a $rvm_path/config/solaris/noask -d http://get.opencsw.org/now CSWpkgutil - /opt/csw/bin/pkgutil -iy CSWgtar -t http://mirror.opencsw.org/opencsw/unstable - fi - rvm_tar_command=/opt/csw/bin/gtar - ;; - (*) - rvm_tar_command=tar - ;; - esac - esac - builtin command -v ${rvm_tar_command:-gtar} >/dev/null || - fail "Could not find GNU compatible version of 'tar' command, make sure it's available first before continuing installation." - fi - if - [[ " ${rvm_tar_options:-} " != *" --no-same-owner "* ]] && - $rvm_tar_command --help 2>&1 | GREP_OPTIONS="" \grep -- --no-same-owner >/dev/null - then - rvm_tar_options="${rvm_tar_options:-}${rvm_tar_options:+ }--no-same-owner" - fi -} - -usage() -{ - printf "%b" " - -Usage - - rvm-installer [options] [action] - -Options - - [[--]version] - - The version or tag to install. Valid values are: - - latest - The latest tagged version. - latest-minor - The latest minor version of the current major version. - latest- - The latest minor version of version x. - latest-. - The latest patch version of version x.y. - .. - Major version x, minor version y and patch z. - - [--]branch - - The name of the branch from which RVM is installed. This option can be used - with the following formats for : - - / - - If account is wayneeseguin or mpapis, installs from one of the following: - - https://github.com/rvm/rvm/archive/master.tar.gz - https://bitbucket.org/mpapis/rvm/get/master.tar.gz - - Otherwise, installs from: - - https://github.com//rvm/archive/master.tar.gz - - / - - If account is wayneeseguin or mpapis, installs from one of the following: - - https://github.com/rvm/rvm/archive/.tar.gz - https://bitbucket.org/mpapis/rvm/get/.tar.gz - - Otherwise, installs from: - - https://github.com//rvm/archive/.tar.gz - - [/] - - Installs the branch from one of the following: - - https://github.com/rvm/rvm/archive/.tar.gz - https://bitbucket.org/mpapis/rvm/get/.tar.gz - - [--]source - - Defines the repository from which RVM is retrieved and installed in the format: - - // - - Where: - - - Is bitbucket.org, github.com or a github enterprise site serving - an RVM repository. - - Is the user account in which the RVM repository resides. - - Is the name of the RVM repository. - - Note that when using the [--]source option, one should only use the [/]branch format - with the [--]branch option. Failure to do so will result in undefined behavior. - - --trace - - Provides debug logging for the installation script. -Actions - - master - Installs RVM from the master branch at rvm/rvm on github or mpapis/rvm - on bitbucket.org. - stable - Installs RVM from the stable branch a rvm/rvm on github or mpapis/rvm - on bitbucket.org. - help - Displays this output. - -" -} - -## duplication marker 32fosjfjsznkjneuera48jae -__rvm_curl_output_control() -{ - if - (( ${rvm_quiet_curl_flag:-0} == 1 )) - then - __flags+=( "--silent" "--show-error" ) - elif - [[ " $*" == *" -s"* || " $*" == *" --silent"* ]] - then - # make sure --show-error is used with --silent - [[ " $*" == *" -S"* || " $*" == *" -sS"* || " $*" == *" --show-error"* ]] || - { - __flags+=( "--show-error" ) - } - fi -} - -## duplication marker 32fosjfjsznkjneuera48jae -# -S is automatically added to -s -__rvm_curl() -( - __rvm_which curl >/dev/null || - { - rvm_error "RVM requires 'curl'. Install 'curl' first and try again." - return 200 - } - - typeset -a __flags - __flags=( --fail --location --max-redirs 10 ) - - [[ "$*" == *"--max-time"* ]] || - [[ "$*" == *"--connect-timeout"* ]] || - __flags+=( --connect-timeout 30 --retry-delay 2 --retry 3 ) - - if [[ -n "${rvm_proxy:-}" ]] - then __flags+=( --proxy "${rvm_proxy:-}" ) - fi - - __rvm_curl_output_control - - unset curl - __rvm_debug_command \curl "${__flags[@]}" "$@" || return $? -) - -rvm_error() { printf "ERROR: %b\n" "$*"; } -__rvm_which(){ which "$@" || return $?; true; } -__rvm_debug_command() -{ - debug "Running($#): $*" - "$@" || return $? - true -} -rvm_is_a_shell_function() -{ - [[ -t 0 && -t 1 ]] || return $? - return ${rvm_is_not_a_shell_function:-0} -} - -# Searches the tags for the highest available version matching a given pattern. -# fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) 1.10. -> 1.10.3 -# fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) 1.10. -> 1.10.3 -# fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) 1. -> 1.11.0 -# fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) "" -> 2.0.1 -fetch_version() -{ - typeset _account _domain _pattern _repo _sources _values _version - _sources=(${!1}) - _pattern=$2 - for _source in "${_sources[@]}" - do - IFS='/' read -r _domain _account _repo <<< "${_source}" - _version="$( - fetch_versions ${_domain} ${_account} ${_repo} | - GREP_OPTIONS="" \grep "^${_pattern:-}" | tail -n 1 - )" - if - [[ -n ${_version} ]] - then - echo "${_version}" - return 0 - fi - done -} - -# Returns a sorted list of all version tags from a repository -fetch_versions() -{ - typeset _account _domain _repo _url - _domain=$1 - _account=$2 - _repo=$3 - case ${_domain} in - (bitbucket.org) - _url=https://${_domain}/api/1.0/repositories/${_account}/${_repo}/branches-tags - ;; - (github.com) - _url=https://api.${_domain}/repos/${_account}/${_repo}/tags - ;; - - (*) - _url=https://${_domain}/api/v3/repos/${_account}/${_repo}/tags - ;; - esac - __rvm_curl -s ${_url} | - \awk -v RS=',' -v FS='"' '$2=="name"{print $4}' | - sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -} - -install_release() -{ - typeset _source _sources _url _version _verify_pgp - _sources=(${!1}) - _version=$2 - debug "Downloading RVM version ${_version}" - for _source in "${_sources[@]}" - do - case ${_source} in - (bitbucket.org*) - _url="https://${_source}/get/${_version}.tar.gz" - _verify_pgp="https://${_source}/downloads/${_version}.tar.gz.asc" - ;; - (*) - _url="https://${_source}/archive/${_version}.tar.gz" - _verify_pgp="https://${_source}/releases/download/${_version}/${_version}.tar.gz.asc" - ;; - esac - get_and_unpack "${_url}" "rvm-${_version}.tgz" "$_verify_pgp" && return - done - return $? -} - -install_head() -{ - typeset _branch _source _sources _url - _sources=(${!1}) - _branch=$2 - debug "Selected RVM branch ${_branch}" - for _source in "${_sources[@]}" - do - case ${_source} in - (bitbucket.org*) - _url=https://${_source}/get/${_branch}.tar.gz - ;; - (*) - _url=https://${_source}/archive/${_branch}.tar.gz - ;; - esac - get_and_unpack "${_url}" "rvm-${_branch//\//_}.tgz" && return - done - return $? -} - -# duplication marker dfkjdjngdfjngjcszncv -# Drop in cd which _doesn't_ respect cdpath -__rvm_cd() -{ - typeset old_cdpath ret - ret=0 - old_cdpath="${CDPATH}" - CDPATH="." - chpwd_functions="" builtin cd "$@" || ret=$? - CDPATH="${old_cdpath}" - return $ret -} - -get_package() -{ - typeset _url _file - _url="$1" - _file="$2" - log "Downloading ${_url}" - __rvm_curl -sS ${_url} -o ${rvm_archives_path}/${_file} || - { - _return=$? - case $_return in - # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn - (60) - log " -Could not download '${_url}', you can read more about it here: -https://rvm.io/support/fixing-broken-ssl-certificates/ -To continue in insecure mode run 'echo insecure >> ~/.curlrc'. -" - ;; - # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn - (77) - log " -It looks like you have old certificates, you can read more about it here: -https://rvm.io/support/fixing-broken-ssl-certificates/ -" - ;; - # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn - (141) - log " -Curl returned 141 - it is result of a segfault which means it's Curls fault. -Try again and if it crashes more than a couple of times you either need to -reinstall Curl or consult with your distribution manual and contact support. -" - ;; - (*) - log " -Could not download '${_url}'. - curl returned status '$_return'. -" - ;; - esac - return $_return - } -} - -# duplication marker flnglfdjkngjndkfjhsbdjgfghdsgfklgg -rvm_install_gpg_setup() -{ - export rvm_gpg_command - { - rvm_gpg_command="$( \which gpg2 2>/dev/null )" && - [[ ${rvm_gpg_command} != "/cygdrive/"* ]] - } || - rvm_gpg_command="$( \which gpg 2>/dev/null )" || - rvm_gpg_command="" - debug "Detected GPG program: '$rvm_gpg_command'" - [[ -n "$rvm_gpg_command" ]] || return $? -} - -# duplication marker rdjgndfnghdfnhgfdhbghdbfhgbfdhbn -verify_package_pgp() -{ - if - "${rvm_gpg_command}" --verify "$2" "$1" - then - log "GPG verified '$1'" - else - typeset _ret=$? - log "\ -Warning, RVM 1.26.0 introduces signed releases and \ -automated check of signatures when GPG software found. -Assuming you trust Michal Papis import the mpapis public \ -key (downloading the signatures). - -GPG signature verification failed for '$1' - '$3'! -try downloading the signatures: - - ${SUDO_USER:+sudo }${rvm_gpg_command##*/} --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 - -or if it fails: - - command curl -sSL https://rvm.io/mpapis.asc | ${SUDO_USER:+sudo }${rvm_gpg_command##*/} --import - - -the key can be compared with: - - https://rvm.io/mpapis.asc - https://keybase.io/mpapis -" - exit $_ret - fi -} - -verify_pgp() -{ - [[ -n "${1:-}" ]] || - { - debug "No PGP url given, skipping." - return 0 - } - - get_package "$1" "$2.asc" || - { - debug "PGP url given but does not exist: '$1'" - return 0 - } - - rvm_install_gpg_setup || - { - log "Found PGP signature at: '$1', -but no GPG software exists to validate it, skipping." - return 0 - } - - verify_package_pgp "${rvm_archives_path}/$2" "${rvm_archives_path}/$2.asc" "$1" -} - -get_and_unpack() -{ - typeset _url _file _patern _return _verify_pgp - _url="$1" - _file="$2" - _verify_pgp="$3" - - get_package "$_url" "$_file" || return $? - verify_pgp "$_verify_pgp" "$_file" || return $? - - [[ -d "${rvm_src_path}/rvm" ]] || \mkdir -p "${rvm_src_path}/rvm" - __rvm_cd "${rvm_src_path}/rvm" || - { - _return=$? - log "Could not change directory '${rvm_src_path}/rvm'." - return $_return - } - - rm -rf ${rvm_src_path}/rvm/* - __rvm_debug_command $rvm_tar_command xzf ${rvm_archives_path}/${_file} ${rvm_tar_options:-} --strip-components 1 || - { - _return=$? - log "Could not extract RVM sources." - return $_return - } -} - -rvm_install_default_settings() -{ - # Tracing, if asked for. - if - [[ "$*" == *--trace* ]] || (( ${rvm_trace_flag:-0} > 0 )) - then - set -o xtrace - rvm_trace_flag=1 - fi - - # Variable initialization, remove trailing slashes if they exist on HOME - true \ - ${rvm_trace_flag:=0} ${rvm_debug_flag:=0}\ - ${rvm_ignore_rvmrc:=0} HOME="${HOME%%+(\/)}" - - if - (( rvm_ignore_rvmrc == 0 )) - then - for rvmrc in /etc/rvmrc "$HOME/.rvmrc" - do - if - [[ -s "$rvmrc" ]] - then - if - GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1 - then - printf "%b" " - Error: $rvmrc is for rvm settings only. - rvm CLI may NOT be called from within $rvmrc. - Skipping the loading of $rvmrc - " - exit 1 - else - source "$rvmrc" - fi - fi - done - fi - - if - [[ -z "${rvm_path:-}" ]] - then - if - (( UID == 0 )) - then - rvm_user_install_flag=0 - rvm_prefix="/usr/local" - rvm_path="${rvm_prefix}/rvm" - else - rvm_user_install_flag=1 - rvm_prefix="$HOME" - rvm_path="${rvm_prefix}/.rvm" - fi - fi - if [[ -z "${rvm_prefix}" ]] - then rvm_prefix=$( dirname $rvm_path ) - fi - - # duplication marker kkdfkgnjfndgjkndfjkgnkfjdgn - [[ -n "${rvm_user_install_flag:-}" ]] || - case "$rvm_path" in - (/usr/local/rvm) rvm_user_install_flag=0 ;; - ($HOME/*|/${USER// /_}*) rvm_user_install_flag=1 ;; - (*) rvm_user_install_flag=0 ;; - esac -} - -rvm_install_parse_params() -{ - install_rubies=() - install_gems=() - flags=( ./scripts/install ) - forwarded_flags=() - while - (( $# > 0 )) - do - token="$1" - shift - case "$token" in - - (--trace) - set -o xtrace - rvm_trace_flag=1 - flags=( -x "${flags[@]}" "$token" ) - forwarded_flags+=( "$token" ) - ;; - - (--debug|--quiet-curl) - flags+=( "$token" ) - forwarded_flags+=( "$token" ) - token=${token#--} - token=${token//-/_} - export "rvm_${token}_flag"=1 - printf "%b" "Turning on ${token/_/ } mode.\n" - ;; - - (--path) - if [[ -n "${1:-}" ]] - then - rvm_path="$1" - shift - else - fail "--path must be followed by a path." - fi - ;; - - (--branch|branch) # Install RVM from a given branch - if [[ -n "${1:-}" ]] - then - case "$1" in - (/*) - branch=${1#/} - ;; - (*/) - branch=master - if [[ "${1%/}" -ne wayneeseguin ]] && [[ "${1%/}" -ne mpapis ]] - then sources=(github.com/${1%/}/rvm) - fi - ;; - (*/*) - branch=${1#*/} - if [[ "${1%%/*}" -ne wayneeseguin ]] && [[ "${1%%/*}" -ne mpapis ]] - then sources=(github.com/${1%%/*}/rvm) - fi - ;; - (*) - branch="$1" - ;; - esac - shift - else - fail "--branch must be followed by a branchname." - fi - ;; - - (--source|source) - if [[ -n "${1:-}" ]] - then - if [[ "$1" = */*/* ]] - then - sources=($1) - shift - else - fail "--source must be in the format //." - fi - else - fail "--source must be followed by a source." - fi - ;; - - (--user-install|--ignore-dotfiles) - token=${token#--} - token=${token//-/_} - export "rvm_${token}_flag"=1 - printf "%b" "Turning on ${token/_/ } mode.\n" - ;; - - (--auto-dotfiles) - flags+=( "$token" ) - export "rvm_auto_dotfiles_flag"=1 - printf "%b" "Turning on auto dotfiles mode.\n" - ;; - - (--auto) - export "rvm_auto_dotfiles_flag"=1 - printf "%b" "Warning, --auto is deprecated in favor of --auto-dotfiles.\n" - ;; - - (--verify-downloads) - if [[ -n "${1:-}" ]] - then - export rvm_verify_downloads_flag="$1" - forwarded_flags+=( "$token" "$1" ) - shift - else - fail "--verify-downloads must be followed by level(0|1|2)." - fi - ;; - - (--autolibs=*) - flags+=( "$token" ) - export rvm_autolibs_flag="${token#--autolibs=}" - forwarded_flags+=( "$token" ) - ;; - - (--without-gems=*|--with-gems=*|--with-default-gems=*) - flags+=( "$token" ) - value="${token#*=}" - token="${token%%=*}" - token="${token#--}" - token="${token//-/_}" - export "rvm_${token}"="${value}" - printf "%b" "Installing RVM ${token/_/ }: ${value}.\n" - ;; - - (--version|version) - version="$1" - shift - ;; - - (head|master) - version="head" - branch="master" - ;; - - (stable) - version="latest" - ;; - - (latest|latest-*|+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) - version="$token" - ;; - - (--ruby) - install_rubies+=( ruby ) - ;; - - (--ruby=*) - token=${token#--ruby=} - install_rubies+=( ${token//,/ } ) - ;; - - (--rails) - install_gems+=( rails ) - ;; - - (--gems=*) - token=${token#--gems=} - install_gems+=( ${token//,/ } ) - ;; - - (--add-to-rvm-group) - export rvm_add_users_to_rvm_group="$1" - shift - ;; - - (help|usage) - usage - exit 0 - ;; - - (*) - usage - exit 1 - ;; - - esac - done - - if (( ${#install_gems[@]} > 0 && ${#install_rubies[@]} == 0 )) - then install_rubies=( ruby ) - fi - - true "${version:=head}" - true "${branch:=master}" - - if [[ -z "${sources[@]}" ]] - then sources=("${DEFAULT_SOURCES[@]}") - fi - - rvm_src_path="$rvm_path/src" - rvm_archives_path="$rvm_path/archives" - rvm_releases_url="https://rvm.io/releases" -} - -rvm_install_validate_rvm_path() -{ - case "$rvm_path" in - (*[[:space:]]*) - printf "%b" " -It looks you are one of the happy *space* users(in home dir name), -RVM is not yet fully ready for it, use this trick to fix it: - - sudo mkdir -p /${USER// /_}.rvm - sudo chown -R \"$USER:\" /${USER// /_}.rvm - echo \"export rvm_path=/${USER// /_}.rvm\" >> \"$HOME/.rvmrc\" - -and start installing again. - -" - exit 2 - ;; - (/usr/share/ruby-rvm) - printf "%b" " -It looks you are one of the happy Ubuntu users, -RVM packaged by Ubuntu is old and broken, -follow this link for details how to fix: - - http://stackoverflow.com/a/9056395/497756 - -" - [[ "${rvm_uses_broken_ubuntu_path:-no}" == "yes" ]] || exit 3 - ;; - esac - - if [[ "$rvm_path" != "/"* ]] - then fail "The rvm install path must be fully qualified. Tried $rvm_path" - fi -} - -rvm_install_select_and_get_version() -{ - typeset _version_release - - for dir in "$rvm_src_path" "$rvm_archives_path" - do - [[ -d "$dir" ]] || mkdir -p "$dir" - done - - _version_release="${version}" - case "${version}" in - (head) - _version_release="${branch}" - install_head sources[@] ${branch:-master} || exit $? - ;; - - (latest) - install_release sources[@] $(fetch_version sources[@]) || exit $? - ;; - - (latest-minor) - version="$(\cat "$rvm_path/VERSION")" - install_release sources[@] $(fetch_version sources[@] ${version%.*}) || exit $? - ;; - - (latest-*) - install_release sources[@] $(fetch_version sources[@] ${version#latest-}) || exit $? - ;; - - (+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) # x.y.z - install_release sources[@] ${version} || exit $? - ;; - - (*) - fail "Something went wrong, unrecognized version '$version'" - ;; - esac - echo "${_version_release}" > "$rvm_path/RELEASE" -} - -rvm_install_main() -{ - [[ -f ./scripts/install ]] || - { - log "'./scripts/install' can not be found for installation, something went wrong, it usally means your 'tar' is broken, please report it here: https://github.com/rvm/rvm/issues" - return 127 - } - - # required flag - path to install - flags+=( --path "$rvm_path" ) - \command bash "${flags[@]}" -} - -rvm_install_ruby_and_gems() -( - if - (( ${#install_rubies[@]} > 0 )) - then - source ${rvm_scripts_path:-${rvm_path}/scripts}/rvm - source ${rvm_scripts_path:-${rvm_path}/scripts}/version - __rvm_version - - for _ruby in ${install_rubies[@]} - do command rvm "${forwarded_flags[@]}" install ${_ruby} -j 2 - done - # set the first one as default, skip rest - for _ruby in ${install_rubies[@]} - do - rvm "${forwarded_flags[@]}" alias create default ${_ruby} - break - done - - for _gem in ${install_gems[@]} - do rvm "${forwarded_flags[@]}" all do gem install ${_gem} - done - - printf "%b" " - * To start using RVM you need to run \`source $rvm_path/scripts/rvm\` - in all your open shell windows, in rare cases you need to reopen all shell windows. -" - - if - [[ "${install_gems[*]}" == *"rails"* ]] - then - printf "%b" " - * To start using rails you need to run \`rails new \`. -" - fi - fi -) - -rvm_install() -{ - rvm_install_initialize - rvm_install_commands_setup - rvm_install_default_settings - rvm_install_parse_params "$@" - rvm_install_validate_rvm_path - rvm_install_select_and_get_version - rvm_install_main - rvm_install_ruby_and_gems -} - -rvm_install "$@" diff --git a/roles/easyredmine/tasks/main.yml b/roles/easyredmine/tasks/main.yml index f0de5a4..accc89d 100644 --- a/roles/easyredmine/tasks/main.yml +++ b/roles/easyredmine/tasks/main.yml @@ -1,21 +1,21 @@ --- -- include: system.yml +- import_tasks: system.yml tags: system -- include: firewall.yml +- import_tasks: firewall.yml tags: firewall -- include: database.yml +- import_tasks: database.yml tags: database when: do_database_management == True -- include: redmine.yml +- import_tasks: redmine.yml tags: redmine -- include: nginx.yml +- import_tasks: nginx.yml tags: nginx -- include: attachments_storage.yml +- import_tasks: attachments_storage.yml tags: attachments_storage when: is_production_vm == True diff --git a/roles/easyredmine/tasks/redmine.yml b/roles/easyredmine/tasks/redmine.yml index fbc0775..082b04a 100644 --- a/roles/easyredmine/tasks/redmine.yml +++ b/roles/easyredmine/tasks/redmine.yml @@ -14,14 +14,16 @@ - subversion # Repository integration - git # Repository integration -- name: install bundler, redmine-installer gems - gem: name='{{ item }}' +# these gems are not user_install but the RVM path is for local redmine +# user so installations are localized to rvm1_install_path (e.g. ~/.rvm) +- name: install redmine-installer gem in selected RVM environment + gem: name='{{ item.name }}' user_install=no - executable=/usr/local/bin/gem # RVM's version - become: yes + version='{{ item.version }}' + executable='{{ rvm1_install_path }}/wrappers/default/gem' # RVM's version + become: no with_items: - - bundler - - redmine-installer + - { name: redmine-installer, version: '' } - name: installer package is present? stat: path='{{ installer_package_path }}' @@ -58,7 +60,7 @@ register: mk_redmine_root_dir - name: run redmine installer - shell: 'source ~/.bash_profile && {{ _redmine_install_wrapper }} > ~/install.log' + shell: 'source ~/.bash_profile && {{ _redmine_install_wrapper }} > ~/install.log 2>&1' when: mk_redmine_root_dir|changed and do_redmine_installer == True register: installer_run become: no @@ -124,7 +126,7 @@ - name: adding run_tasks crontab cron: name="redmine tasks" minute="*/15" - job='cd {{ redmine_root_dir }} && /usr/local/bin/bundle exec rake easyproject:scheduler:run_tasks RAILS_ENV=production > /dev/null' + job='cd {{ redmine_root_dir }} && {{ rvm1_install_path }}/wrappers/default/bundle exec rake easyproject:scheduler:run_tasks RAILS_ENV=production > /dev/null' user='{{ redmine_owner }}' become: yes diff --git a/roles/easyredmine/tasks/system.yml b/roles/easyredmine/tasks/system.yml index ebe55e0..107ee44 100644 --- a/roles/easyredmine/tasks/system.yml +++ b/roles/easyredmine/tasks/system.yml @@ -1,5 +1,5 @@ -- include: addswap.yml +- import_tasks: addswap.yml - name: install system tools yum: name='{{ item }}' diff --git a/roles/easyredmine/templates/install_wrapper.j2 b/roles/easyredmine/templates/install_wrapper.j2 index c0e3b15..82b3cf4 100755 --- a/roles/easyredmine/templates/install_wrapper.j2 +++ b/roles/easyredmine/templates/install_wrapper.j2 @@ -4,20 +4,23 @@ # non-interactive installs by Ansible set timeout -1 +set KEYUP "\x1B\[A" +set KEYDOWN "\x1B\[B" spawn redmine install {{ remote_scratch_path }}/{{ installer_package_name }} -expect -re {[\r\n]+Path for redmine_root} +expect -re {[\r\n]+Path .+ redmine[\s_]root} send "{{ redmine_root_dir }}\r" -# Database Configuration -expect -re {[\r\n]+> } -send "1\r"; # MySQL +# Database Configuration (arrow-key navigation menu) +expect -re {What database do you want use} +send "\r"; # MySQL -expect -re {[\r\n]+Database: } +# no [\n\r] follows the arrow-key navigation menu +expect -re {[\r\n]*Database: } send "{{ redmine_db_name }}\r" -expect -re {[\r\n]+Host } +expect -re {[\r\n]+Host: } send "{{ redmine_db_host }}\r" expect -re {[\r\n]+Username:} @@ -32,49 +35,33 @@ send "{{ redmine_db_encoding }}\r" expect -re {[\r\n]+Port} send "{{ redmine_db_port }}\r" -# Email sending configuration -expect -re {[\r\n]+> } -send "3\r"; # SMTP from scratch +# Email sending configuration (arrow-key navigation menu) +expect -re {Which service to use for email sending} +send "${KEYUP}${KEYUP}${KEYUP}\r"; # SMTP from scratch -expect -re {[\r\n]+Address:} -send "{{ smtp_address }}\r" - -expect -re {[\r\n]+Port } -send "{{ smtp_port }}\r" - -expect -re {[\r\n]+Domain: } -send "{{ smtp_domain }}\r" - -expect -re {[\r\n]+User_name:} +# no [\n\r] follows the arrow-key navigation menu +expect -re {[\r\n]*Username:} send "{{ smtp_username }}\r" expect -re {[\r\n]+Password:} send "{{ smtp_password }}\r" +expect -re {[\r\n]+Address:} +send "{{ smtp_address }}\r" + +expect -re {[\r\n]+Port:} +send "{{ smtp_port }}\r" + +expect -re {[\r\n]+Domain: } +send "{{ smtp_domain }}\r" + expect -re {[\r\n]+Authentication:} send "{{ smtp_authentication }}\r" -expect -re {[\r\n]+Enable_starttls_auto:} -send "{{ smtp_enable_starttls }}\r" +expect -re {[\r\n]+Openssl verify mode:} +send "{{ smtp_openssl_verify_mode }}\r" -expect { - -re {[\r\n]+-- } {exp_continue} - -re {[\r\n]+Do you want repeat this command?} {send "yes\n"; exp_continue} - -re {[\r\n]+Done.} -} +expect -re {[\r\n]+Enable starttls} +send "Y\r" -# # Email sending configuration -# expect -re {[\r\n]+> } -# send "1\r"; # GMail -# -# expect -re {[\r\n]+User_name:} -# send "{{ smtp_username }}\r" -# -# expect -re {[\r\n]+Password:} -# send "{{ smtp_password }}\r" - -# What web-server do you want -expect -re {[\r\n]+> } -send "4\r"; # Passenger (nginx) - -interact +expect "Redmine was installed" diff --git a/roles/easyredmine/templates/passenger.conf.j2 b/roles/easyredmine/templates/passenger.conf.j2 index 2fa62cf..87b29ea 100644 --- a/roles/easyredmine/templates/passenger.conf.j2 +++ b/roles/easyredmine/templates/passenger.conf.j2 @@ -1,5 +1,5 @@ passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini; -passenger_ruby /usr/local/rvm/gems/ruby-{{ ruby_version }}/wrappers/ruby; +passenger_ruby {{ rvm1_install_path }}/gems/ruby-{{ ruby_version }}/wrappers/ruby; passenger_instance_registry_dir /var/run/passenger-instreg; passenger_show_version_in_header off; diff --git a/roles/rvm_io.ruby.patch/README.md b/roles/rvm_io.ruby.patch/README.md new file mode 100644 index 0000000..5413b37 --- /dev/null +++ b/roles/rvm_io.ruby.patch/README.md @@ -0,0 +1,23 @@ +rvm_io.ruby.patch +========= + +Patches to [rvm1-ansible](https://github.com/rvm/rvm1-ansible) role. + +- install `/etc/profile.d/rvm.sh` - https://github.com/rvm/rvm1-ansible/issues/135 + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + +``` + - hosts: servers + roles: + - { role: rvm_io.ruby.patch } +``` + +License +------- + +BSD + diff --git a/roles/rvm_io.ruby.patch/defaults/main.yml b/roles/rvm_io.ruby.patch/defaults/main.yml new file mode 100644 index 0000000..5ae59a0 --- /dev/null +++ b/roles/rvm_io.ruby.patch/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for rvm_io.ruby.patch \ No newline at end of file diff --git a/roles/rvm_io.ruby.patch/files/rvm.sh b/roles/rvm_io.ruby.patch/files/rvm.sh new file mode 100644 index 0000000..acdb7d0 --- /dev/null +++ b/roles/rvm_io.ruby.patch/files/rvm.sh @@ -0,0 +1,47 @@ +# +# RVM profile +# +# /etc/profile.d/rvm.sh # sh extension required for loading. +# + +if + [ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] && + test "`\command \ps -p $$ -o ucomm=`" != dash && + test "`\command \ps -p $$ -o ucomm=`" != sh +then + [[ -n "${rvm_stored_umask:-}" ]] || export rvm_stored_umask=$(umask) + # Load user rvmrc configurations, if exist + for file in "/etc/rvmrc" "$HOME/.rvmrc" + do + [[ -s "$file" ]] && source $file + done + if + [[ -n "${rvm_prefix:-}" ]] && + [[ -s "${rvm_prefix}/.rvmrc" ]] && + [[ ! "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]] + then + source "${rvm_prefix}/.rvmrc" + fi + + # Load RVM if it is installed, try user then root install. + if + [[ -s "$rvm_path/scripts/rvm" ]] + then + source "$rvm_path/scripts/rvm" + elif + [[ -s "$HOME/.rvm/scripts/rvm" ]] + then + true ${rvm_path:="$HOME/.rvm"} + source "$HOME/.rvm/scripts/rvm" + elif + [[ -s "/usr/local/rvm/scripts/rvm" ]] + then + true ${rvm_path:="/usr/local/rvm"} + source "/usr/local/rvm/scripts/rvm" + fi + + # Add $rvm_bin_path to $PATH if necessary + if [[ -n "${rvm_bin_path}" && ! ":${PATH}:" == *":${rvm_bin_path}:"* ]] + then PATH="${PATH}:${rvm_bin_path}" + fi +fi diff --git a/roles/rvm_io.ruby.patch/handlers/main.yml b/roles/rvm_io.ruby.patch/handlers/main.yml new file mode 100644 index 0000000..e21626d --- /dev/null +++ b/roles/rvm_io.ruby.patch/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for rvm_io.ruby.patch \ No newline at end of file diff --git a/roles/rvm_io.ruby.patch/meta/main.yml b/roles/rvm_io.ruby.patch/meta/main.yml new file mode 100644 index 0000000..7223799 --- /dev/null +++ b/roles/rvm_io.ruby.patch/meta/main.yml @@ -0,0 +1,57 @@ +galaxy_info: + author: your name + description: your description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + + min_ansible_version: 1.2 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If Travis integration is configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # platforms is a list of platforms, and each platform has a name and a list of versions. + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. \ No newline at end of file diff --git a/roles/rvm_io.ruby.patch/tasks/main.yml b/roles/rvm_io.ruby.patch/tasks/main.yml new file mode 100644 index 0000000..ae1e1d6 --- /dev/null +++ b/roles/rvm_io.ruby.patch/tasks/main.yml @@ -0,0 +1,9 @@ +--- +# tasks file for rvm_io.ruby.patch + +- copy: + src: rvm.sh + dest: /etc/profile.d/rvm.sh + owner: root + group: root + mode: 0644 diff --git a/roles/rvm_io.ruby.patch/tests/inventory b/roles/rvm_io.ruby.patch/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/rvm_io.ruby.patch/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/rvm_io.ruby.patch/tests/test.yml b/roles/rvm_io.ruby.patch/tests/test.yml new file mode 100644 index 0000000..5164132 --- /dev/null +++ b/roles/rvm_io.ruby.patch/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - rvm_io.ruby.patch \ No newline at end of file diff --git a/roles/rvm_io.ruby.patch/vars/main.yml b/roles/rvm_io.ruby.patch/vars/main.yml new file mode 100644 index 0000000..e9ac7a7 --- /dev/null +++ b/roles/rvm_io.ruby.patch/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for rvm_io.ruby.patch \ No newline at end of file