--- - hosts: all vars: node_apps: /root tasks: - name: "安装node.js源" shell: curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash - - name: "yum安装node.js" yum: name=nodejs state=present - name: "禁用https检测" shell: npm config set strict-ssl false - name: "安装forever" npm: name=forever global=yes state=latest - name: "确保node.js app的目录存在" file: "path={{ node_apps }} state=directory" - name: 复制node.js app目录到目标主机 copy: "src=app dest={{ node_apps }}" - name: 安装package.json文件中定义的依赖关系 npm: "path={{ node_apps }}/app" - name: 获取正在运行的node.js列表 shell: forever list register: forever_list changed_when: false - name: 启动node.js app shell: "forever start {{ node_apps }}/app/app.js" #when: "forever_list.stdout.find('/root/app/app.js') == -1"
Ansible-Playbook部署node.js
未经允许不得转载:Anonym0x1 » Ansible-Playbook部署node.js