New "nodejs" role
authorAlexander Barton <alex@barton.de>
Fri, 16 Mar 2018 16:24:23 +0000 (17:24 +0100)
committerAlexander Barton <alex@barton.de>
Fri, 16 Mar 2018 16:24:23 +0000 (17:24 +0100)
roles/nodejs/defaults/main.yml [new file with mode: 0644]
roles/nodejs/files/nodejs.gpg [new file with mode: 0644]
roles/nodejs/tasks/main.yml [new file with mode: 0644]
roles/nodejs/templates/nodejs.list.j2 [new file with mode: 0644]

diff --git a/roles/nodejs/defaults/main.yml b/roles/nodejs/defaults/main.yml
new file mode 100644 (file)
index 0000000..a8322fc
--- /dev/null
@@ -0,0 +1,5 @@
+---
+# defaults file for nodejs
+
+nodejs_version: "9"
+nodejs_apt_repository: "https://deb.nodesource.com/node_{{nodejs_version}}.x"
diff --git a/roles/nodejs/files/nodejs.gpg b/roles/nodejs/files/nodejs.gpg
new file mode 100644 (file)
index 0000000..4f3ec4e
Binary files /dev/null and b/roles/nodejs/files/nodejs.gpg differ
diff --git a/roles/nodejs/tasks/main.yml b/roles/nodejs/tasks/main.yml
new file mode 100644 (file)
index 0000000..b8e968d
--- /dev/null
@@ -0,0 +1,53 @@
+---
+# tasks file for nodejs
+
+- name: install "apt-transport-https" and "ca-certificates"
+  tags:
+    - nodejs
+    - packages
+  apt:
+    name: "{{ item }}"
+    state: installed
+  with_items:
+    - apt-transport-https
+    - ca-certificates
+  when: nodejs_apt_repository.startswith("https://")
+
+- name: install Node.js repository GnuPG key
+  tags:
+    - nodejs
+    - packages
+  copy:
+    dest: /etc/apt/trusted.gpg.d/
+    group: root
+    mode: 0644
+    owner: root
+    src: nodejs.gpg
+  notify:
+    - update APT repositories
+
+- name: install Node.js repository configuration
+  tags:
+    - nodejs
+    - packages
+  template:
+    dest: /etc/apt/sources.list.d/nodejs.list
+    group: root
+    mode: 0644
+    owner: root
+    src: nodejs.list.j2
+  notify:
+    - update APT repositories
+
+- meta: flush_handlers
+  tags:
+    - nodejs
+    - packages
+
+- name: install "npm"
+  tags:
+    - nodejs
+    - packages
+  apt:
+    name: npm
+    state: installed
diff --git a/roles/nodejs/templates/nodejs.list.j2 b/roles/nodejs/templates/nodejs.list.j2
new file mode 100644 (file)
index 0000000..a49b7d2
--- /dev/null
@@ -0,0 +1,6 @@
+# /etc/apt/sources.list.d/nodejs.list -- Node.js repository configuration
+# ---
+#  {{ ansible_managed }}
+# ---
+
+deb {{nodejs_apt_repository}} {{ansible_distribution_release}} main