mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 07:04:27 -04:00
consolidate ansible setup into roles dir
This commit is contained in:
parent
25db6826ec
commit
c55cd46ecb
27 changed files with 763 additions and 91 deletions
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: Main entry point for the npm role
|
||||
|
||||
options:
|
||||
|
||||
state:
|
||||
type: "str"
|
||||
required: false
|
||||
default: 'present'
|
||||
description:
|
||||
- "The desired state: present | latest"
|
||||
|
||||
npm_packages:
|
||||
type: "list"
|
||||
elements: "dict"
|
||||
required: false
|
||||
default: []
|
||||
description: "A list of dicts with a defined structure and with default a value."
|
||||
options:
|
||||
key:
|
||||
type: "str"
|
||||
required: true
|
||||
description: "A string name for the dependency"
|
||||
|
||||
packages:
|
||||
type: "list"
|
||||
elements: "str"
|
||||
required: true
|
||||
description: "What npm packages to install for the given dependency."
|
59
archivebox/builtin_plugins/ansible/roles/setup_lib_npm/tasks/main.yml
Executable file
59
archivebox/builtin_plugins/ansible/roles/setup_lib_npm/tasks/main.yml
Executable file
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
- name: Make sure lib folders exist
|
||||
file:
|
||||
path: '{{item}}'
|
||||
state: directory
|
||||
recurse: true
|
||||
loop:
|
||||
- '{{LIB_DIR_NPM_BIN}}'
|
||||
- '{{LIB_DIR_BIN}}'
|
||||
|
||||
- name: "Install system packages: [node, npm]"
|
||||
ansible.builtin.package:
|
||||
name: "node"
|
||||
state: "present"
|
||||
|
||||
- name: Load NPM and Node binaries
|
||||
include_role:
|
||||
name: load_binary
|
||||
vars:
|
||||
name: '{{item}}'
|
||||
loop:
|
||||
- node
|
||||
- npm
|
||||
|
||||
- name: Check that installed Node version matches expected version
|
||||
assert:
|
||||
that:
|
||||
- BINARIES.node.version is version(MIN_NODE_VERSION, '>=')
|
||||
- BINARIES.npm.version is version(MIN_NPM_VERSION, '>=')
|
||||
quiet: true
|
||||
|
||||
###################################################################################
|
||||
|
||||
|
||||
# - name: "Install npm packages: {{install_npm}}"
|
||||
# community.general.npm:
|
||||
# name: '{{item}}'
|
||||
# state: "{{state}}"
|
||||
# path: '{{LIB_DIR_NPM}}'
|
||||
# loop: "{{install_npm|dictsort|map(attribute='1')|map(attribute='packages')|flatten}}"
|
||||
|
||||
###################################################################################
|
||||
|
||||
|
||||
###################################################################################
|
||||
- set_fact:
|
||||
NODE_BINPROVIDERS:
|
||||
npm:
|
||||
installer_abspath: "{{BINARIES.npm.abspath}}"
|
||||
installer_version: "{{BINARIES.npm.version}}"
|
||||
PATH: "{{LIB_DIR_NPM_BIN}}"
|
||||
lib_dir_npm: "{{LIB_DIR_NPM}}"
|
||||
|
||||
- set_fact:
|
||||
BINPROVIDERS: "{{ BINPROVIDERS | default({}) | combine(NODE_BINPROVIDERS) }}"
|
||||
cacheable: true
|
||||
|
||||
- debug:
|
||||
msg: "{{ {'BINARIES': BINARIES, 'BINPROVIDERS': BINPROVIDERS} }}"
|
|
@ -0,0 +1,7 @@
|
|||
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'
|
Loading…
Add table
Add a link
Reference in a new issue