From ec333339161091d3b005449cdaf9cf4047aae3c9 Mon Sep 17 00:00:00 2001 From: mg Date: Tue, 29 Jun 2021 21:43:09 +0200 Subject: [PATCH] ctop (#139) rolle einzeln submodule entfernt Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/139 Co-Authored-By: mg Co-Committed-By: mg --- roles/gantsign.ctop | 1 - roles/gantsign.ctop/.editorconfig | 27 + roles/gantsign.ctop/.gitattributes | 47 + roles/gantsign.ctop/.github/workflows/ci.yml | 81 ++ .../.github/workflows/release.yml | 29 + roles/gantsign.ctop/.gitignore | 297 ++++++ .../.moleculew/ansible_lint_version | 1 + .../gantsign.ctop/.moleculew/ansible_version | 1 + .../.moleculew/docker_lib_version | 1 + roles/gantsign.ctop/.moleculew/flake8_version | 1 + .../gantsign.ctop/.moleculew/molecule_version | 1 + roles/gantsign.ctop/.moleculew/python_version | 1 + .../.moleculew/testinfra_version | 1 + .../gantsign.ctop/.moleculew/yamllint_version | 1 + roles/gantsign.ctop/.yamllint | 33 + roles/gantsign.ctop/LICENSE | 21 + roles/gantsign.ctop/README.md | 156 +++ roles/gantsign.ctop/defaults/main.yml | 9 + roles/gantsign.ctop/handlers/main.yml | 2 + roles/gantsign.ctop/meta/main.yml | 31 + .../gantsign.ctop/molecule/centos/INSTALL.rst | 22 + .../molecule/centos/molecule.yml | 26 + .../molecule/debian_max/INSTALL.rst | 22 + .../molecule/debian_max/molecule.yml | 29 + .../molecule/debian_min/INSTALL.rst | 22 + .../molecule/debian_min/molecule.yml | 29 + .../molecule/default/INSTALL.rst | 22 + .../molecule/default/converge.yml | 5 + .../molecule/default/molecule.yml | 22 + .../molecule/default/tests/conftest.py | 22 + .../molecule/default/tests/test_role.py | 23 + .../gantsign.ctop/molecule/fedora/INSTALL.rst | 22 + .../molecule/fedora/molecule.yml | 26 + .../molecule/opensuse/INSTALL.rst | 22 + .../molecule/opensuse/molecule.yml | 26 + .../molecule/ubuntu_max/INSTALL.rst | 22 + .../molecule/ubuntu_max/molecule.yml | 29 + .../molecule/ubuntu_min/INSTALL.rst | 22 + .../molecule/ubuntu_min/molecule.yml | 29 + roles/gantsign.ctop/moleculew | 957 ++++++++++++++++++ roles/gantsign.ctop/tasks/main.yml | 31 + roles/gantsign.ctop/vars/main.yml | 18 + 42 files changed, 2189 insertions(+), 1 deletion(-) delete mode 160000 roles/gantsign.ctop create mode 100644 roles/gantsign.ctop/.editorconfig create mode 100644 roles/gantsign.ctop/.gitattributes create mode 100644 roles/gantsign.ctop/.github/workflows/ci.yml create mode 100644 roles/gantsign.ctop/.github/workflows/release.yml create mode 100644 roles/gantsign.ctop/.gitignore create mode 100644 roles/gantsign.ctop/.moleculew/ansible_lint_version create mode 100644 roles/gantsign.ctop/.moleculew/ansible_version create mode 100644 roles/gantsign.ctop/.moleculew/docker_lib_version create mode 100644 roles/gantsign.ctop/.moleculew/flake8_version create mode 100644 roles/gantsign.ctop/.moleculew/molecule_version create mode 100644 roles/gantsign.ctop/.moleculew/python_version create mode 100644 roles/gantsign.ctop/.moleculew/testinfra_version create mode 100644 roles/gantsign.ctop/.moleculew/yamllint_version create mode 100644 roles/gantsign.ctop/.yamllint create mode 100644 roles/gantsign.ctop/LICENSE create mode 100644 roles/gantsign.ctop/README.md create mode 100644 roles/gantsign.ctop/defaults/main.yml create mode 100644 roles/gantsign.ctop/handlers/main.yml create mode 100644 roles/gantsign.ctop/meta/main.yml create mode 100644 roles/gantsign.ctop/molecule/centos/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/centos/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/debian_max/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/debian_max/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/debian_min/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/debian_min/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/default/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/default/converge.yml create mode 100644 roles/gantsign.ctop/molecule/default/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/default/tests/conftest.py create mode 100644 roles/gantsign.ctop/molecule/default/tests/test_role.py create mode 100644 roles/gantsign.ctop/molecule/fedora/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/fedora/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/opensuse/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/opensuse/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/ubuntu_max/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/ubuntu_max/molecule.yml create mode 100644 roles/gantsign.ctop/molecule/ubuntu_min/INSTALL.rst create mode 100644 roles/gantsign.ctop/molecule/ubuntu_min/molecule.yml create mode 100644 roles/gantsign.ctop/moleculew create mode 100644 roles/gantsign.ctop/tasks/main.yml create mode 100644 roles/gantsign.ctop/vars/main.yml diff --git a/roles/gantsign.ctop b/roles/gantsign.ctop deleted file mode 160000 index 92f20ce8..00000000 --- a/roles/gantsign.ctop +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 92f20ce81c42388295bd62afc0e3d04ab398e3c0 diff --git a/roles/gantsign.ctop/.editorconfig b/roles/gantsign.ctop/.editorconfig new file mode 100644 index 00000000..c30c09d8 --- /dev/null +++ b/roles/gantsign.ctop/.editorconfig @@ -0,0 +1,27 @@ +# EditorConfig: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Defaults for all editor files +[*] +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +# YAML is fussy about indenting and charset +[*.yml] +indent_style = space +indent_size = 2 +continuation_indent_size = unset +charset = utf-8 + +# Markdown is fussy about indenting +[*.md] +indent_style = space +indent_size = 4 + +# Jinja2 template files +[*.j2] +end_of_line = lf diff --git a/roles/gantsign.ctop/.gitattributes b/roles/gantsign.ctop/.gitattributes new file mode 100644 index 00000000..ea7ae0f9 --- /dev/null +++ b/roles/gantsign.ctop/.gitattributes @@ -0,0 +1,47 @@ + +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +LICENSE text +.editorconfig text +.gitattributes text +.gitignore text +.yamllint text +*.cfg text +*.css text +*.htm text +*.html text +*.js text +*.json text +*.less text +*.md text +*.py text +*.scss text +*.ts text +*.txt text +*.xhtml text +*.xml text +*.yaml text +*.yml text + +# Declare files that will always have CRLF line endings on checkout. +*.bat text eol=crlf +*.cmd text eol=crlf + +# Declare files that will always have LF line endings on checkout. +*.conf eol=lf +*.desktop eol=lf +*.j2 eol=lf +*.service eol=lf +*.sh text eol=lf + +# Denote all files that are truly binary and should not be modified. +*.eot binary +*.gif binary +*.jpeg binary +*.jpg binary +*.png binary +*.tff binary +*.woff binary diff --git a/roles/gantsign.ctop/.github/workflows/ci.yml b/roles/gantsign.ctop/.github/workflows/ci.yml new file mode 100644 index 00000000..bcb5f8df --- /dev/null +++ b/roles/gantsign.ctop/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +name: Tests + +on: + push: + branches: + - master + pull_request: {} + +env: + MOLECULEW_USE_SYSTEM: 'true' + PY_COLORS: '1' + ANSIBLE_FORCE_COLOR: '1' + +jobs: + test: + name: Molecule test + runs-on: ubuntu-18.04 + + strategy: + matrix: + ansible-version: + - '2.9.1' + molecule-scenario: + - centos + - debian_max + - debian_min + - ubuntu_max + - opensuse + - fedora + include: + - ansible-version: '2.8.16' + molecule-scenario: ubuntu_min + + env: + MOLECULEW_ANSIBLE: ${{ matrix.ansible-version }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.6' + + - name: Cache Molecule + id: molecule-cache + uses: actions/cache@v2 + with: + path: ~/.moleculew + key: Ansible-${{ matrix.ansible-version }}-${{ hashFiles('.moleculew/**') }} + + - name: Install dependencies + if: steps.molecule-cache.outputs.cache-hit != 'true' + run: ./moleculew wrapper-install + + - name: Dependency versions + run: ./moleculew wrapper-versions + + - name: Login to Docker Hub + if: '!github.event.pull_request || github.event.pull_request.head.repo.full_name == github.repository' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Molecule test + run: ./moleculew test --scenario-name=${{ matrix.molecule-scenario }} + + - name: Compact cache + if: steps.molecule-cache.outputs.cache-hit != 'true' + run: find ~/.moleculew -name '__pycache__' -exec rm -rf {} + + + test-all: + if: ${{ always() }} + name: Test (matrix) + runs-on: ubuntu-18.04 + needs: test + steps: + - name: Check test matrix status + run: "[[ '${{ needs.test.result }}' == 'success' ]] || exit 1" diff --git a/roles/gantsign.ctop/.github/workflows/release.yml b/roles/gantsign.ctop/.github/workflows/release.yml new file mode 100644 index 00000000..5d21acc5 --- /dev/null +++ b/roles/gantsign.ctop/.github/workflows/release.yml @@ -0,0 +1,29 @@ +name: Release +on: + push: + tags: + - '*' + +jobs: + + release: + name: Release + runs-on: ubuntu-18.04 + steps: + - name: Checkout + + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.6' + + - name: Install Ansible + run: pip3 install --no-compile ansible-base + + - name: Trigger a new import on Galaxy + run: >- + ansible-galaxy role import + --api-key ${{ secrets.GALAXY_API_KEY }} + ${GITHUB_REPOSITORY%%/*} ${GITHUB_REPOSITORY#*/} diff --git a/roles/gantsign.ctop/.gitignore b/roles/gantsign.ctop/.gitignore new file mode 100644 index 00000000..81318854 --- /dev/null +++ b/roles/gantsign.ctop/.gitignore @@ -0,0 +1,297 @@ +# Created by https://www.gitignore.io/api/windows,linux,osx,vim,emacs,intellij,eclipse,visualstudiocode,ansible + +### Ansible ### +*.retry + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +# End of https://www.gitignore.io/api/windows,linux,osx,vim,emacs,intellij,eclipse,visualstudiocode,ansible + +#################### +### Custom rules ### +#################### + +### Molecule ### + +__pycache__ +.cache +.molecule diff --git a/roles/gantsign.ctop/.moleculew/ansible_lint_version b/roles/gantsign.ctop/.moleculew/ansible_lint_version new file mode 100644 index 00000000..e198586e --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/ansible_lint_version @@ -0,0 +1 @@ +4.3.5 diff --git a/roles/gantsign.ctop/.moleculew/ansible_version b/roles/gantsign.ctop/.moleculew/ansible_version new file mode 100644 index 00000000..dedcc7d4 --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/ansible_version @@ -0,0 +1 @@ +2.9.1 diff --git a/roles/gantsign.ctop/.moleculew/docker_lib_version b/roles/gantsign.ctop/.moleculew/docker_lib_version new file mode 100644 index 00000000..f77856a6 --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/docker_lib_version @@ -0,0 +1 @@ +4.3.1 diff --git a/roles/gantsign.ctop/.moleculew/flake8_version b/roles/gantsign.ctop/.moleculew/flake8_version new file mode 100644 index 00000000..ff313b8c --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/flake8_version @@ -0,0 +1 @@ +3.8.4 diff --git a/roles/gantsign.ctop/.moleculew/molecule_version b/roles/gantsign.ctop/.moleculew/molecule_version new file mode 100644 index 00000000..67786e24 --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/molecule_version @@ -0,0 +1 @@ +3.0.8 diff --git a/roles/gantsign.ctop/.moleculew/python_version b/roles/gantsign.ctop/.moleculew/python_version new file mode 100644 index 00000000..5b341314 --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/python_version @@ -0,0 +1 @@ +3.6.7 diff --git a/roles/gantsign.ctop/.moleculew/testinfra_version b/roles/gantsign.ctop/.moleculew/testinfra_version new file mode 100644 index 00000000..c7cb1311 --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/testinfra_version @@ -0,0 +1 @@ +5.3.1 diff --git a/roles/gantsign.ctop/.moleculew/yamllint_version b/roles/gantsign.ctop/.moleculew/yamllint_version new file mode 100644 index 00000000..ad219194 --- /dev/null +++ b/roles/gantsign.ctop/.moleculew/yamllint_version @@ -0,0 +1 @@ +1.25.0 diff --git a/roles/gantsign.ctop/.yamllint b/roles/gantsign.ctop/.yamllint new file mode 100644 index 00000000..88276760 --- /dev/null +++ b/roles/gantsign.ctop/.yamllint @@ -0,0 +1,33 @@ +--- +# Based on ansible-lint config +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + colons: + max-spaces-after: -1 + level: error + commas: + max-spaces-after: -1 + level: error + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + max: 3 + level: error + hyphens: + level: error + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable + truthy: disable diff --git a/roles/gantsign.ctop/LICENSE b/roles/gantsign.ctop/LICENSE new file mode 100644 index 00000000..4add3620 --- /dev/null +++ b/roles/gantsign.ctop/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 GantSign Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/roles/gantsign.ctop/README.md b/roles/gantsign.ctop/README.md new file mode 100644 index 00000000..80258c59 --- /dev/null +++ b/roles/gantsign.ctop/README.md @@ -0,0 +1,156 @@ +Ansible Role: ctop +================== + +[![Tests](https://github.com/gantsign/ansible_role_ctop/workflows/Tests/badge.svg)](https://github.com/gantsign/ansible_role_ctop/actions?query=workflow%3ATests) +[![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-gantsign.ctop-blue.svg)](https://galaxy.ansible.com/gantsign/ctop) +[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/gantsign/ansible_role_ctop/master/LICENSE) + +Role to download and install [ctop](https://ctop.sh) the top-like interface for +container metrics. View CPU, RAM and network I/O for your Docker containers at +a glance from your terminal. + +Requirements +------------ + +* Ansible >= 2.8 + +* Linux Distribution + + * Debian Family + + * Debian + + * Jessie (8) + * Stretch (9) + + * Ubuntu + + * Xenial (16.04) + * Bionic (18.04) + + * RedHat Family + + * CentOS + + * 7 + + * Fedora + + * 31 + + * SUSE Family + + * openSUSE + + * 15.1 + + * Note: other versions are likely to work but have not been tested. + +* Docker (already installed) + +Role Variables +-------------- + +The following variables will change the behavior of this role (default values +are shown below): + +```yaml +# ctop version number +ctop_version: '0.7.6' + +# SHA256 sum for the ctop redistributable +ctop_redis_sha256sum: 'c5f8da250ec733084fb3891f2f8d04a49ffd25e81af59079216f2e6bb35fd983' + +# Directory to store files downloaded for ctop +ctop_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}" +``` + +Example Playbook +---------------- + +```yaml +- hosts: servers + roles: + - role: gantsign.ctop +``` + +Tab Completion for Zsh +---------------------- + +### Using Ansible + +We recommend using the +[gantsign.antigen](https://galaxy.ansible.com/gantsign/antigen) role to enable +tab completion for ctop (this must be configured for each user). + +```yaml +- hosts: servers + roles: + - role: gantsign.ctop + + - role: gantsign.antigen + users: + - username: example + antigen_bundles: + - name: ctop + url: gantsign/zsh-plugins + location: ctop +``` + +### Using Antigen + +If you prefer to use [Antigen](https://github.com/zsh-users/antigen) directly +add the following to your Antigen configuration: + +```bash +antigen bundle gantsign/zsh-plugins ctop +``` + +More Roles From GantSign +------------------------ + +You can find more roles from GantSign on +[Ansible Galaxy](https://galaxy.ansible.com/gantsign). + +Development & Testing +--------------------- + +This project uses [Molecule](http://molecule.readthedocs.io/) to aid in the +development and testing; the role is unit tested using +[Testinfra](http://testinfra.readthedocs.io/) and +[pytest](http://docs.pytest.org/). + +To develop or test you'll need to have installed the following: + +* Linux (e.g. [Ubuntu](http://www.ubuntu.com/)) +* [Docker](https://www.docker.com/) +* [Python](https://www.python.org/) (including python-pip) +* [Ansible](https://www.ansible.com/) +* [Molecule](http://molecule.readthedocs.io/) + +Because the above can be tricky to install, this project includes +[Molecule Wrapper](https://github.com/gantsign/molecule-wrapper). Molecule +Wrapper is a shell script that installs Molecule and it's dependencies (apart +from Linux) and then executes Molecule with the command you pass it. + +To test this role using Molecule Wrapper run the following command from the +project root: + +```bash +./moleculew test +``` + +Note: some of the dependencies need `sudo` permission to install. + +License +------- + +MIT + +Author Information +------------------ + +John Freeman + +GantSign Ltd. +Company No. 06109112 (registered in England) diff --git a/roles/gantsign.ctop/defaults/main.yml b/roles/gantsign.ctop/defaults/main.yml new file mode 100644 index 00000000..42e0d7dc --- /dev/null +++ b/roles/gantsign.ctop/defaults/main.yml @@ -0,0 +1,9 @@ +--- +# ctop version number +ctop_version: '0.7.6' + +# SHA256 sum for the ctop redistributable +ctop_redis_sha256sum: 'c5f8da250ec733084fb3891f2f8d04a49ffd25e81af59079216f2e6bb35fd983' + +# Directory to store files downloaded for ctop +ctop_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}" diff --git a/roles/gantsign.ctop/handlers/main.yml b/roles/gantsign.ctop/handlers/main.yml new file mode 100644 index 00000000..5b6f86c4 --- /dev/null +++ b/roles/gantsign.ctop/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for ansible_role_ctop diff --git a/roles/gantsign.ctop/meta/main.yml b/roles/gantsign.ctop/meta/main.yml new file mode 100644 index 00000000..b4727225 --- /dev/null +++ b/roles/gantsign.ctop/meta/main.yml @@ -0,0 +1,31 @@ +--- +galaxy_info: + author: John Freeman + role_name: ctop + description: Ansible role for downloading and installing ctop. + company: GantSign Ltd. + license: MIT + min_ansible_version: 2.8 + platforms: + - name: EL + versions: + - 7 + - name: Fedora + versions: + - 31 + - name: Ubuntu + versions: + - xenial + - bionic + - name: Debian + versions: + - jessie + - stretch + - name: opensuse + versions: + - 15.1 + galaxy_tags: + - ctop + - docker + - development +dependencies: [] diff --git a/roles/gantsign.ctop/molecule/centos/INSTALL.rst b/roles/gantsign.ctop/molecule/centos/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/centos/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/centos/molecule.yml b/roles/gantsign.ctop/molecule/centos/molecule.yml new file mode 100644 index 00000000..bcd95b00 --- /dev/null +++ b/roles/gantsign.ctop/molecule/centos/molecule.yml @@ -0,0 +1,26 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_centos + image: centos:7 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/molecule/debian_max/INSTALL.rst b/roles/gantsign.ctop/molecule/debian_max/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/debian_max/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/debian_max/molecule.yml b/roles/gantsign.ctop/molecule/debian_max/molecule.yml new file mode 100644 index 00000000..e8b6d1f9 --- /dev/null +++ b/roles/gantsign.ctop/molecule/debian_max/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_debian_max + image: debian:9 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +scenario: + name: debian_max + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/molecule/debian_min/INSTALL.rst b/roles/gantsign.ctop/molecule/debian_min/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/debian_min/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/debian_min/molecule.yml b/roles/gantsign.ctop/molecule/debian_min/molecule.yml new file mode 100644 index 00000000..7f226490 --- /dev/null +++ b/roles/gantsign.ctop/molecule/debian_min/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_debian_min + image: debian:8 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +scenario: + name: debian_min + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/molecule/default/INSTALL.rst b/roles/gantsign.ctop/molecule/default/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/default/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/default/converge.yml b/roles/gantsign.ctop/molecule/default/converge.yml new file mode 100644 index 00000000..e2368af7 --- /dev/null +++ b/roles/gantsign.ctop/molecule/default/converge.yml @@ -0,0 +1,5 @@ +--- +- name: Converge + hosts: all + roles: + - role: ansible_role_ctop diff --git a/roles/gantsign.ctop/molecule/default/molecule.yml b/roles/gantsign.ctop/molecule/default/molecule.yml new file mode 100644 index 00000000..ca2c6cb0 --- /dev/null +++ b/roles/gantsign.ctop/molecule/default/molecule.yml @@ -0,0 +1,22 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_default + image: ubuntu:18.04 + +provisioner: + name: ansible + +verifier: + name: testinfra diff --git a/roles/gantsign.ctop/molecule/default/tests/conftest.py b/roles/gantsign.ctop/molecule/default/tests/conftest.py new file mode 100644 index 00000000..e1b22c08 --- /dev/null +++ b/roles/gantsign.ctop/molecule/default/tests/conftest.py @@ -0,0 +1,22 @@ +"""PyTest Fixtures.""" +from __future__ import absolute_import + +import os + +import pytest + + +def pytest_runtest_setup(item): + """Run tests only when under molecule with testinfra installed.""" + try: + import testinfra + except ImportError: + pytest.skip("Test requires testinfra", allow_module_level=True) + if "MOLECULE_INVENTORY_FILE" in os.environ: + pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ["MOLECULE_INVENTORY_FILE"] + ).get_hosts("all") + else: + pytest.skip( + "Test should run only from inside molecule.", + allow_module_level=True) diff --git a/roles/gantsign.ctop/molecule/default/tests/test_role.py b/roles/gantsign.ctop/molecule/default/tests/test_role.py new file mode 100644 index 00000000..9c6e7be4 --- /dev/null +++ b/roles/gantsign.ctop/molecule/default/tests/test_role.py @@ -0,0 +1,23 @@ +import re + + +def test_dir(host): + dir = host.file('/usr/local/bin') + assert dir.exists + assert dir.is_directory + assert dir.user == 'root' + assert dir.group == 'root' + + +def test_file(host): + installed_file = host.file('/usr/local/bin/ctop') + assert installed_file.exists + assert installed_file.is_file + assert installed_file.user == 'root' + assert installed_file.group == 'root' + + +def test_version(host): + version = host.check_output('ctop -v') + pattern = 'ctop version [0-9\\.]+' + assert re.search(pattern, version) diff --git a/roles/gantsign.ctop/molecule/fedora/INSTALL.rst b/roles/gantsign.ctop/molecule/fedora/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/fedora/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/fedora/molecule.yml b/roles/gantsign.ctop/molecule/fedora/molecule.yml new file mode 100644 index 00000000..b95d796e --- /dev/null +++ b/roles/gantsign.ctop/molecule/fedora/molecule.yml @@ -0,0 +1,26 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_fedora + image: fedora:31 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/molecule/opensuse/INSTALL.rst b/roles/gantsign.ctop/molecule/opensuse/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/opensuse/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/opensuse/molecule.yml b/roles/gantsign.ctop/molecule/opensuse/molecule.yml new file mode 100644 index 00000000..5100dfe6 --- /dev/null +++ b/roles/gantsign.ctop/molecule/opensuse/molecule.yml @@ -0,0 +1,26 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_opensuse + image: opensuse/leap:15.1 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/molecule/ubuntu_max/INSTALL.rst b/roles/gantsign.ctop/molecule/ubuntu_max/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/ubuntu_max/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/ubuntu_max/molecule.yml b/roles/gantsign.ctop/molecule/ubuntu_max/molecule.yml new file mode 100644 index 00000000..2e7a50d7 --- /dev/null +++ b/roles/gantsign.ctop/molecule/ubuntu_max/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_ubuntu_max + image: ubuntu:18.04 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +scenario: + name: ubuntu_max + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/molecule/ubuntu_min/INSTALL.rst b/roles/gantsign.ctop/molecule/ubuntu_min/INSTALL.rst new file mode 100644 index 00000000..d926ca25 --- /dev/null +++ b/roles/gantsign.ctop/molecule/ubuntu_min/INSTALL.rst @@ -0,0 +1,22 @@ +******* +Docker driver installation guide +******* + +Requirements +============ + +* Docker Engine + +Install +======= + +Please refer to the `Virtual environment`_ documentation for installation best +practices. If not using a virtual environment, please consider passing the +widely recommended `'--user' flag`_ when invoking ``pip``. + +.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ +.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site + +.. code-block:: bash + + $ python3 -m pip install 'molecule[docker]' diff --git a/roles/gantsign.ctop/molecule/ubuntu_min/molecule.yml b/roles/gantsign.ctop/molecule/ubuntu_min/molecule.yml new file mode 100644 index 00000000..4b2b4e95 --- /dev/null +++ b/roles/gantsign.ctop/molecule/ubuntu_min/molecule.yml @@ -0,0 +1,29 @@ +--- +dependency: + name: galaxy + +driver: + name: docker + +lint: | + set -e + yamllint . + ansible-lint + flake8 + +platforms: + - name: ansible_role_ctop_ubuntu_min + image: ubuntu:16.04 + dockerfile: ../default/Dockerfile.j2 + +provisioner: + name: ansible + playbooks: + converge: ../default/converge.yml + +scenario: + name: ubuntu_min + +verifier: + name: testinfra + directory: ../default/tests diff --git a/roles/gantsign.ctop/moleculew b/roles/gantsign.ctop/moleculew new file mode 100644 index 00000000..fdbe4079 --- /dev/null +++ b/roles/gantsign.ctop/moleculew @@ -0,0 +1,957 @@ +#!/usr/bin/env bash + +# MIT License +# +# Copyright (c) 2018 GantSign Ltd. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +# Molecule Wrapper the wrapper script for Molecule +# https://github.com/gantsign/molecule-wrapper + +set -e + +WRAPPER_VERSION=1.1.0 + +VERSION_DIR='.moleculew' +PYTHON_VERSION_FILE="$VERSION_DIR/python_version" +ANSIBLE_VERSION_FILE="$VERSION_DIR/ansible_version" +DOCKER_LIB_VERSION_FILE="$VERSION_DIR/docker_lib_version" +MOLECULE_VERSION_FILE="$VERSION_DIR/molecule_version" +YAMLLINT_VERSION_FILE="$VERSION_DIR/yamllint_version" +ANSIBLE_LINT_VERSION_FILE="$VERSION_DIR/ansible_lint_version" +FLAKE8_VERSION_FILE="$VERSION_DIR/flake8_version" +TESTINFRA_VERSION_FILE="$VERSION_DIR/testinfra_version" + +BUILD_DEPENDENCIES_INSTALLLED=false +PYENV_INSTALLED=false + +ANSIBLE_VERSION='' +DOCKER_LIB_VERSION='' +MOLECULE_VERSION='' +PYTHON_VERSION='' +YAMLLINT_VERSION='' +ANSIBLE_LINT_VERSION='' +FLAKE8_VERSION='' +TESTINFRA_VERSION='' +USE_SYSTEM_DEPENDENCIES=false + +PRE_ARGS=() +MOLECULE_CMD='' +POST_ARGS=() + +export PATH="$HOME/.pyenv/bin:$HOME/.local/bin:$PATH" + +hr() { + for ((i = 1; i <= 80; i++)); do + printf '*' + done + echo '' +} + +banner() { + hr + echo "$1" + hr +} + +run_as_root() { + if [[ $EUID -eq 0 ]]; then + "$@" + elif [ -x "$(command -v sudo)" ]; then + sudo "$@" + else + echo "Error: sudo is not installed" >&2 + exit 1 + fi +} + +build_dependencies_present() { + if [[ $BUILD_DEPENDENCIES_INSTALLLED == true ]]; then + return + fi + if [[ $USE_SYSTEM_DEPENDENCIES == true ]]; then + return + fi + # https://github.com/pyenv/pyenv/wiki/common-build-problems + if [[ -x "$(command -v apt-get)" ]]; then + banner 'Installing build dependencies' + + run_as_root apt-get update + run_as_root apt-get install --assume-yes \ + make build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ + libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev \ + git jq + echo '' + elif [[ -x "$(command -v dnf)" ]]; then + banner 'Installing build dependencies' + + run_as_root dnf install \ + zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel \ + openssl-devel xz xz-devel libffi-devel \ + git curl jq + echo '' + elif [[ -x "$(command -v yum)" ]]; then + banner 'Installing build dependencies' + + run_as_root yum install \ + zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel \ + openssl-devel xz xz-devel libffi-devel \ + git curl jq + echo '' + elif [[ -x "$(command -v zypper)" ]]; then + banner 'Installing build dependencies' + + run_as_root zypper install \ + zlib-devel bzip2 libbz2-devel readline-devel sqlite3 sqlite3-devel \ + libopenssl-devel xz xz-devel \ + git curl jq + echo '' + fi + BUILD_DEPENDENCIES_INSTALLLED=true +} + +pyenv_present() { + if [[ $PYENV_INSTALLED == true ]]; then + return + fi + if [[ $USE_SYSTEM_DEPENDENCIES == true ]]; then + return + fi + if [[ -x "$(command -v pyenv)" ]]; then + PYENV_INSTALLED=true + return + fi + + build_dependencies_present + + banner "Installing pyenv for user $USER" + bash <(curl --location https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer) + echo '' + PYENV_INSTALLED=true +} + +query_latest_python_version() { + pyenv_present + + PYTHON_VERSION="$(~/.pyenv/plugins/python-build/bin/python-build --definitions | grep --color=never '^3\.' | grep --invert-match '\-dev$' | tail -1)" +} + +query_latest_package_version() { + if [[ ! -x "$(command -v curl)" ]]; then + build_dependencies_present + fi + if [[ ! -x "$(command -v jq)" ]]; then + build_dependencies_present + fi + if [[ ! -x "$(command -v curl)" ]]; then + echo 'Error: curl is not installed.' >&2 + exit 1 + fi + if [[ ! -x "$(command -v jq)" ]]; then + echo 'Error: jq is not installed.' >&2 + exit 1 + fi + + local version + # shellcheck disable=SC2034 + version=$(curl --fail --silent --show-error --location "https://pypi.org/pypi/$2/json" | jq --raw-output '.info.version') + + eval "$1=\"\$version\"" +} + +docker_present() { + if [[ -x "$(command -v docker)" ]]; then + return + fi + if [[ $USE_SYSTEM_DEPENDENCIES == true ]]; then + echo 'Error: docker is not installed.' >&2 + exit 1 + fi + + build_dependencies_present + + banner 'Installing Docker' + sh <(curl --fail --silent --show-error --location https://get.docker.com) + run_as_root usermod --append --groups docker "$USER" + banner "User '$USER' has been added to the 'docker' group. Logout/restart and log back in for changes to take effect." + exit +} + +python_present() { + if [[ $PYTHON_VERSION == system ]]; then + if [[ ! -x "$(command -v python3)" ]] && + [[ ! -x "$(command -v python)" ]]; then + echo 'Error: python is not installed.' >&2 + exit 1 + fi + if [[ ! -x "$(command -v pip3)" ]] && + [[ ! -x "$(command -v pip)" ]]; then + echo 'Error: pip is not installed.' >&2 + exit 1 + fi + PYTHON_EXE="$(command -v python3 || command -v python)" + else + if [[ ! -x "$(command -v git)" ]]; then + echo 'Error: git is not installed.' >&2 + exit 1 + fi + + pyenv_present + + export PYENV_VERSION="$PYTHON_VERSION" + if [[ ! -d "$HOME/.pyenv/versions/$PYTHON_VERSION" ]]; then + build_dependencies_present + + banner "Making Python version $PYTHON_VERSION available using pyenv" + pyenv install "$PYTHON_VERSION" + echo '' + fi + eval "$(pyenv init -)" + PYTHON_EXE="$(pyenv which python)" + fi +} + +virtualenv_presant() { + if [[ ! -x "$(command -v virtualenv)" ]]; then + banner "Installing virtualenv for user $USER" + "$PYTHON_EXE" -m pip install --user virtualenv + echo '' + fi +} + +install_ansible() { + banner "Installing Ansible $ANSIBLE_VERSION into virtualenv $VIRTUAL_ENV" + pip install "ansible==$ANSIBLE_VERSION" + echo '' +} + +install_docker_lib() { + banner "Installing Python Docker $DOCKER_LIB_VERSION into virtualenv $VIRTUAL_ENV" + pip install "docker==$DOCKER_LIB_VERSION" + echo '' +} + +install_molecule() { + banner "Installing Molecule $MOLECULE_VERSION into virtualenv $VIRTUAL_ENV" + + pip install "molecule==$MOLECULE_VERSION" + echo '' +} + +install_yamllint() { + banner "Installing YamlLint $YAMLLINT_VERSION into virtualenv $VIRTUAL_ENV" + + pip install "yamllint==$YAMLLINT_VERSION" + echo '' +} + +install_ansible_lint() { + banner "Installing Anssible Lint $ANSIBLE_LINT_VERSION into virtualenv $VIRTUAL_ENV" + + pip install "ansible-lint==$ANSIBLE_LINT_VERSION" + echo '' +} + +install_flake8() { + banner "Installing Flake8 $FLAKE8_VERSION into virtualenv $VIRTUAL_ENV" + + pip install "flake8==$FLAKE8_VERSION" + echo '' +} + +install_testinfra() { + banner "Installing Testinfra $TESTINFRA_VERSION into virtualenv $VIRTUAL_ENV" + + pip install "testinfra==$TESTINFRA_VERSION" + echo '' +} + +wrapper_clean() { + local MOLECULE_WRAPPER_HOME="$HOME/.moleculew" + read -r -p "Delete ${MOLECULE_WRAPPER_HOME} (y/n)? " yn + case $yn in + [Yy]|YES|yes|Yes) + rm -rf "$MOLECULE_WRAPPER_HOME"; + exit + ;; + *) + exit + ;; + esac +} + +wrapper_upgrade() { + curl --fail --silent --show-error --location --output moleculew.new \ + 'https://raw.githubusercontent.com/gantsign/molecule-wrapper/master/moleculew' \ + && chmod 'u+x' moleculew.new \ + && mv --force moleculew.new moleculew + + local NEW_VERSION + NEW_VERSION="$(./moleculew wrapper-version)" + if [ "$WRAPPER_VERSION" != "$NEW_VERSION" ]; then + echo "Upgraded wrapper from version $WRAPPER_VERSION to $NEW_VERSION" + else + echo "You are already using the latest version" + fi + exit +} + +wrapper_version() { + echo "$WRAPPER_VERSION" + exit +} + +print_versions() { + echo "Python: $PYTHON_VERSION" + echo "Ansible: $ANSIBLE_VERSION" + echo "Python Docker library: $DOCKER_LIB_VERSION" + echo "Molecule: $MOLECULE_VERSION" + echo "YamlLint: $YAMLLINT_VERSION" + echo "Ansible Lint: $ANSIBLE_LINT_VERSION" + echo "Flake8: $FLAKE8_VERSION" + echo "Testinfra: $TESTINFRA_VERSION" +} + +wrapper_versions() { + detemine_versions + + print_versions + exit +} + +wrapper_freeze() { + detemine_versions + + banner 'Freezing versions' + + mkdir -p "$VERSION_DIR" + + echo "$PYTHON_VERSION" > "$PYTHON_VERSION_FILE" + echo "$ANSIBLE_VERSION" > "$ANSIBLE_VERSION_FILE" + echo "$DOCKER_LIB_VERSION" > "$DOCKER_LIB_VERSION_FILE" + echo "$MOLECULE_VERSION" > "$MOLECULE_VERSION_FILE" + echo "$YAMLLINT_VERSION" > "$YAMLLINT_VERSION_FILE" + echo "$ANSIBLE_LINT_VERSION" > "$ANSIBLE_LINT_VERSION_FILE" + echo "$FLAKE8_VERSION" > "$FLAKE8_VERSION_FILE" + echo "$TESTINFRA_VERSION" > "$TESTINFRA_VERSION_FILE" + + print_versions + + exit +} + +wrapper_unfreeze() { + banner 'Un-freezing versions' + + if [[ -f "$PYTHON_VERSION_FILE" ]]; then + rm --verbose "$PYTHON_VERSION_FILE" + fi + if [[ -f "$ANSIBLE_VERSION_FILE" ]]; then + rm --verbose "$ANSIBLE_VERSION_FILE" + fi + if [[ -f "$DOCKER_LIB_VERSION_FILE" ]]; then + rm --verbose "$DOCKER_LIB_VERSION_FILE" + fi + if [[ -f "$MOLECULE_VERSION_FILE" ]]; then + rm --verbose "$MOLECULE_VERSION_FILE" + fi + if [[ -f "$YAMLLINT_VERSION_FILE" ]]; then + rm --verbose "$YAMLLINT_VERSION_FILE" + fi + if [[ -f "$ANSIBLE_LINT_VERSION_FILE" ]]; then + rm --verbose "$ANSIBLE_LINT_VERSION_FILE" + fi + if [[ -f "$FLAKE8_VERSION_FILE" ]]; then + rm --verbose "$FLAKE8_VERSION_FILE" + fi + if [[ -f "$TESTINFRA_VERSION_FILE" ]]; then + rm --verbose "$TESTINFRA_VERSION_FILE" + fi + + exit +} + +wrapper_upgrade_versions() { + detemine_versions + + banner 'Upgrading versions' + + local CURRENT_PYTHON_VERSION="$PYTHON_VERSION" + local CURRENT_ANSIBLE_VERSION="$ANSIBLE_VERSION" + local CURRENT_DOCKER_LIB_VERSION="$DOCKER_LIB_VERSION" + local CURRENT_MOLECULE_VERSION="$MOLECULE_VERSION" + local CURRENT_YAMLLINT_VERSION="$YAMLLINT_VERSION" + local CURRENT_ANSIBLE_LINT_VERSION="$ANSIBLE_LINT_VERSION" + local CURRENT_FLAKE8_VERSION="$FLAKE8_VERSION" + local CURRENT_TESTINFRA_VERSION="$TESTINFRA_VERSION" + + query_latest_python_version + query_latest_package_version ANSIBLE_VERSION ansible + query_latest_package_version DOCKER_LIB_VERSION docker + query_latest_package_version MOLECULE_VERSION molecule + query_latest_package_version YAMLLINT_VERSION yamllint + query_latest_package_version ANSIBLE_LINT_VERSION ansible-lint + query_latest_package_version FLAKE8_VERSION flake8 + query_latest_package_version TESTINFRA_VERSION testinfra + echo '' + + echo 'New versions:' + if [[ "$CURRENT_PYTHON_VERSION" == "$PYTHON_VERSION" ]]; then + echo "Python: $CURRENT_PYTHON_VERSION (no change)" + else + echo "Python: $CURRENT_PYTHON_VERSION -> $PYTHON_VERSION" + fi + + if [[ "$CURRENT_ANSIBLE_VERSION" == "$ANSIBLE_VERSION" ]]; then + echo "Ansible: $CURRENT_ANSIBLE_VERSION (no change)" + else + echo "Ansible: $CURRENT_ANSIBLE_VERSION -> $ANSIBLE_VERSION" + fi + + if [[ "$CURRENT_DOCKER_LIB_VERSION" == "$DOCKER_LIB_VERSION" ]]; then + echo "Python Docker library: $CURRENT_DOCKER_LIB_VERSION (no change)" + else + echo "Python Docker library: $CURRENT_DOCKER_LIB_VERSION -> $DOCKER_LIB_VERSION" + fi + + if [[ "$CURRENT_MOLECULE_VERSION" == "$MOLECULE_VERSION" ]]; then + echo "Molecule: $CURRENT_MOLECULE_VERSION (no change)" + else + echo "Molecule: $CURRENT_MOLECULE_VERSION -> $MOLECULE_VERSION" + fi + + if [[ "$CURRENT_YAMLLINT_VERSION" == "$YAMLLINT_VERSION" ]]; then + echo "YamlLint: $CURRENT_YAMLLINT_VERSION (no change)" + else + echo "YamlLint: $CURRENT_YAMLLINT_VERSION -> $YAMLLINT_VERSION" + fi + + if [[ "$CURRENT_ANSIBLE_LINT_VERSION" == "$ANSIBLE_LINT_VERSION" ]]; then + echo "Ansible Lint: $CURRENT_ANSIBLE_LINT_VERSION (no change)" + else + echo "Ansible Lint: $CURRENT_ANSIBLE_LINT_VERSION -> $ANSIBLE_LINT_VERSION" + fi + + if [[ "$CURRENT_FLAKE8_VERSION" == "$FLAKE8_VERSION" ]]; then + echo "Flake8: $CURRENT_FLAKE8_VERSION (no change)" + else + echo "Flake8: $CURRENT_FLAKE8_VERSION -> $FLAKE8_VERSION" + fi + + if [[ "$CURRENT_TESTINFRA_VERSION" == "$TESTINFRA_VERSION" ]]; then + echo "Testinfra: $CURRENT_TESTINFRA_VERSION (no change)" + else + echo "Testinfra: $CURRENT_TESTINFRA_VERSION -> $TESTINFRA_VERSION" + fi + + echo '' + + wrapper_freeze +} + +wrapper_help() { + activate_virtualenv + + molecule --help + + echo " +Molecule Wrapper + +Additional options: + --ansible VERSION Use the specified version of Ansible + --docker-lib VERSION Use the specified version of the Python Docker + library + --molecule VERSION Use the specified version of Molecule + --python VERSION Use the specified version of Python + --yamllint VERSION Use the specified version of YamlLint + --ansible-lint VERSION Use the specified version of Ansible Lint + --flake8 VERSION Use the specified version of Flake8 + --testinfra VERSION Use the specified version of Testinfra + --use-system-dependencies Use system dependencies + +Additional commands: + wrapper-clean Removes all the wrapper virtual environments + wrapper-freeze Freezes the dependency versions being used + wrapper-unfreeze Un-freezes the dependency versions + wrapper-upgrade Upgrades the Molecule Wrapper to the latest version + wrapper-upgrade-versions Upgrades any frozen dependency versions + wrapper-version Displays the current version of Molecule Wrapper +" +} + +query_package_versions() { + local package_name="$1" + local min_version="$2" + + if [[ ! -x "$(command -v curl)" ]]; then + build_dependencies_present > /dev/null + fi + if [[ ! -x "$(command -v jq)" ]]; then + build_dependencies_present > /dev/null + fi + if [[ ! -x "$(command -v curl)" ]]; then + echo 'Error: curl is not installed.' >&2 + exit 1 + fi + if [[ ! -x "$(command -v jq)" ]]; then + echo 'Error: jq is not installed.' >&2 + exit 1 + fi + if [[ ! -x "$(command -v sort)" ]]; then + echo 'Error: sort is not installed.' >&2 + exit 1 + fi + + for i in $(curl --fail --silent --show-error \ + --location "https://pypi.org/pypi/$package_name/json" \ + | jq --raw-output ".releases | keys | .[], \"$min_version.\"" \ + | grep --invert-match '[a-zA-Z]' \ + | sort --version-sort --reverse) ; do + if [[ "$i" == "$min_version." ]]; then + break + fi + echo "$i" + done +} + +wrapper_options_ansible() { + echo 'latest' + query_package_versions 'ansible' '2.8' +} + +wrapper_options_docker_lib() { + echo 'latest' + query_package_versions 'docker' '3.0' +} + +wrapper_options_molecule() { + echo 'latest' + query_package_versions 'molecule' '3.0.6' +} + +wrapper_options_python() { + if [[ ! -x "$(command -v sort)" ]]; then + echo 'Error: sort is not installed.' >&2 + exit 1 + fi + + pyenv_present > /dev/null + + local min_version='3.6' + + echo 'latest' + + for i in $( (echo "$min_version." && \ + ~/.pyenv/plugins/python-build/bin/python-build --definitions) \ + | grep --color=never '^[0-9]' \ + | grep --invert-match '\-dev$' \ + | sort --version-sort --reverse) ; do + if [[ "$i" == "$min_version." ]]; then + break + fi + echo "$i" + done +} + +wrapper_options_yamllint() { + echo 'latest' + query_package_versions 'yamllint' '1.24.2' +} + +wrapper_options_ansible_lint() { + echo 'latest' + query_package_versions 'ansible_lint' '4.2.0' +} + +wrapper_options_flake8() { + echo 'latest' + query_package_versions 'flake8' '3.8.3' +} + +wrapper_options_testinfra() { + echo 'latest' + query_package_versions 'testinfra' '5.2.2' +} + +wrapper_options_scenario() { + ( + cd molecule > /dev/null && + for d in *; do + if [ -d "$d" ]; then + echo "$d" + fi + done + ) +} + +wrapper_virtualenv() { + activate_virtualenv > /dev/null + echo "$VIRTUAL_ENV" +} + +parse_args() { + set +e + + while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + --python=*) + PYTHON_VERSION="${1#*=}" + shift + ;; + --python) + shift + PYTHON_VERSION="$1" + shift + ;; + --ansible=*) + ANSIBLE_VERSION="${1#*=}" + shift + ;; + --ansible) + shift + ANSIBLE_VERSION="$1" + shift + ;; + --docker-lib=*) + DOCKER_LIB_VERSION="${1#*=}" + shift + ;; + --docker-lib) + shift + DOCKER_LIB_VERSION="$1" + shift + ;; + --molecule=*) + MOLECULE_VERSION="${1#*=}" + shift + ;; + --molecule) + shift + MOLECULE_VERSION="$1" + shift + ;; + --yamllint=*) + YAMLLINT_VERSION="${1#*=}" + shift + ;; + --yamllint) + shift + YAMLLINT_VERSION="$1" + shift + ;; + --ansible-lint=*) + ANSIBLE_LINT_VERSION="${1#*=}" + shift + ;; + --ansible-lint) + shift + ANSIBLE_LINT_VERSION="$1" + shift + ;; + --flake8=*) + FLAKE8_VERSION="${1#*=}" + shift + ;; + --flake8) + shift + FLAKE8_VERSION="$1" + shift + ;; + --testinfra) + shift + TESTINFRA_VERSION="$1" + shift + ;; + --testinfra=*) + TESTINFRA_VERSION="${1#*=}" + shift + ;; + --use-system-dependencies) + USE_SYSTEM_DEPENDENCIES=true + shift + ;; + --help) + MOLECULE_CMD='wrapper-help' + break + ;; + wrapper-*) + MOLECULE_CMD="$1" + shift + ;; + check|converge|create|dependency|destroy|idempotence|init|lint|list|login|matrix|prepare|side-effect|syntax|test|verify) + if [[ "$MOLECULE_CMD" != '' ]]; then + shift + else + MOLECULE_CMD="$1" + shift + for arg in "$@"; do + POST_ARGS+=("$arg") + done + break + fi + ;; + *) + PRE_ARGS+=("$1") + shift + ;; + esac + done + set -e +} + +detemine_versions() { + if [[ $USE_SYSTEM_DEPENDENCIES == false ]]; then + USE_SYSTEM_DEPENDENCIES="$MOLECULEW_USE_SYSTEM" + fi + if [[ $PYTHON_VERSION == '' ]]; then + PYTHON_VERSION="$MOLECULEW_PYTHON" + fi + if [[ $ANSIBLE_VERSION == '' ]]; then + ANSIBLE_VERSION="$MOLECULEW_ANSIBLE" + fi + if [[ $DOCKER_LIB_VERSION == '' ]]; then + DOCKER_LIB_VERSION="$MOLECULEW_DOCKER_LIB" + fi + if [[ $MOLECULE_VERSION == '' ]]; then + MOLECULE_VERSION="$MOLECULEW_MOLECULE" + fi + if [[ $YAMLLINT_VERSION == '' ]]; then + YAMLLINT_VERSION="$MOLECULEW_YAMLLINT" + fi + if [[ $ANSIBLE_LINT_VERSION == '' ]]; then + ANSIBLE_LINT_VERSION="$MOLECULEW_ANSIBLE_LINT" + fi + if [[ $FLAKE8_VERSION == '' ]]; then + FLAKE8_VERSION="$MOLECULEW_FLAKE8" + fi + if [[ $TESTINFRA_VERSION == '' ]]; then + TESTINFRA_VERSION="$MOLECULEW_TESTINFRA" + fi + + if [[ $USE_SYSTEM_DEPENDENCIES == true ]]; then + if [[ $PYTHON_VERSION != '' ]]; then + echo "Error: --python and --use-system-dependencies cannot be used together" >&2 + exit 1 + fi + PYTHON_VERSION=system + elif [[ $PYTHON_VERSION == '' ]] || [[ $PYTHON_VERSION == 'default' ]]; then + if [[ -f $PYTHON_VERSION_FILE ]]; then + PYTHON_VERSION=$(<"$PYTHON_VERSION_FILE") + fi + if [[ $PYTHON_VERSION == '' ]]; then + query_latest_python_version + fi + elif [[ $PYTHON_VERSION == 'latest' ]]; then + query_latest_python_version + fi + + if [[ $ANSIBLE_VERSION == '' ]] || [[ $ANSIBLE_VERSION == 'default' ]]; then + if [[ -f $ANSIBLE_VERSION_FILE ]]; then + ANSIBLE_VERSION=$(<"$ANSIBLE_VERSION_FILE") + fi + if [[ $ANSIBLE_VERSION == '' ]]; then + query_latest_package_version ANSIBLE_VERSION ansible + fi + elif [[ $ANSIBLE_VERSION == 'latest' ]]; then + query_latest_package_version ANSIBLE_VERSION ansible + fi + + if [[ $DOCKER_LIB_VERSION == '' ]] || [[ $DOCKER_LIB_VERSION == 'default' ]]; then + if [[ -f $DOCKER_LIB_VERSION_FILE ]]; then + DOCKER_LIB_VERSION=$(<"$DOCKER_LIB_VERSION_FILE") + fi + if [[ $DOCKER_LIB_VERSION == '' ]]; then + query_latest_package_version DOCKER_LIB_VERSION docker + fi + elif [[ $DOCKER_LIB_VERSION == 'latest' ]]; then + query_latest_package_version DOCKER_LIB_VERSION docker + fi + + if [[ $MOLECULE_VERSION == '' ]] || [[ $MOLECULE_VERSION == 'default' ]]; then + if [[ -f $MOLECULE_VERSION_FILE ]]; then + MOLECULE_VERSION=$(<$MOLECULE_VERSION_FILE) + fi + if [[ $MOLECULE_VERSION == '' ]]; then + query_latest_package_version MOLECULE_VERSION molecule + fi + elif [[ $MOLECULE_VERSION == 'latest' ]]; then + query_latest_package_version MOLECULE_VERSION molecule + fi + + if [[ $YAMLLINT_VERSION == '' ]] || [[ $YAMLLINT_VERSION == 'default' ]]; then + if [[ -f $YAMLLINT_VERSION_FILE ]]; then + YAMLLINT_VERSION=$(<$YAMLLINT_VERSION_FILE) + fi + if [[ $YAMLLINT_VERSION == '' ]]; then + query_latest_package_version YAMLLINT_VERSION yamllint + fi + elif [[ $YAMLLINT_VERSION == 'latest' ]]; then + query_latest_package_version YAMLLINT_VERSION yamllint + fi + + if [[ $ANSIBLE_LINT_VERSION == '' ]] || [[ $ANSIBLE_LINT_VERSION == 'default' ]]; then + if [[ -f $ANSIBLE_LINT_VERSION_FILE ]]; then + ANSIBLE_LINT_VERSION=$(<$ANSIBLE_LINT_VERSION_FILE) + fi + if [[ $ANSIBLE_LINT_VERSION == '' ]]; then + query_latest_package_version ANSIBLE_LINT_VERSION ansible-lint + fi + elif [[ $ANSIBLE_LINT_VERSION == 'latest' ]]; then + query_latest_package_version ANSIBLE_LINT_VERSION ansible-lint + fi + + if [[ $FLAKE8_VERSION == '' ]] || [[ $FLAKE8_VERSION == 'default' ]]; then + if [[ -f $FLAKE8_VERSION_FILE ]]; then + FLAKE8_VERSION=$(<$FLAKE8_VERSION_FILE) + fi + if [[ $FLAKE8_VERSION == '' ]]; then + query_latest_package_version FLAKE8_VERSION flake8 + fi + elif [[ $FLAKE8_VERSION == 'latest' ]]; then + query_latest_package_version FLAKE8_VERSION flake8 + fi + + if [[ $TESTINFRA_VERSION == '' ]] || [[ $TESTINFRA_VERSION == 'default' ]]; then + if [[ -f $TESTINFRA_VERSION_FILE ]]; then + TESTINFRA_VERSION=$(<$TESTINFRA_VERSION_FILE) + fi + if [[ $TESTINFRA_VERSION == '' ]]; then + query_latest_package_version TESTINFRA_VERSION testinfra + fi + elif [[ $TESTINFRA_VERSION == 'latest' ]]; then + query_latest_package_version TESTINFRA_VERSION testinfra + fi +} + +activate_virtualenv() { + detemine_versions + + MOLECULE_WRAPPER_ENV="$HOME/.moleculew/ml-${MOLECULE_VERSION}_an-${ANSIBLE_VERSION}_py-${PYTHON_VERSION}_dk-${DOCKER_LIB_VERSION}_yl-${YAMLLINT_VERSION}_al-${ANSIBLE_LINT_VERSION}_f8-${FLAKE8_VERSION}_ti-${TESTINFRA_VERSION}" + + if [ ! -f "$MOLECULE_WRAPPER_ENV/bin/activate" ]; then + + build_dependencies_present + + docker_present + + python_present + + virtualenv_presant + + banner "Initializing virtualenv $MOLECULE_WRAPPER_ENV" + virtualenv "--python=$PYTHON_EXE" "$MOLECULE_WRAPPER_ENV" + # shellcheck disable=SC1090 + source "$MOLECULE_WRAPPER_ENV/bin/activate" + echo '' + + install_ansible + + install_docker_lib + + install_molecule + + install_yamllint + + install_ansible_lint + + install_flake8 + + install_testinfra + else + # shellcheck disable=SC1090 + source "$MOLECULE_WRAPPER_ENV/bin/activate" + fi +} + +parse_args "$@" + +case $MOLECULE_CMD in + wrapper-clean) + wrapper_clean + ;; + wrapper-freeze) + wrapper_freeze + ;; + wrapper-help) + wrapper_help + ;; + wrapper-install) + activate_virtualenv + ;; + wrapper-options-ansible) + wrapper_options_ansible + ;; + wrapper-options-docker-lib) + wrapper_options_docker_lib + ;; + wrapper-options-molecule) + wrapper_options_molecule + ;; + wrapper-options-python) + wrapper_options_python + ;; + wrapper-options-yamllint) + wrapper_options_yamllint + ;; + wrapper-options-ansible-lint) + wrapper_options_ansible_lint + ;; + wrapper-options-flake8) + wrapper_options_flake8 + ;; + wrapper-options-testinfra) + wrapper_options_testinfra + ;; + wrapper-options-scenario) + wrapper_options_scenario + ;; + wrapper-unfreeze) + wrapper_unfreeze + ;; + wrapper-upgrade) + wrapper_upgrade + ;; + wrapper-upgrade-versions) + wrapper_upgrade_versions + ;; + wrapper-version) + wrapper_version + ;; + wrapper-versions) + wrapper_versions + ;; + wrapper-virtualenv) + wrapper_virtualenv + ;; + wrapper-*) + echo "Unsupported command: $1" >&2 + exit 1 + ;; + *) + activate_virtualenv + + # shellcheck disable=SC2086 + exec molecule "${PRE_ARGS[@]}" $MOLECULE_CMD "${POST_ARGS[@]}" + ;; +esac diff --git a/roles/gantsign.ctop/tasks/main.yml b/roles/gantsign.ctop/tasks/main.yml new file mode 100644 index 00000000..d14549ca --- /dev/null +++ b/roles/gantsign.ctop/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: create download directory + file: + state: directory + mode: 'u=rwx,go=rx' + dest: '{{ ctop_download_dir }}' + +- name: download ctop + get_url: + url: '{{ ctop_mirror }}/{{ ctop_redis_filename }}' + dest: '{{ ctop_download_dir }}/{{ ctop_redis_filename }}' + checksum: 'sha256:{{ ctop_redis_sha256sum }}' + mode: 'u=rw,go=r' + +- name: create the ctop installation dir + become: yes + file: + state: directory + owner: root + group: root + mode: 'u=rwx,go=rx' + dest: '{{ ctop_install_dir }}' + +- name: install ctop + become: yes + copy: + src: '{{ ctop_download_dir }}/{{ ctop_redis_filename }}' + remote_src: yes + dest: '{{ ctop_install_path }}' + force: yes + mode: 'u=rwx,go=rx' diff --git a/roles/gantsign.ctop/vars/main.yml b/roles/gantsign.ctop/vars/main.yml new file mode 100644 index 00000000..aecd432b --- /dev/null +++ b/roles/gantsign.ctop/vars/main.yml @@ -0,0 +1,18 @@ +--- +# Dir where ctop should be installed +ctop_install_dir: '/usr/local/bin' + +# Path where ctop should be installed +ctop_install_path: '{{ ctop_install_dir }}/ctop' + +# Mirror to download the ctop from +ctop_mirror: 'https://github.com/bcicen/ctop/releases/download/{{ ctop_version }}' + +# The OS of the ctop redistributable +ctop_os: 'linux' + +# The CPU architecture of the ctop redistributable +ctop_architecture: 'amd64' + +# File name of the ctop redistributable file +ctop_redis_filename: 'ctop-{{ ctop_version }}-{{ ctop_os }}-{{ ctop_architecture }}'