diff options
| author | Suren A. Chilingaryan <csa@suren.me> | 2017-04-01 04:53:28 +0200 | 
|---|---|---|
| committer | Suren A. Chilingaryan <csa@suren.me> | 2017-04-01 04:53:28 +0200 | 
| commit | e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86 (patch) | |
| tree | 444778102e4f73b83ef9462235b7f614b004b264 /opts.sh | |
| download | ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.gz ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.bz2 ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.xz ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.zip  | |
Initial import
Diffstat (limited to 'opts.sh')
| -rw-r--r-- | opts.sh | 117 | 
1 files changed, 117 insertions, 0 deletions
@@ -0,0 +1,117 @@ +#!/bin/bash + +inventory="inventories/testing.erb" +group="nodes" + +usage() {  +    cat << END +Usage: $0 [-i inventory] [-g group] <action> [extra-args-to-ansible] + +Parameters: +    inventory           - specifies name of inventory to use (testing, staging, production) +    group               - specifies node group to use if role is considered in action +     +Actions: +    -h                  - show help and exit + + Initial system installation +    all                 - full install, all the following steps in sequence: +    local               - configure local ssh client +    prepare             - perform all required pre-configuration before setting openshift +    openshift           - setup OpenShift cluster +    configure           - configures OpenShift cluster (Storage, Users, OpenVPN tunnels) +    projects            - installs configuration files and OpenShift resources for KaaS and other configured projects + + Scaling the cluster +    nodes               - complete action: prepares the nodes, scales up the cluster, and reconfigures storage +    prepare             - prepares the new nodes +    openshift-nodes     - scales OpenShift cluster (master scallability is not checked) +    configure           - Configures new nodes (Storage, Users, OpenVPN tunnels) +  + Configuration of new resources, etc. +    users               - configure user roles & passwords +    storage             - reconfigure Gluster and OpenShift volumes +    projects            - reconfigures OpenShift resources if necessary +    vpn                 - reconfigure VPN tunnels +    certs               - re-generate OpenShift x509 certificates +    check               - check current setup and report if any maintenace should be peformed +    setup <type>        - executes specific configuration task from ands-openshift +                          Tasks: hostnames, users, ssh, storage, heketi + + Custom actions +    playbook.yml        - execute the specified playbook +    role                - generates temporary playbook and executes the role +     +END +    echo +    [ -n "$1" ] && echo "Error: $1" +    exit +} + +apply() { +    export ANSIBLE_HOST_KEY_CHECKING=False + +    [ -n "$1" ] || usage "No action specified" + +    action=$1 +    shift 1 + +    if [ -f "$action" ]; then +        playbook=$action +    elif [ -d "roles/$action" ]; then +        role=$action +    else +        usage "Role '$action' is not existing" +    fi + +    clean="" +    if [ -z "$playbook" ]; then +        echo "Executing a specific role '$role' on '$group'" +        playbook="playbooks/tmp_role.yml" +        clean="playbooks/tmp_role.*" +     +        cat <<END  > playbooks/tmp_role.yml +- name: Common setup procedures +  hosts: $group +  remote_user: root +  roles: +    - ands_facts +    - $role +END +    fi +     +    ansible-playbook  --vault-password-file .vault-pass -i $inventory $playbook $@ +     +    if [ -n "$clean" ]; then +        rm -rf "$clean" +    fi + +    return $? +} + +while getopts ":i:g:h" o; do +    case "${o}" in +        h) +            usage +            ;; +        i) +            inventory=${OPTARG} +            [ -f $inventory ] || [ -f inventories/${inventory}.erb ] || usage "Specified inventory '$inventory' is not found" +            [ -f $inventory ] || inventory=inventories/${inventory}.erb  +            ;; +        g) +            group=${OPTARG} +            ;; +        \?) +            usage "Invalid option: -$OPTARG" +            ;; +        :) +            usage "Option -$OPTARG requires an argument" +            ;; +        *) +            usage +            ;; +    esac +done + +shift $((OPTIND-1))  | 
