diff --git a/README.md b/README.md index 4ed6400..e930acf 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,21 @@ Create a local playbook `local_playbook.yml`: - hosts: localhost user: $MY_USER_NAME roles: - - { role: ansible-nodejs, node_version_family: "4.x", local_development: { user: "$MY_USER_NAME", enabled: true }, - globally_installed_tools: ["browserify", "coffeescript", "less"] - } + - { role: "ansible-nodejs", + node_version_family: "4.x", + local_development: { + user: "$MY_USER_NAME", + enabled: true + }, + globally_installed_tools: [ + "browserify", + "coffee-script", + "less", + "npmrc", + "grunt-cli", + "karma-cli" + ] + } ``` Create local inventory `localhost_inventory`: diff --git a/tasks/development.yml b/tasks/development.yml index 8148afc..d259e0e 100644 --- a/tasks/development.yml +++ b/tasks/development.yml @@ -1,11 +1,18 @@ --- - name: setup a user local node folder for development - file: path="{{ local_dev_setup.user_home }}/.local/nodejs" state=directory owner={{ local_development.user }} + file: path="{{ local_dev_setup.npm_home }}" state=directory + owner={{ local_development.user }} group={{ local_development.user }} - name: setup a npmrc setting for local development - template: src=npmrc.tmpl dest="{{ local_dev_setup.user_home }}/.npmrc" owner={{ local_development.user }} + template: src=npmrc.tmpl dest="{{ local_dev_setup.user_home }}/.npmrc" + owner={{ local_development.user }} + group={{ local_development.user }} - name: install globally required tools - npm: name={{ item }} state=present registry=http://registry.npmjs.org/ path="{{ local_dev_setup.npm_home }}" - become_user: "{{ local_development.user }}" + npm: name={{ item }} state=present registry=http://registry.npmjs.org/ + path="{{ local_dev_setup.npm_home }}" global=yes with_items: globally_installed_tools + +- name: add binaries to local path + lineinfile: state=present dest="{{ local_dev_setup.user_home }}/.bash_profile" + line="export PATH=$PATH:$HOME/.local/share/node_modules/bin:$HOME/.local/share/node_modules/.bin" diff --git a/tasks/main.yml b/tasks/main.yml index f7965c8..267aa59 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,3 @@ --- - { include: nodejs.yml, become_user: root, become_method: sudo } -- { include: development.yml, when: local_development.enabled == true } +- { include: development.yml, when: local_development.enabled == true, become_user: "{{ local_development.user }}" }