Puppet Functions Library

by samuelelliot
0 deployments · 0 still active · last rev. 2 years ago

Does nothing on its own. Do not deploy directly.


* VARIABLES *

PE_ANSWER_FILE
PE_LOG_FILE


* PUPPET INSTALL FUNCTIONS *

puppet_install_from_backports_ppa "puppet/master/passwnger"
Add Puppet Backport repository, keys, and install applications


* PUPPET CONFIGUER FUNCTIONS *

puppet_config_agent_env "environment"
- Configure Puppet Agent environment

puppet_config_agent_master_dns "master ip"
- Configure Puppet Agent for remote connection

puppet_config_agent_seccom
- Initialize Secure Communications with Puppet Master


* PUPPET ANSWER FUNCTIONS *

puppet_answer_yes_no "value"
- Translate the value to an answer file valid value

puppet_answer_write "directive" "value"
- Write an answer to the Puppet install answer file


* AUGEAS INSTALL FUNCTIONS *

augeas_install_from_backports_ppa
- Add Augeas Backports PPA & Sign

Compatible with: No distros currently supported
						#!/usr/bin/env bash
#
# Puppet Functions Library
#
# Does nothing on its own. Do not deploy directly.
#
#
# * VARIABLES *
#
# PE_ANSWER_FILE
# PE_LOG_FILE
#
#
# * PUPPET INSTALL FUNCTIONS *
#
# puppet_install_from_backports_ppa "puppet/master/passwnger"
# Add Puppet Backport repository, keys, and install applications
#
#
# * PUPPET CONFIGUER FUNCTIONS *
#
# puppet_config_agent_env "environment"
# - Configure Puppet Agent environment
#
# puppet_config_agent_master_dns "master ip"
# - Configure Puppet Agent for remote connection
#
# puppet_config_agent_seccom
# - Initialize Secure Communications with Puppet Master
#
#
# * PUPPET ANSWER FUNCTIONS *
#
# puppet_answer_yes_no "value"
# - Translate the value to an answer file valid value
#
# puppet_answer_write "directive" "value"
# - Write an answer to the Puppet install answer file
#
#
# * AUGEAS INSTALL FUNCTIONS *
#
# augeas_install_from_backports_ppa
# - Add Augeas Backports PPA & Sign


###############
## VARIABLES ##
###############

PE_ANSWER_FILE="puppet-enterprise-install.cfg"
PE_LOG_FILE="puppet-enterprise-install.log"


##############################
## PUPPET INSTALL FUNCTIONS ##
##############################

puppet_install_from_backports_ppa() {
    # Add Puppet Backport repository and keys
    # $1 = puppet/master/passenger - Install just puppet, master & puppet, or passenger-master & puppet

    # Add Puppet Backports PPA & Sign
    apt_ppa_add ppa:mathiaz/puppet-backports 094D0420   # Defined in StackScriptID 3687

    # Bring system up to date
    apt_upgrade_full                                    # Defined in StackScriptID 3687

    # Install Puppet Agent [and [Passenger] Master]
    if [ "$1" == 'passenger' ]; then
        INSTALL="puppetmaster-passenger puppet rdoc"
    elif [ "$1" == 'master' ]; then
        INSTALL="puppetmaster puppet rdoc"
    else
        INSTALL="puppet rdoc"
    fi

    apt_install "$INSTALL"                              # Defined in StackScriptID 3687
}


################################
## PUPPET CONFIGUER FUNCTIONS ##
################################

puppet_config_agent_env() {
    # Configure Puppet Agent environment
    # $1 = Agent Environment

    if [ ! -n "$1" ]; then
        echo "puppet_config_agent_env requires the Puppet evironment as its first argument"
        return 1;
    fi

    echo "[agent]" > /etc/puppet/puppet.conf
    echo "environment = $1" > /etc/puppet/puppet.conf
}

puppet_config_agent_master_dns() {
    # Configure Puppet Agent for remote connection
    # $1 = Puppet Master IP

    if [ ! -n "$1" ]; then
        echo "puppet_config_agent_master_dns requires the Puppet Master IP as its first argument"
        return 1;
    fi

    add_hosts "$1" "puppet"                             # Defined in StackScriptID 3687
}

puppet_config_agent_seccom() {
    # Initialize Secure Communications with Puppet Master

    puppetd --waitforcert 60 --test
}


#############################
## PUPPET ANSWER FUNCTIONS ##
#############################

puppet_answer_yes_no() {
    # Translate the value to an answer file valid value
    # $1 = the value

    if [ "$1" == "Yes" ]; then
        echo "y"
    elif [ "$1" == "No" ]; then
        echo "n"
    else
        echo "$1"
    fi
}

puppet_answer_write() {
    # Write an answer to the Puppet install answer file
    # $1 = the directive
    # $2 = the value

    if [ ! -n "$2" ]; then
        echo "puppet_answer_write() requires both directive and value arguments"
        return 1;
    fi

    if [ -a "$WORK_DIR/$PE_ANSWER_FILE" ]; then 
        touch "$WORK_DIR/$PE_ANSWER_FILE"
    fi

    echo "$1=$(puppet_answer_yes_no "$2")" >> "$WORK_DIR/$PE_ANSWER_FILE"
}


##############################
## AUGEAS INSTALL FUNCTIONS ##
##############################

augeas_install_from_backports_ppa() {
    # Add Augeas Backports PPA & Sign

    apt_ppa_add ppa:raphink/augeas AE498453             # Defined in StackScriptID 3687

    # Bring system up to date
    apt_upgrade_full                                    # Defined in StackScriptID 3687

    # Install Augeas
    apt_install "augeas"                                # Defined in StackScriptID 3687
}