Get working setup for local development setup.

Include documentation for local setup.
This commit is contained in:
Dorian 2016-03-15 10:10:17 -04:00
parent 3eea9f3afb
commit ed270431ec
8 changed files with 44 additions and 15 deletions

View File

@ -1,3 +1,27 @@
Local Setup
===========
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 } }
```
Create local inventory `localhost_inventory`:
```
localhost ansible_connection=local ansible_become=true
```
Run the playbook locally:
```
ansible-playbook test_playbook.yml -i localhost_inventory -vvvv -K
```
Role Name Role Name
========= =========

View File

@ -6,5 +6,8 @@ globally_installed_tools:
- browserify - browserify
- npmrc - npmrc
# Set to true for provisioning a development environment local_development:
local_development: false # Set to true for provisioning a development environment
enabled: false
user: "{{ ansible_env.SUDO_USER }}"

View File

@ -1,7 +1,11 @@
--- ---
- name: setup a user local node folder for development - name: setup a user local node folder for development
file: path="{{ ansible.user_home }}/.local/nodejs" state=directory owner={{ ansible.user }} file: path="{{ local_dev_setup.user_home }}/.local/nodejs" state=directory owner={{ local_development.user }}
- name: setup a npmrc setting for local development - name: setup a npmrc setting for local development
file: path="{{ ansible.user_home }}/.npmrc" state=file owner={{ ansible.user }} template: src=npmrc.tmpl dest="{{ local_dev_setup.user_home }}/.npmrc" owner={{ local_development.user }}
when: local_development == true
- 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 }}"
with_items: globally_installed_tools

View File

@ -1,4 +1,3 @@
--- ---
include: nodejs.yml - { include: nodejs.yml, become_user: root, become_method: sudo }
{ include: development.yml, when: local_development == true } - { include: development.yml, when: local_development.enabled == true }
include: tools.yml

View File

@ -32,4 +32,5 @@
- name: install globally required tools - name: install globally required tools
npm: name={{ item }} global=yes state=present registry=http://registry.npmjs.org/ npm: name={{ item }} global=yes state=present registry=http://registry.npmjs.org/
with_items: {{ globally_installed_tools }} when: local_development.enabled == false
with_items: globally_installed_tools

View File

@ -1,5 +0,0 @@
---
- name: install globally required tools
npm: name={{ item }} global=yes state=present registry=http://registry.npmjs.org/
with_items: {{ globally_installed_tools }}
when: globally_installed_tools exists

1
templates/npmrc.tmpl Normal file
View File

@ -0,0 +1 @@
prefix={{ local_dev_setup.user_home }}/.local/share/node_modules

View File

@ -1,2 +1,4 @@
--- ---
# vars file for ansible-nodejs local_dev_setup:
user_home: "/home/{{ local_development.user }}"
npm_home: "/home/{{ local_development.user }}/.local/share/node_modules"