我试图使用ansible为jenkins提供karma测试服务器,使用karma-phantomjs-launcher插件。我希望避免使用" exec npm install"的shellcript。格式。
麻烦在于phantomjs插件需要在安装时使用--save-dev
标志。我希望使用来自npm的--save-dev
标志,但是ansible npm模块似乎没有办法将这些标志传递给它运行的实际npm命令。
这是可能的,还是我应该使用ansible的命令模块来运行npm install karma-phantomjs-launcher --save-dev
?
答案 0 :(得分:0)
它与你的问题不完全相同,但我遇到了类似的问题,试图让npm使用ansible中的代理。我发现你可以运行npm命令,因此运行npm config命令。我假设save-dev
有一个npm config命令,对于大多数事情都有。
在我的情况下,我在角色中设置了一个任务,负责设置apache和npm(并安装npm' bower包)。
这是从我的任务中剪断的(记住这是在一个角色里面,而不是一个直接的任务,它跟随一个yum with command,它传递一个包列表,包括npm)。
- name: Setup NPM HTTP Proxy
become: True
command: npm config set proxy "{{http_proxy}}"
when: (http_proxy is defined) and (not http_proxy == '') and (node_modules.stat.exists == False)
- name: Clear NPM HTTP Proxy Setting
become: True
command: npm config rm proxy
when: (http_proxy is defined) and (http_proxy == '') and (node_modules.stat.exists == False)
- name: Setup NPM HTTPS Proxy
become: True
command: npm config set https-proxy "{{https_proxy}}"
when: (https_proxy is defined) and (not https_proxy == '') and (node_modules.stat.exists == False)
- name: Clear NPM HTTPS Proxy Setting
become: True
command: npm config rm https-proxy
when: (https_proxy is defined) and (https_proxy == '') and (node_modules.stat.exists == False)
- name: Disable NPM strict SSL mode
become: True
command: npm config set strict-ssl false
when: (http_proxy is defined) and (not http_proxy == '') and (node_modules.stat.exists == False)
- name: Clear NPM strict SSL mode Setting (if no http_proxy)
become: True
command: npm config rm strict-ssl
when: (http_proxy is defined) and (http_proxy == '') and (node_modules.stat.exists == False)
- name: Setup NPM to use http:// version of the registry
become: True
command: npm config set registry "http://registry.npmjs.org/"
when: (http_proxy is defined) and (not http_proxy == '') and (node_modules.stat.exists == False)
- name: Install Bower
become: True
shell: >
umask 022; npm install bower chdir=/usr/local/lib
when: node_modules.stat.exists == False
道歉,如果这没有帮助