# Automatisierte Provisionierung mittels Terraform
**Autor:** Frank Brehm <frank.brehm@pixelpark.com>
+
**Copyright:** Pixelpark GmbH, Berlin, 2019
## 1. Voraussetzungen und Installation
--- /dev/null
+#!/bin/bash
+
+set -e
+set -u
+
+this_script=$( readlink -f "$0" )
+cur_dir=$( pwd )
+
+base_dir=$( dirname $( dirname "${this_script}" ) )
+cd ${base_dir}
+
+locale_dir=locale
+locale_domain="create_terraform"
+pot_file="${locale_dir}/${locale_domain}.pot"
+po_with=99
+my_address="${DEBEMAIL:-frank.brehm@pixelpark.com}"
+
+if [[ ! -d "${locale_dir}" ]] ; then
+ echo "Localisation directory '${cur_dir}/${locale_dir}' not found." >&2
+ exit 3
+fi
+
+pybabel compile --domain "${locale_domain}" \
+ --directory "${locale_dir}" \
+ --statistics
+
--- /dev/null
+#!/bin/bash
+
+base_dir=$( dirname $( dirname $0 ) )
+cd ${base_dir}
+base_dir=$( readlink -f . )
+
+declare -a VALID_PY_VERSIONS=("3.8" "3.7" "3.6" "3.5")
+
+echo "Preparing virtual environment ..."
+echo
+if [[ ! -f venv/bin/activate ]] ; then
+ found="n"
+ for py_version in "${VALID_PY_VERSIONS[@]}" ; do
+ PYTHON="python${py_version}"
+ if type -t ${PYTHON} >/dev/null ; then
+ found="y"
+ echo
+ echo "Found ${PYTHON}."
+ echo
+ virtualenv --python=${PYTHON} venv
+ break
+ fi
+ done
+ if [[ "${found}" == "n" ]] ; then
+ echo >&2
+ echo "Did not found a usable Python version." >&2
+ echo "Usable Python versions are: ${VALID_PY_VERSIONS[*]}" >&2
+ echo >&2
+ exit 5
+ fi
+fi
+
+. venv/bin/activate || exit 5
+
+echo "---------------------------------------------------"
+echo "Upgrading PIP ..."
+echo
+pip install --upgrade --upgrade-strategy eager pip
+echo
+
+echo "---------------------------------------------------"
+echo "Upgrading setuptools + wheel + six ..."
+echo
+pip install --upgrade --upgrade-strategy eager setuptools wheel six
+echo
+
+echo "---------------------------------------------------"
+echo "Installing and/or upgrading necessary modules ..."
+echo
+pip install --upgrade --upgrade-strategy eager --requirement requirements.txt
+echo
+echo "---------------------------------------------------"
+echo "Installed modules:"
+echo
+pip list --format columns
+
+if [[ -x bin/compile-xlate-msgs.sh ]]; then
+ echo
+ echo "--------------"
+ echo "Updating i18n files in ${base_dir} ..."
+ echo
+ bin/compile-xlate-msgs.sh
+fi
+
+echo
+echo "-------"
+echo "Fertig."
+echo
+
+# vim: ts=4
--- /dev/null
+#!/bin/bash
+
+set -e
+set -u
+
+this_script=$( readlink -f "$0" )
+cur_dir=$( pwd )
+
+base_dir=$( dirname $( dirname "${this_script}" ) )
+cd ${base_dir}
+
+locale_dir=locale
+locale_domain="create_terraform"
+pot_file="${locale_dir}/${locale_domain}.pot"
+po_with=99
+my_address="${DEBEMAIL:-frank.brehm@pixelpark.com}"
+
+if [[ ! -d "lib" ]] ; then
+ echo "Python module directory '${cur_dir}/lib' not found." >&2
+ exit 3
+fi
+
+pkg_version=$( cat lib/cr_tf/__init__.py | \
+ grep '^[ ]*__version__' | \
+ sed -e 's/[ ]*//g' | \
+ awk -F= '{print $2}' | \
+ sed -e "s/^'//" -e "s/'\$//" )
+
+mkdir -pv "${locale_dir}"
+
+pybabel extract lib/cr_tf \
+ -o "${pot_file}" \
+ -F babel.ini \
+ --width=${po_with} \
+ --sort-by-file \
+ --msgid-bugs-address="${my_address}" \
+ --copyright-holder="Frank Brehm, Pixelpark GmbH, Berlin" \
+ --project="${locale_domain}" \
+ --version="${pkg_version}"
+
+sed -i -e "s/FIRST AUTHOR/Frank Brehm/g" -e "s/<EMAIL@ADDRESS>/<${my_address}>/g" "${pot_file}"
+
+for lang in de_DE en_US ; do
+ if [[ ! -f "${locale_dir}/${lang}/LC_MESSAGES/${locale_domain}.po" ]] ; then
+ pybabel init --domain "${locale_domain}" \
+ --input-file "${pot_file}" \
+ --output-dir "${locale_dir}" \
+ --locale "${lang}" \
+ --width ${po_with}
+ else
+ pybabel update --domain "${locale_domain}" \
+ --input-file "${pot_file}" \
+ --output-dir "${locale_dir}" \
+ --locale "${lang}" \
+ --width ${po_with} \
+ --update-header-comment
+ fi
+ # --ignore-obsolete \
+done
--- /dev/null
+pip
+ansible
+babel
+PyYAML
+pyvmomi>=v6.5.0.2017.5-1
+requests
+six
+pytz
+paramiko
+dnspython
+flake8
+docker-py
+pathlib
+setuptools
+git+https://git.pixelpark.com/python/python_fb_tools.git@master