delete dead code

This commit is contained in:
Nick Sweeting 2024-09-24 15:26:43 -07:00
parent 97695bda5e
commit 7ffb81f61b
No known key found for this signature in database
19 changed files with 345 additions and 689 deletions

View file

@ -0,0 +1,31 @@
---
argument_specs:
main:
short_description: Load a specified binary from the environment/PATH into BINARIES fact.
options:
name:
type: "str"
required: true
description: "A string key for the binary"
bin_name:
type: "str"
required: false
description: "The basename of the binary file (optional, defaults to name)"
abspath:
type: "str"
required: false
description: "An absolute path to the binary (overrides any auto-detected one)"
version_cmd:
type: "str"
required: false
description: "The command to run to get the binary's version (optional, defaults to $ <bin_name> --version)"
PATH:
type: "str"
required: false
description: "The PATH to search for the binary (optional, defaults to environment $PATH)"

View file

@ -0,0 +1,75 @@
---
- name: Make sure ./data/lib/bin folder exists
file:
path: '{{LIB_DIR_BIN}}'
state: directory
recurse: true
###################################################################################
- set_fact:
PATH: "{{PATH or DEFAULT_PATH}}"
bin_name: "{{bin_name or name}}"
BINARY_ABSPATH: null
BINARY_VERSION: null
- name: 'Get installed binary abspath: {{name}}'
command: 'env PATH="{{PATH}}:$PATH" which {{bin_name}}'
register: BINARY_ABSPATH
changed_when: False
- set_fact:
bin_name: "{{BINARY_ABSPATH.stdout|basename or bin_name}}"
- set_fact:
version_cmd: "{{version_cmd or (bin_name + ' --version')}}"
- name: 'Get installed binary version: {{name}}'
command: 'env PATH="{{PATH}}:$PATH" {{version_cmd}}'
register: BINARY_VERSION
changed_when: False
- name: 'Updating BINARIES with loaded abspaths & versions: {{name}}'
set_fact:
BINARIES: "{{
BINARIES
| default({})
| combine({
name: {
'name': name,
'bin_name': bin_name,
'version_cmd': version_cmd,
'symlink': LIB_DIR_BIN + '/' + name,
'abspath': BINARY_ABSPATH.stdout or abspath or None,
'version': BINARY_VERSION.stdout_lines|first|regex_replace('^.*?([\\d+\\.]+).*$', '\\1') or version or None,
'version_stdout': BINARY_VERSION.stdout or BINARY_VERSION.stderr,
'PATH': BINARY_ABSPATH.stdout|dirname or PATH,
},
})
}}"
cacheable: true
changed_when: True
- name: 'Symlink installed binary into lib bin folder: {{name}}'
file:
src: "{{ BINARY_ABSPATH.stdout }}"
dest: "{{ LIB_DIR_BIN }}/{{ name }}"
state: link
force: true
when: BINARY_VERSION.stdout_lines|first|regex_replace('^.*?([\\d+\\.]+).*$', '\\1')|length
- debug:
msg:
- '{{BINARIES}}'
- name: Unset variables
set_fact:
name:
bin_name:
version_cmd:
abspath:
version:
PATH:
BINARY_ABSPATH:
BINARY_VERSION:

View file

@ -0,0 +1,12 @@
DATA_DIR: '{{playbook_dir}}'
LIB_DIR: '{{DATA_DIR}}/lib'
LIB_DIR_BIN: '{{LIB_DIR}}/bin'
DEFAULT_PATH: /bin
name:
bin_name:
version_cmd:
PATH:
abspath:
version: