darkwizard242.nodejs
Ansible角色: nodejs
该角色用于在基于Debian和EL的系统上安装(默认)nodejs包,或在传递变量时卸载。nodejs 是 JavaScript 运行时环境。同时也会安装 npm 和 npx。默认安装版本是 18.x
的 NodeJS,除非明确指定其他特定版本,因为源代码库基于此。
要求
无。
角色变量
可用的变量列在下面(位于 defaults/main.yml
中):
变量列表:
nodejs_app: nodejs
nodejs_app_desired_state: present
nodejs_version: 18.x
# 基于Debian的
nodejs_debian_pre_reqs:
- apt-transport-https
- gnupg
nodejs_debian_pre_reqs_desired_state: present
nodejs_repo_debian_gpg_key: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
nodejs_repo_debian: "deb https://deb.nodesource.com/node_{{ nodejs_version }} {{ ansible_lsb['codename'] }} main"
nodejs_repo_debian_filename: "{{ nodejs_app }}"
nodejs_repo_debian_desired_state: present
# 基于EL的
nodejs_repo_el: "https://rpm.nodesource.com/pub_{{ nodejs_version }}/el/{{ ansible_distribution_major_version }}/$basearch"
nodejs_repo_el_name: nodesource
nodejs_repo_el_description: Node.js EL系列库
nodejs_repo_el_gpgkey: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
nodejs_repo_el_gpgcheck: yes
nodejs_repo_el_enabled: yes
nodejs_repo_el_filename: "{{ nodejs_app }}"
nodejs_repo_el_desired_state: present
变量表:
变量 | 描述 |
---|---|
nodejs_app | 要安装的 nodejs 应用程序包的名称,即 nodejs |
nodejs_app_desired_state | nodejs_app 包的状态。是否安装、检查是否可用或卸载(即 ansible apt 模块的值: present 、latest 或 absent ) |
nodejs_version | 要安装的 NodeJS 版本。 |
nodejs_debian_pre_reqs | NodeJS 建议在基于 Debian 的系统上安装这两个包,因此它们被视为先决条件。 |
nodejs_debian_pre_reqs_desired_state | Debian 系统上 NodeJS 先决条件应用程序的期望状态。 |
nodejs_repo_debian_gpg_key | 在基于 Debian 的系统上需要的 NodeJS GPG 密钥 |
nodejs_repo_debian | Debian 系统上 NodeJS 的库 URL。使用了 ansible_lsb['codename'] 的事实。 |
nodejs_repo_debian_filename | 将存储在 Debian 系统上的 /etc/apt/sources.list.d/ 中的库文件的名称。 |
nodejs_repo_debian_desired_state | present 表示如果在 Debian 系统上库文件不存在,则创建该库文件。另一种选择是 absent (不推荐,因为会阻止安装 nodejs 包)。 |
nodejs_repo_el | 在基于 EL 的系统上 NodeJS 的库 baseurl 。使用 ansible_distribution_major_version ansible 事实来设置相应的 EL 系统版本。 |
nodejs_repo_el_name | 在基于 EL 的系统上 NodeJS 的库名称。 |
nodejs_repo_el_description | 将添加到 EL 基于的 NodeJS 库文件的描述。 |
nodejs_repo_el_gpgkey | 在基于 EL 的系统上需要的 NodeJS GPG 密钥。 |
nodejs_repo_el_gpgcheck | 是否在基于 EL 的系统上对 NodeJS 进行 GPG 检查的布尔值。 |
nodejs_repo_el_enabled | 布尔值,用于设置 NodeJS 库在基于 EL 的系统上是否启用。 |
nodejs_repo_el_filename | 将存储在 EL 系统上的 /yum/sources.list.d/nodejs.repo 中的库文件的名称。 |
nodejs_repo_el_desired_state | present 表示如果在 EL 系统上库文件不存在,则创建该库文件。另一种选择是 absent (不推荐,因为会阻止安装 nodejs 包)。 |
依赖
无
示例剧本
对于角色的默认行为(即安装 nodejs 包)在 ansible 剧本中:
- hosts: servers
roles:
- darkwizard242.nodejs
对于自定义角色行为(例如在 ansible 剧本中安装 12.x 版本的 nodejs):
- hosts: servers
roles:
- darkwizard242.nodejs
vars:
nodejs_version: 14.x
对于自定义角色行为(例如在 ansible 剧本中卸载 nodejs 包):
- hosts: servers
roles:
- darkwizard242.nodejs
vars:
nodejs_apps_desired_state: absent
许可证
作者信息
该角色由 Ali Muhammad 创建。
关于项目
Installs/Uninstalls 'nodejs'. A JavaScript runtime environment.
安装
ansible-galaxy install darkwizard242.nodejs
许可证
mit
下载
4k
拥有者
Senior DevOps/CloudOps Engineer.
Dedicated to Automating everything I come across.
Love to work on and learn new technologies/tools everyday!