Get working setup for local development setup.
Include documentation for local setup.
This commit is contained in:
parent
3eea9f3afb
commit
ed270431ec
24
README.md
24
README.md
|
@ -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
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
|
|
@ -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 }}"
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
|
@ -0,0 +1 @@
|
||||||
|
prefix={{ local_dev_setup.user_home }}/.local/share/node_modules
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue