使用 Ansible get_url 时传递 BitBucket 服务器凭据 [英] Passing BitBucket server credentials when using Ansible get_url

查看:24
本文介绍了使用 Ansible get_url 时传递 BitBucket 服务器凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 ansible 脚本来从本地 bitbucket 服务器下载文件(shell 脚本).

I am trying to write an ansible script to download files ( shell scripts ) from local bitbucket server.

目前代码如下.它要求输入 id 和 pw,当我打印它时,它会打印出正确的输出.

Currently the code is as below. It asks for id and pw input and when I printed it, it prints a correct output.

但是 get_url 调用返回一个 html 页面.输入的 Id/pw 确实可以访问相关 BB 存储库.

But the get_url call returns an html page. The Id / pw entered does have access to the BB repo in question.

下面不是将凭据传递给 bitbucket 存储库的正确方法吗?

Is below not the correct way to pass credentials to bitbucket repo?

---

- 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 }}'

我应该如何修改上面的脚本以从BitBucket下载文件>

How should I modify the above script to download files from BitBucket>

谢谢

推荐答案

在脚本中添加 force_basic_auth: yes 解决了问题

Adding force_basic_auth: yes to the script resolved the issue

任务:

- name: Download connector scripts
  get_url:
    url: "http://bbserver:7990/projects/myproject/repos/myrepo/raw/scripts/{{ item }}"
    dest:  /var/scripts
    url_username: '{{ bb_username }}'
    url_password: '{{ bb_password }}'
    **force_basic_auth: yes**
  with_items:
    - script1.sh
    - script2.sh
    - script3.sh

这篇关于使用 Ansible get_url 时传递 BitBucket 服务器凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆