@installdoc/ansible-gas-station
Version:
An Ansible playbook that provisions your network with software from GitHub Awesome lists, developed with disaster recovery in mind ⛽🔥🤤
167 lines (156 loc) • 6.16 kB
YAML
---
version: '3'
tasks:
pip:
deps:
- :install:software:python
run: when_changed
log:
error: Failed to install pip3 package `{{.PACKAGE}}`
start: Installing pip3 package `{{.PACKAGE}}`
success: Installed pip3 package `{{.PACKAGE}}`
cmds:
- |
if [ -n "$CI" ]; then echo "*************** pip3 --> {{.PACKAGE}}"; fi
- pip3 install {{.PACKAGE}}
status:
- type {{.PACKAGE}} > /dev/null
pipx:
cmds:
- task: :install:pipx:install
vars:
BIN_NAME: '{{.BIN_NAME}}'
PACKAGE: '{{.PACKAGE}}'
pytest:
cmds:
- task: :install:pipx:pytest
pytest-cov:
cmds:
- task: :install:pipx:pytest-cov
requirements:
run: once
cmds:
- task: :install:software:python
- task: requirements:poetry
- task: :{{if eq .REPOSITORY_TYPE "ansible"}}ansible:galaxy:requirements{{else}}donothing{{end}}
requirements:poetry:
cmds:
- task: requirements:poetry:prereqs
- task: requirements:poetry:install
status:
- '[ ! -f pyproject.toml ] || ! type poetry &> /dev/null'
requirements:poetry:install:
summary: |
# Poetry Requirements
`poetry publish -r gitlab` will publish to GitLab registry on GitLab CI
run: once
log:
error: Failed to configure / install via `poetry`
start: Configuring Poetry and running `poetry install`
success: Successfully ran `poetry install`
cmds:
- task: :install:software:poetry
- poetry env use "$(which python3)"
- poetry config virtualenvs.create {{if .PYTHON_VIRTUALENV}}{{.PYTHON_VIRTUALENV}}{{else}}false{{end}}
- poetry config virtualenvs.in-project true
- |
if [ -n "$PYPI_TOKEN" ]; then
poetry config pypi-token.pypi "$PYPI_TOKEN" || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
.config/log warn 'Failed to run `poetry config pypi-token.pypi`'
fi
fi
- |
if [ -n "$GITLAB_CI" ]; then
poetry config repositories.gitlab "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi"
fi
- |
if [ -n "$GITLAB_CI" ]; then
poetry config http-basic.gitlab gitlab-ci-token "${CI_JOB_TOKEN}" || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
.config/log warn 'Failed to run `poetry config http-basic.gitlab gitlab-ci-token`'
fi
fi
- |
if [ -n "$AUTO_UPDATE_PIP_PACKAGES" ]; then
.config/log info 'Updating Poetry dependencies{{if .INSTALL_OPTIONS}} with options `{{.INSTALL_OPTIONS}}`{{end}}'
poetry update{{if .INSTALL_OPTIONS}} {{.INSTALL_OPTIONS}}{{end}}
else
.config/log info 'Installing Poetry dependencies{{if .INSTALL_OPTIONS}} with options `{{.INSTALL_OPTIONS}}`{{end}}'
poetry install{{if .INSTALL_OPTIONS}} {{.INSTALL_OPTIONS}}{{end}} || EXIT_CODE=$?
if [ -n "$EXIT_CODE" ]; then
.config/log warn 'Running `poetry install{{if .INSTALL_OPTIONS}} {{.INSTALL_OPTIONS}}{{end}}` failed.'
.config/log info 'Attempting to fix by running `poetry update{{if .INSTALL_OPTIONS}} {{.INSTALL_OPTIONS}}{{end}}`'
poetry update{{if .INSTALL_OPTIONS}} {{.INSTALL_OPTIONS}}{{end}}
fi
fi
sources:
- pyproject.toml
requirements:poetry:prereqs:
tags:
- update
vars:
GCC5_MISSING_MESSAGE: |
It looks like your system is missing gcc-5 but gcc is available. You might be prompted
for your sudo password to run the following command:
log:
error: Error checking `gcc`
start: Checking if `gcc` should be symlinked to `gcc-5`
success: Checked `gcc`
cmds:
- |
if which gcc; then
if [ -w /usr/local/bin ]; then
ln -s "$(which gcc)" /usr/local/bin/gcc-5
else
.config/log info '{{.GCC5_MISSING_MESSAGE}}'
.config/log info '`sudo ln -s '"$(which gcc)"' /usr/local/bin/gcc-5`'
sudo ln -s "$(which gcc)" /usr/local/bin/gcc-5
fi
else
.config/log warn '`gcc` is missing.'
fi
status:
- which gcc-5
venv:node:
deps:
- :install:software:dasel
- :install:software:python
vars:
POETRY_MANUAL_SETUP_MSG: Adding semantic-release-python plugin Python dependencies by
running `poetry add pip@latest setuptools@latest twine@latest wheel@latest`
log:
error: Encountered error while installing Python dependencies for `semantic-release-python`
start: Installing `semantic-release-python` Python dependencies
success: Successfully installed `semantic-release-python` Python dependencies
cmds:
- |
REQUIREMENTS_PATH="$PWD/lib/requirements.txt"
cd "$INIT_CWD" || exit
if type poetry > /dev/null && test -f pyproject.toml; then
.config/log info 'Poetry installation detected. Using Poetry to install NPM package Python dependencies.'
if dasel select -f pyproject.toml '.tool.poetry.extras.semantic' > /dev/null; then
.config/log info '`semantic` extras bundle detected.. Installing via `poetry install -E semantic`'
poetry install -E semantic
else
.config/log info '{{.POETRY_MANUAL_SETUP_MSG}}'
poetry add pip@latest setuptools@latest twine@latest wheel@latest
fi
else
if [ -f venv/bin/activate ]; then
.config/log info 'Using existing virtualenv found at `venv/`'
. venv/bin/activate
elif [ -f .venv/bin/activate ]; then
.config/log info 'Using existing virtualenv found at `.venv/`'
. .venv/bin/activate
else
.config/log info 'No virtualenv detected.. Creating virtualenv in `.venv/`'
python3 -m venv .venv
. .venv/bin/activate
fi
.config/log info 'Installing Python dependencies into virtualenv'
pip3 install -U pip setuptools
pip3 install -r "$REQUIREMENTS_PATH"
fi
sources:
- lib/requirements.txt