问题描述
我正在尝试编写一个 ansible 脚本来从本地 bitbucket 服务器下载文件(shell 脚本)。
目前代码如下。它要求输入 id 和 pw,当我打印它时,它会打印出正确的输出。
但是 get_url 调用返回一个 html 页面。输入的 Id / pw 确实可以访问相关 BB 存储库。
下面不是将凭据传递给 bitbucket 存储库的正确方法吗?
---
- name: Deployment of infrastructure changes
hosts: kafka_broker[0]
vars:
ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
ansible_host_key_checking: false
date: "{{ lookup('pipe','date +%Y%m%d-%H%M%s') }}"
vars_prompt:
- name: bb_username
prompt: "User name for Bitbucket"
private: no
- name: bb_password
prompt: "Password for "
private: yes
tasks:
- name: Download connector scripts
get_url:
url: "http://bbserver:7990/projects/myproject/repos/myrepo/browse/scripts/{{ item }}"
dest: /var/scripts
url_username: '{{ bb_username }}'
url_password: '{{ bb_password }}'
with_items:
- script1.sh
- script2.sh
- script3.sh
register: showdlstatus
become: yes
become_user: '{{ bb_username }}'
谢谢
解决方法
在脚本中添加 force_basic_auth: yes 解决了问题
任务:
command = "java -jar <filename.jar> <args>" result = suprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()