move unused ansible folder

This commit is contained in:
Nick Sweeting 2024-09-27 00:39:55 -07:00
parent 7b6a491ae0
commit 6f7b6c6bde
No known key found for this signature in database
13 changed files with 0 additions and 0 deletions

View file

@ -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."

View file

@ -0,0 +1,99 @@
---
- name: Make sure lib folders exist
file:
path: '{{item}}'
state: directory
recurse: true
loop:
- '{{LIB_DIR_NPM_BIN}}'
- '{{LIB_DIR_BIN}}'
###################################################################################
- name: Ensure dependencies are present.
when: ansible_facts['os_family']|lower == 'debian'
ansible.builtin.apt:
name:
- apt-transport-https
- python3-debian
- gnupg2
state: present
- name: Download NodeSource's signing key.
# NodeSource's web server discriminates the User-Agent used by the deb822_repository module.
# https://github.com/nodesource/distributions/issues/1723
when: ansible_facts['os_family']|lower == 'debian'
ansible.builtin.get_url:
url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
dest: /etc/apt/signing-key-nodesource-repo.asc
owner: root
group: root
mode: '0444'
register: node_signing_key
- name: Add NodeSource repositories for Node.js.
when: ansible_facts['os_family']|lower == 'debian'
ansible.builtin.deb822_repository:
name: nodesource_{{ TARGET_NODE_VERSION }}
uris: "https://deb.nodesource.com/node_{{ TARGET_NODE_VERSION }}.x"
types: deb
suites: nodistro
components: main
signed_by: "{{ node_signing_key.dest }}"
state: present
register: node_repo
- name: Update apt cache if repo was added.
ansible.builtin.apt: update_cache=yes
when: ansible_facts['os_family']|lower == 'debian' and node_repo is changed
- name: Ensure Node.js and npm are installed.
when: ansible_facts['os_family']|lower == 'debian'
ansible.builtin.apt:
name: "nodejs={{ TARGET_NODE_VERSION | regex_replace('x', '') }}*"
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} }}"

View file

@ -0,0 +1,10 @@
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'
TARGET_NODE_VERSION: '21'
MIN_NODE_VERSION: '20.0.0'
MIN_NPM_VERSION: '10.0.0'