Content #
Install app #
- name: Ensure nodejs app file: “path={{ node_apps_location }}” state=directory"
- name: Copy nodejs app copy: “src=app dest={{ node_apps_location }}”
- name: Install npm package npm: “path={{ node_apps_location }}/app”
Run with forever #
- name: Get running nodejs app list command: forever list register: forever_list changed_when: false
- name: start nodejs app command: “forever start {{ node_apps_location }}/app/app.js” when: “forever_list.stdout.find(’{{ node_apps_location }}/app/app.js’) == -1”
changed_when: false
用于告诉ansible,本任务没有对主机造成影响(改变文件或安装软件等)。
From #
Ansible权威指南