fix singlefile and puppeteer ansible install

This commit is contained in:
Nick Sweeting 2024-09-17 01:33:32 -07:00
parent 5c0aa6fe59
commit 7ab1a0b873
No known key found for this signature in database
6 changed files with 39 additions and 31 deletions

View file

@ -17,7 +17,7 @@
- name: 'Get installed binary abspath: {{name}}'
command: 'env PATH="{{PATH}}:$PATH" which {{bin_name}}'
register: BINARY_ABSPATH
changed_when: BINARIES[name].abspath|default('NO VERSION FOUND') not in BINARY_ABSPATH.stdout
changed_when: False
- set_fact:
bin_name: "{{BINARY_ABSPATH.stdout|basename or bin_name}}"
@ -27,7 +27,7 @@
- name: 'Get installed binary version: {{name}}'
command: 'env PATH="{{PATH}}:$PATH" {{version_cmd}}'
register: BINARY_VERSION
changed_when: BINARIES[name].version|default('NO VERSION FOUND') not in BINARY_VERSION.stdout
changed_when: False
- name: 'Updating BINARIES with loaded abspaths & versions: {{name}}'
@ -49,7 +49,7 @@
})
}}"
cacheable: true
when: BINARY_ABSPATH.stdout and BINARY_VERSION.stdout
changed_when: True
- name: 'Symlink installed binary into lib bin folder: {{name}}'
file:
@ -57,8 +57,7 @@
dest: "{{ LIB_DIR_BIN }}/{{ name }}"
state: link
force: true
when: BINARY_ABSPATH.stdout and BINARY_VERSION.stdout
changed_when: False
when: BINARY_VERSION.stdout_lines|first|regex_replace('^.*?([\\d+\\.]+).*$', '\\1')|length
- debug:
msg:
@ -69,6 +68,8 @@
name:
bin_name:
version_cmd:
abspath:
version:
PATH:
BINARY_ABSPATH:
BINARY_VERSION:

View file

@ -1,4 +1,5 @@
DATA_DIR: '{{playbook_dir}}'
LIB_DIR: '{{DATA_DIR}}/lib'
LIB_DIR_BIN: '{{LIB_DIR}}/bin'
DEFAULT_PATH: /bin

View file

@ -1,7 +1,9 @@
DATA_DIR: '{{playbook_dir}}'
LIB_DIR: '{{DATA_DIR}}/lib'
LIB_DIR_BIN: '{{LIB_DIR}}/bin'
LIB_DIR_NPM: '{{LIB_DIR}}/npm'
LIB_DIR_NPM_BIN: '{{LIB_DIR_NPM}}/node_modules/.bin'
MIN_NODE_VERSION: '20.0.0'
MIN_NPM_VERSION: '10.0.0'

View file

@ -1,7 +1,9 @@
DATA_DIR: '{{playbook_dir}}'
LIB_DIR: '{{DATA_DIR}}/lib'
LIB_DIR_BIN: '{{LIB_DIR}}/bin'
LIB_DIR_PIP: '{{LIB_DIR}}/pip'
LIB_DIR_PIP_BIN: '{{LIB_DIR_PIP}}/venv/bin'
MIN_PYTHON_VERSION: '3.10.0'
MIN_PIP_VERSION: '22.0'

View file

@ -4,6 +4,7 @@
hosts: localhost
gather_facts: true
vars:
DATA_DIR: '{{playbook_dir}}'
LIB_DIR: '{{DATA_DIR}}/lib'
LIB_DIR_BIN: '{{LIB_DIR}}/bin'
LIB_DIR_BROWSERS: '{{LIB_DIR}}/browsers'
@ -38,31 +39,29 @@
name: puppeteer
PATH: '{{BINPROVIDERS.npm.PATH}}'
- name: Load chrome binaries from environment PATH
include_tasks: roles/load_binary/tasks/main.yml
vars:
name: 'chrome'
bin_name: '{{chrome_executable}}'
PATH: '{{ansible_env.PATH}}'
with_items:
- chrome
# - chrome-browser
# - chromium
# - chromium-browser
# - google-chrome
# - google-chrome-browser
# - google-chrome-stable
# - google-chrome-beta
# - google-chrome-canary
# - google-chrome-unstable
# - google-chrome-dev
loop_control:
loop_var: chrome_executable
# break_when:
# - BINARIES.chrome.version|default('')
# - debug:
# msg: "{{ {'BINARIES': BINARIES, 'BINPROVIDERS': BINPROVIDERS} }}"
# - name: Load chrome binaries from environment PATH
# include_role:
# name: load_binary
# vars:
# name: 'chrome'
# bin_name: '{{chrome_executable}}'
# PATH: '{{ansible_env.PATH}}'
# loop:
# - chrome
# - chrome-browser
# - chromium
# - chromium-browser
# - google-chrome
# - google-chrome-browser
# - google-chrome-stable
# - google-chrome-beta
# - google-chrome-canary
# - google-chrome-unstable
# - google-chrome-dev
# loop_control:
# loop_var: chrome_executable
# break_when:
# - BINARIES.chrome.version|default('')
###################################################################################
@ -101,12 +100,15 @@
- set_fact:
PUPPETEER_BINARIES:
chrome:
name: 'chrome'
bin_name: 'chrome'
abspath: "{{CHROME_ABSPATH|default(BINARIES.chrome.abspath) or None}}"
version: "{{CHROME_VERSION|default(BINARIES.chrome.version) or None}}"
symlink: "{{LIB_DIR_BIN}}/chrome"
version_cmd: "chrome --version"
version_stdout: "{{CHROME_VERSION_FULL.stdout}}"
binprovider: 'puppeteer'
PATH: "{{LIB_DIR_BIN}}"
- name: Check that installed Chrome matches expected version
assert:

View file

@ -20,7 +20,7 @@
community.general.npm:
name: 'single-file-cli@1.1.54'
state: "present"
path: '{{BINPROVIDERS.npm.root_path}}'
path: '{{BINPROVIDERS.npm.lib_dir_npm}}'
- name: Load single-file binary from installed NPM package
include_role: