From 5d6690b70def73cc18d9a6294db1d3127b009087 Mon Sep 17 00:00:00 2001 From: ellaqezi Date: Mon, 2 Apr 2018 00:21:37 +0200 Subject: [PATCH 1/8] Add Ansible section * syntax check on first yml found, tasks|hosts|roles =~ valid ansible file * set show version to false by default * updated docs --- README.md | 1 + docs/Options.md | 15 +++++++++++++ docs/README.md | 1 + docs/Troubleshooting.md | 1 + sections/ansible.zsh | 47 +++++++++++++++++++++++++++++++++++++++++ spaceship.zsh | 1 + 6 files changed, 66 insertions(+) create mode 100644 sections/ansible.zsh diff --git a/README.md b/README.md index 3f458be3e..605c3d27b 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ Spaceship is a minimalistic, powerful and extremely customizable [Zsh][zsh-url] - Current version of Haskell GHC Compiler, defined in stack.yaml file (`ฮป`). - Current Julia version (`เฎƒ`). - Current Docker version and connected machine (`๐Ÿณ`). +- Current Ansible version (`๐Ÿ…`). - Current Amazon Web Services (AWS) profile (`โ˜๏ธ`) ([Using named profiles](http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html)). - Current Python virtualenv. - Current Conda virtualenv (`๐Ÿ…’`). diff --git a/docs/Options.md b/docs/Options.md index 729bde104..164e7a87f 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -34,6 +34,7 @@ SPACESHIP_PROMPT_ORDER=( haskell # Haskell Stack section julia # Julia section docker # Docker section + ansible # Ansible section aws # Amazon Web Services section venv # virtualenv section conda # conda virtualenv section @@ -405,6 +406,20 @@ The environment variable `COMPOSE_PATH_SEPARATOR` is supported too. For more inf | `SPACESHIP_DOCKER_COLOR` | `cyan` | Color of Docker section | | `SPACESHIP_DOCKER_VERBOSE` | `false` | Show complete Docker version | +### Ansible (`ansible`) + +Ansible section is shown only in directories that contain valid ansible playbooks or `[.]ansible.cfg` files. Please be aware +that switching on the option to display the ansible version causes some delay. + +| Variable | Default | Meaning | +| :------- | :-----: | ------- | +| `SPACESHIP_ANSIBLE_SHOW` | `true` | Show Ansible section | +| `SPACESHIP_ANSIBLE_SHOW_VERSION` | `false` | Show current Ansible version | +| `SPACESHIP_ANSIBLE_PREFIX` | `$SPACESHIP_PROMPT_DEFAULT_PREFIX` | Prefix before the Ansible section | +| `SPACESHIP_ANSIBLE_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Suffix after the Ansible section | +| `SPACESHIP_ANSIBLE_SYMBOL` | `๐Ÿ…ยท` | Character to be shown before Ansible version | +| `SPACESHIP_ANSIBLE_COLOR` | `white` | Color of Ansible section | + ### Amazon Web Services (AWS) (`aws`) Shows selected Amazon Web Services profile configured using [`AWS_PROFILE`](http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html) variable. diff --git a/docs/README.md b/docs/README.md index ab1dec872..67115fae8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -28,6 +28,7 @@ * [Haskell (haskell)](/docs/Options.md#haskell-haskell) * [Julia (julia)](/docs/Options.md#julia-julia) * [Docker (docker)](/docs/Options.md#docker-docker) + * [Ansible (ansible)](/docs/Options.md#ansible-ansible) * [Amazon Web Services (aws)](/docs/Options.md#amazon-web-services-aws-aws) * [Virtualenv (venv)](/docs/Options.md#virtualenv-venv) * [Conda Virtualenv (conda)](/docs/Options.md#conda-virtualenv-conda) diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 57d9baa49..12c1c084e 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -65,6 +65,7 @@ SPACESHIP_PROMPT_ORDER=( haskell # Haskell Stack section # julia # Julia section (Disabled) # docker # Docker section (Disabled) + ansible # Ansible section aws # Amazon Web Services section venv # virtualenv section conda # conda virtualenv section diff --git a/sections/ansible.zsh b/sections/ansible.zsh new file mode 100644 index 000000000..5ae1a47ff --- /dev/null +++ b/sections/ansible.zsh @@ -0,0 +1,47 @@ +# +# Ansible +# +# Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks +# such as continuous deployments or zero downtime rolling updates. +# Link: https://docs.ansible.com/ansible/latest/index.html + +# ------------------------------------------------------------------------------ +# Configuration +# ------------------------------------------------------------------------------ + +SPACESHIP_ANSIBLE_SHOW="${SPACESHIP_ANSIBLE_SHOW=true}" +SPACESHIP_ANSIBLE_SHOW_VERSION="${SPACESHIP_ANSIBLE_SHOW_VERSION=false}" +SPACESHIP_ANSIBLE_PREFIX="${SPACESHIP_ANSIBLE_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" +SPACESHIP_ANSIBLE_SUFFIX="${SPACESHIP_ANSIBLE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" +SPACESHIP_ANSIBLE_SYMBOL="${SPACESHIP_ANSIBLE_SYMBOL="๐Ÿ…ยท"}" +SPACESHIP_ANSIBLE_COLOR="${SPACESHIP_ANSIBLE_COLOR="white"}" + +# ------------------------------------------------------------------------------ +# Section +# ------------------------------------------------------------------------------ + +# Show ansible status +# spaceship_ prefix before section's name is required! +# Otherwise this section won't be loaded. +spaceship_ansible() { + # If SPACESHIP_ANSIBLE_SHOW is false, don't show ansible section + [[ $SPACESHIP_ANSIBLE_SHOW == false ]] && return + + # Show ansible section only when there are ansible-specific files in current + # working directory. + # Here glob qualifiers are used to check if files with specific extension are + # present in directory. Read more about them here: + # https://zsh.sourceforge.net/Doc/Release/Expansion.html + YAML=$(echo ?(*.yml|*.yaml)([1]N^/)) + [[ -f ansible.cfg || -f .ansible.cfg || -f $YAML && $(grep -m 1 -E "tasks|hosts|roles" $YAML &> /dev/null) -eq 0 ]] || return + + # Retrieve ansible status and save it to variable + [[ ${SPACESHIP_ANSIBLE_SHOW_VERSION} = true ]] && ansible_status=`ansible --version 2>&1 | head -n 1 | tr -d ansible` + + # Display ansible section + spaceship::section \ + "$SPACESHIP_ANSIBLE_COLOR" \ + "$SPACESHIP_ANSIBLE_PREFIX" \ + "$SPACESHIP_ANSIBLE_SYMBOL$ansible_status" \ + "$SPACESHIP_ANSIBLE_SUFFIX" +} diff --git a/spaceship.zsh b/spaceship.zsh index 048a34f93..9ee2c4b37 100644 --- a/spaceship.zsh +++ b/spaceship.zsh @@ -59,6 +59,7 @@ if [ -z "$SPACESHIP_PROMPT_ORDER" ]; then haskell # Haskell Stack section julia # Julia section docker # Docker section + ansible # Ansible section aws # Amazon Web Services section venv # virtualenv section conda # conda virtualenv section From a183dcab7ac8e0566d5228d67314f322ccb3cf85 Mon Sep 17 00:00:00 2001 From: Salmanul Farzy Date: Sun, 25 Aug 2019 17:17:14 +0530 Subject: [PATCH 2/8] Fix whitespace --- docs/Options.md | 3 +-- sections/ansible.zsh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/Options.md b/docs/Options.md index 164e7a87f..3b4d7828e 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -408,8 +408,7 @@ The environment variable `COMPOSE_PATH_SEPARATOR` is supported too. For more inf ### Ansible (`ansible`) -Ansible section is shown only in directories that contain valid ansible playbooks or `[.]ansible.cfg` files. Please be aware -that switching on the option to display the ansible version causes some delay. +Ansible section is shown only in directories that contain valid ansible playbooks or `[.]ansible.cfg` files. Please be aware that switching on the option to display the ansible version causes some delay. | Variable | Default | Meaning | | :------- | :-----: | ------- | diff --git a/sections/ansible.zsh b/sections/ansible.zsh index 5ae1a47ff..a9aee9ed4 100644 --- a/sections/ansible.zsh +++ b/sections/ansible.zsh @@ -13,7 +13,7 @@ SPACESHIP_ANSIBLE_SHOW="${SPACESHIP_ANSIBLE_SHOW=true}" SPACESHIP_ANSIBLE_SHOW_VERSION="${SPACESHIP_ANSIBLE_SHOW_VERSION=false}" SPACESHIP_ANSIBLE_PREFIX="${SPACESHIP_ANSIBLE_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" SPACESHIP_ANSIBLE_SUFFIX="${SPACESHIP_ANSIBLE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" -SPACESHIP_ANSIBLE_SYMBOL="${SPACESHIP_ANSIBLE_SYMBOL="๐Ÿ…ยท"}" +SPACESHIP_ANSIBLE_SYMBOL="${SPACESHIP_ANSIBLE_SYMBOL="๐Ÿ… "}" SPACESHIP_ANSIBLE_COLOR="${SPACESHIP_ANSIBLE_COLOR="white"}" # ------------------------------------------------------------------------------ From c2dfd2dacada2114a18193d39d659c3312912529 Mon Sep 17 00:00:00 2001 From: Salmanul Farzy Date: Sun, 25 Aug 2019 17:19:31 +0530 Subject: [PATCH 3/8] Use Zsh splitting to get ansible version --- sections/ansible.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sections/ansible.zsh b/sections/ansible.zsh index a9aee9ed4..60b57ab11 100644 --- a/sections/ansible.zsh +++ b/sections/ansible.zsh @@ -36,7 +36,7 @@ spaceship_ansible() { [[ -f ansible.cfg || -f .ansible.cfg || -f $YAML && $(grep -m 1 -E "tasks|hosts|roles" $YAML &> /dev/null) -eq 0 ]] || return # Retrieve ansible status and save it to variable - [[ ${SPACESHIP_ANSIBLE_SHOW_VERSION} = true ]] && ansible_status=`ansible --version 2>&1 | head -n 1 | tr -d ansible` + [[ ${SPACESHIP_ANSIBLE_SHOW_VERSION} = true ]] && ansible_status=${$(ansible --version)[2]} # Display ansible section spaceship::section \ From d16ff95b227d5efbbd8872dbae6c2715296d50f7 Mon Sep 17 00:00:00 2001 From: ellaqezi Date: Thu, 29 Aug 2019 23:26:00 +0200 Subject: [PATCH 4/8] evaluate yamls only if .cfg files don't exist --- sections/ansible.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sections/ansible.zsh b/sections/ansible.zsh index 60b57ab11..fdbf344f0 100644 --- a/sections/ansible.zsh +++ b/sections/ansible.zsh @@ -32,8 +32,7 @@ spaceship_ansible() { # Here glob qualifiers are used to check if files with specific extension are # present in directory. Read more about them here: # https://zsh.sourceforge.net/Doc/Release/Expansion.html - YAML=$(echo ?(*.yml|*.yaml)([1]N^/)) - [[ -f ansible.cfg || -f .ansible.cfg || -f $YAML && $(grep -m 1 -E "tasks|hosts|roles" $YAML &> /dev/null) -eq 0 ]] || return + [[ -f ansible.cfg || -f .ansible.cfg || -f $(echo ?(*.yml|*.yaml)([1]N^/)) && $(grep -m 1 -E "tasks|hosts|roles" $(echo ?(*.yml|*.yaml)) &> /dev/null) -eq 0 ]] || return # Retrieve ansible status and save it to variable [[ ${SPACESHIP_ANSIBLE_SHOW_VERSION} = true ]] && ansible_status=${$(ansible --version)[2]} From efb6bc6caaab50977d77541541fb55172e1119bc Mon Sep 17 00:00:00 2001 From: Denys Dovhan Date: Tue, 8 Nov 2022 21:15:19 +0200 Subject: [PATCH 5/8] refactor(ansible): Update to v4 --- sections/ansible.zsh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sections/ansible.zsh b/sections/ansible.zsh index fdbf344f0..5173308c9 100644 --- a/sections/ansible.zsh +++ b/sections/ansible.zsh @@ -1,8 +1,7 @@ # # Ansible # -# Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks -# such as continuous deployments or zero downtime rolling updates. +# Ansible is an IT automation tool. # Link: https://docs.ansible.com/ansible/latest/index.html # ------------------------------------------------------------------------------ @@ -10,6 +9,7 @@ # ------------------------------------------------------------------------------ SPACESHIP_ANSIBLE_SHOW="${SPACESHIP_ANSIBLE_SHOW=true}" +SPACESHIP_ANSIBLE_ASYNC="${SPACESHIP_ANSIBLE_ASYNC=true}" SPACESHIP_ANSIBLE_SHOW_VERSION="${SPACESHIP_ANSIBLE_SHOW_VERSION=false}" SPACESHIP_ANSIBLE_PREFIX="${SPACESHIP_ANSIBLE_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" SPACESHIP_ANSIBLE_SUFFIX="${SPACESHIP_ANSIBLE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" @@ -20,11 +20,7 @@ SPACESHIP_ANSIBLE_COLOR="${SPACESHIP_ANSIBLE_COLOR="white"}" # Section # ------------------------------------------------------------------------------ -# Show ansible status -# spaceship_ prefix before section's name is required! -# Otherwise this section won't be loaded. spaceship_ansible() { - # If SPACESHIP_ANSIBLE_SHOW is false, don't show ansible section [[ $SPACESHIP_ANSIBLE_SHOW == false ]] && return # Show ansible section only when there are ansible-specific files in current @@ -32,15 +28,20 @@ spaceship_ansible() { # Here glob qualifiers are used to check if files with specific extension are # present in directory. Read more about them here: # https://zsh.sourceforge.net/Doc/Release/Expansion.html - [[ -f ansible.cfg || -f .ansible.cfg || -f $(echo ?(*.yml|*.yaml)([1]N^/)) && $(grep -m 1 -E "tasks|hosts|roles" $(echo ?(*.yml|*.yaml)) &> /dev/null) -eq 0 ]] || return + local yaml_files="$(echo ?(*.yml|*.yaml)([1]N^/))" + local detected_playbooks="$(spaceship::grep -m 1 -E "tasks|hosts|roles" $yaml_files 2> /dev/null)" + local ansible_configs="$(spaceship::upsearch ansible.cfg .ansible.cfg)" - # Retrieve ansible status and save it to variable - [[ ${SPACESHIP_ANSIBLE_SHOW_VERSION} = true ]] && ansible_status=${$(ansible --version)[2]} + [[ -n "$ansible_configs" || -n "$detected_playbooks" ]] || return + + # Retrieve ansible version + local ansible_version=$(ansible --version | head -1 | spaceship::grep -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]') # Display ansible section spaceship::section \ - "$SPACESHIP_ANSIBLE_COLOR" \ - "$SPACESHIP_ANSIBLE_PREFIX" \ - "$SPACESHIP_ANSIBLE_SYMBOL$ansible_status" \ - "$SPACESHIP_ANSIBLE_SUFFIX" + --color "$SPACESHIP_ANSIBLE_COLOR" \ + --prefix "$SPACESHIP_ANSIBLE_PREFIX" \ + --suffix "$SPACESHIP_ANSIBLE_SUFFIX" \ + --symbol "$SPACESHIP_ANSIBLE_SYMBOL" \ + "$ansible_version" } From 2ee16cd08fc7fe33875a0d6b0db017a5c012fcd3 Mon Sep 17 00:00:00 2001 From: Denys Dovhan Date: Tue, 8 Nov 2022 21:45:39 +0200 Subject: [PATCH 6/8] refactor(ansible): fix some problems --- sections/ansible.zsh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sections/ansible.zsh b/sections/ansible.zsh index 5173308c9..db4e31e37 100644 --- a/sections/ansible.zsh +++ b/sections/ansible.zsh @@ -1,7 +1,7 @@ # # Ansible # -# Ansible is an IT automation tool. +# Ansible is a suite of software tools that enables infrastructure as code. # Link: https://docs.ansible.com/ansible/latest/index.html # ------------------------------------------------------------------------------ @@ -10,7 +10,6 @@ SPACESHIP_ANSIBLE_SHOW="${SPACESHIP_ANSIBLE_SHOW=true}" SPACESHIP_ANSIBLE_ASYNC="${SPACESHIP_ANSIBLE_ASYNC=true}" -SPACESHIP_ANSIBLE_SHOW_VERSION="${SPACESHIP_ANSIBLE_SHOW_VERSION=false}" SPACESHIP_ANSIBLE_PREFIX="${SPACESHIP_ANSIBLE_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" SPACESHIP_ANSIBLE_SUFFIX="${SPACESHIP_ANSIBLE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" SPACESHIP_ANSIBLE_SYMBOL="${SPACESHIP_ANSIBLE_SYMBOL="๐Ÿ… "}" @@ -23,14 +22,21 @@ SPACESHIP_ANSIBLE_COLOR="${SPACESHIP_ANSIBLE_COLOR="white"}" spaceship_ansible() { [[ $SPACESHIP_ANSIBLE_SHOW == false ]] && return + # Check if ansible is installed + spaceship::exists ansible || return + # Show ansible section only when there are ansible-specific files in current # working directory. # Here glob qualifiers are used to check if files with specific extension are # present in directory. Read more about them here: # https://zsh.sourceforge.net/Doc/Release/Expansion.html - local yaml_files="$(echo ?(*.yml|*.yaml)([1]N^/))" - local detected_playbooks="$(spaceship::grep -m 1 -E "tasks|hosts|roles" $yaml_files 2> /dev/null)" local ansible_configs="$(spaceship::upsearch ansible.cfg .ansible.cfg)" + local yaml_files="$(echo ?(*.yml|*.yaml)([1]N^/))" + local detected_playbooks + + if [[ -n "$yaml_files" ]]; then + detected_playbooks="$(spaceship::grep -oE "tasks|hosts|roles" $yaml_files)" + fi [[ -n "$ansible_configs" || -n "$detected_playbooks" ]] || return @@ -43,5 +49,5 @@ spaceship_ansible() { --prefix "$SPACESHIP_ANSIBLE_PREFIX" \ --suffix "$SPACESHIP_ANSIBLE_SUFFIX" \ --symbol "$SPACESHIP_ANSIBLE_SYMBOL" \ - "$ansible_version" + "v$ansible_version" } From 3bad5cdcb409cbb5981d129016b2ecfff647df35 Mon Sep 17 00:00:00 2001 From: Denys Dovhan Date: Tue, 8 Nov 2022 21:45:57 +0200 Subject: [PATCH 7/8] test(ansible): Add tests for ansible --- tests/ansible.test.zsh | 108 +++++++++++++++++++++++++++++++++++++++++ tests/stubs/ansible | 11 +++++ 2 files changed, 119 insertions(+) create mode 100755 tests/ansible.test.zsh create mode 100755 tests/stubs/ansible diff --git a/tests/ansible.test.zsh b/tests/ansible.test.zsh new file mode 100755 index 000000000..00146c771 --- /dev/null +++ b/tests/ansible.test.zsh @@ -0,0 +1,108 @@ +#!/usr/bin/env zsh + +# Required for shunit2 to run correctly +setopt shwordsplit +SHUNIT_PARENT=$0 + +# ------------------------------------------------------------------------------ +# SHUNIT2 HOOKS +# ------------------------------------------------------------------------------ + +oneTimeSetUp() { + export TERM="xterm-256color" + export PATH=$PWD/tests/stubs:$PATH + + ANSIBLE_VERSION="2.13.5" + + SPACESHIP_PROMPT_ASYNC=false + SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true + SPACESHIP_PROMPT_ADD_NEWLINE=false + SPACESHIP_PROMPT_ORDER=(ansible) + + source "spaceship.zsh" +} + +setUp() { + SPACESHIP_ANSIBLE_SHOW="true" + SPACESHIP_ANSIBLE_PREFIX="via " + SPACESHIP_ANSIBLE_SUFFIX="" + SPACESHIP_ANSIBLE_SYMBOL="๐Ÿ… " + SPACESHIP_ANSIBLE_COLOR="white" + + cd $SHUNIT_TMPDIR +} + +oneTimeTearDown() { + unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW + unset SPACESHIP_PROMPT_ADD_NEWLINE + unset SPACESHIP_PROMPT_ORDER +} + +tearDown() { + unset SPACESHIP_ANSIBLE_SHOW + unset SPACESHIP_ANSIBLE_PREFIX + unset SPACESHIP_ANSIBLE_SUFFIX + unset SPACESHIP_ANSIBLE_SYMBOL + unset SPACESHIP_ANSIBLE_COLOR +} + +# ------------------------------------------------------------------------------ +# TEST CASES +# ------------------------------------------------------------------------------ + +test_ansible_no_files() { + local no_files_expected="" + local no_files_actual="$(spaceship::testkit::render_prompt)" + assertEquals "should not render without files" "$no_files_expected" "$no_files_actual" +} + +test_ansible_configs() { + FILES=(ansible.cfg .ansible.cfg) + for file in $FILES; do + touch $file + local expected=( + "%{%B%}$SPACESHIP_ANSIBLE_PREFIX%{%b%}" + "%{%B%F{$SPACESHIP_ANSIBLE_COLOR}%}" + "${SPACESHIP_ANSIBLE_SYMBOL}" + "v$ANSIBLE_VERSION%{%b%f%}" + ) + local actual="$(spaceship::testkit::render_prompt)" + assertEquals "should render with $file" "${(j::)expected}" "$actual" + rm $file + done +} + +test_ansible_playbooks() { + FILES=(playbook.yml playbook.yaml) + for file in $FILES; do + touch $file + echo "tasks: []" > $file + local expected=( + "%{%B%}$SPACESHIP_ANSIBLE_PREFIX%{%b%}" + "%{%B%F{$SPACESHIP_ANSIBLE_COLOR}%}" + "${SPACESHIP_ANSIBLE_SYMBOL}" + "v$ANSIBLE_VERSION%{%b%f%}" + ) + local actual="$(spaceship::testkit::render_prompt)" + assertEquals "should render with $file" "${(j::)expected}" "$actual" + rm $file + done +} + +test_ansible_yml_files() { + FILES=(regular.yml regular.yaml) + for file in $FILES; do + touch $file + local expected="" + local actual="$(spaceship::testkit::render_prompt)" + assertEquals "should render with $file" "$expected" "$actual" + rm $file + done +} + +# ------------------------------------------------------------------------------ +# SHUNIT2 +# Run tests with shunit2 +# ------------------------------------------------------------------------------ + +source tests/shunit2/shunit2 diff --git a/tests/stubs/ansible b/tests/stubs/ansible new file mode 100755 index 000000000..2f3505016 --- /dev/null +++ b/tests/stubs/ansible @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +echo "ansible [core 2.13.5]" +echo " config file = None" +echo " configured module search path = ['path/to/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']" +echo " ansible python module location = /opt/homebrew/Cellar/ansible/6.5.0/libexec/lib/python3.10/site-packages/ansible" +echo " ansible collection location = path/to/.ansible/collections:/usr/share/ansible/collections" +echo " executable location = /opt/homebrew/bin/ansible" +echo " python version = 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]" +echo " jinja version = 3.1.2" +echo " libyaml = True" From af8b2b0e28e94a5867e691534d1aba4fb324b316 Mon Sep 17 00:00:00 2001 From: Denys Dovhan Date: Tue, 8 Nov 2022 21:46:17 +0200 Subject: [PATCH 8/8] docs(ansible): Add docs for ansible --- docs/config/prompt.md | 1 + docs/registry/internal.json | 6 ++++++ docs/sections/ansible.md | 24 ++++++++++++++++++++++++ mkdocs.yml | 1 + 4 files changed, 32 insertions(+) create mode 100644 docs/sections/ansible.md diff --git a/docs/config/prompt.md b/docs/config/prompt.md index b3ae4f4d2..a2bd34a74 100644 --- a/docs/config/prompt.md +++ b/docs/config/prompt.md @@ -74,6 +74,7 @@ SPACESHIP_PROMPT_ORDER=( dotnet # .NET section ocaml # OCaml section kubectl # Kubectl context section + ansible # Ansible section terraform # Terraform workspace section pulumi # Pulumi stack section ibmcloud # IBM Cloud section diff --git a/docs/registry/internal.json b/docs/registry/internal.json index 74a3372b8..390416a44 100644 --- a/docs/registry/internal.json +++ b/docs/registry/internal.json @@ -324,6 +324,12 @@ "url": "https://spaceship-prompt.sh/sections/pulumi", "description": "The current Pulumi stack.", "internal": true + }, + { + "name": "ansible", + "url": "https://spaceship-prompt.sh/sections/ansible", + "description": "The current Ansible version.", + "internal": true } ] } diff --git a/docs/sections/ansible.md b/docs/sections/ansible.md new file mode 100644 index 000000000..1c78d383c --- /dev/null +++ b/docs/sections/ansible.md @@ -0,0 +1,24 @@ +# Ansible (`ansible`) + +!!! important "This section is rendered asynchronously by default" + +!!! info + [**Ansible**](https://www.ansible.com/) is a suite of software tools that enables infrastructure as code. + +The `ansible` section shows Ansible version. + +This section is only displayed when you have a `ansible` command available and: + +* Upsearch finds a `ansible.cfg` or `.ansible.cfg` file +* Current directory contains a file with `.yml`, `.yaml` extensions containing ansible playbooks. + +## Options + +| Variable | Default | Meaning | +| :------------------------ | :--------------------------------: | ----------------------------------- | +| `SPACESHIP_ANSIBLE_SHOW` | `true` | Show section | +| `SPACESHIP_ANSIBLE_ASYNC` | `true` | Render section asynchronously | +| `SPACESHIP_ANSIBLE_PREFIX` | `$SPACESHIP_PROMPT_DEFAULT_PREFIX` | Section's prefix | +| `SPACESHIP_ANSIBLE_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Section's suffix | +| `SPACESHIP_ANSIBLE_SYMBOL` | `๐Ÿ… ` | Symbol displayed before the section | +| `SPACESHIP_ANSIBLE_COLOR` | `white` | Section's color | diff --git a/mkdocs.yml b/mkdocs.yml index 8cc035967..fbcd76a99 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -91,6 +91,7 @@ nav: - .NET (dotnet): sections/dotnet.md - OCaml (ocaml): sections/ocaml.md - Kubernetes (kubectl): sections/kubectl.md + - Ansible (Ansible): sections/ansible.md - Terraform (terraform): sections/terraform.md - Pulumi (pulumi): sections/pulumi.md - IBM Cloud (ibmcloud): sections/ibmcloud.md