esp.bitbucket.bitbucket_slurp (1.4.1) — module

Slurps a file from Bitbucket Server

| "added in version" 1.0.0 of esp.bitbucket"

Authors: Krzysztof Lewandowski (@klewan)

Install collection

Install with ansible-galaxy collection install esp.bitbucket:==1.4.1


Add to requirements.yml

  collections:
    - name: esp.bitbucket
      version: 1.4.1

Description

This module is used for fetching a base64-encoded blob containing the data in a file on Bitbucket Server.

Authentication can be done with I(token) or with I(username) and I(password).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read baz.yml file contents from Bitbucket Server from default branch
  esp.bitbucket.bitbucket_slurp:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    src: 'path/to/baz.yml'
    validate_certs: no
    force_basic_auth: yes
  register: _result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Print returned information
  ansible.builtin.debug:
    msg: "{{ _result['content'] | b64decode }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Read baz.yml file contents from Bitbucket Server from develop branch
  esp.bitbucket.bitbucket_slurp:
    url: 'https://bitbucket.example.com'
    token: 'MjA2M...hqP58'
    repository: bar
    project_key: FOO
    src: 'path/to/baz.yml'
    at: develop
    validate_certs: no
  register: _result

Inputs

    
at:
    description:
    - The commit ID or ref (e.g. a branch or tag) to read a file at.
    - If not specified the default branch will be used instead.
    required: false
    type: str

src:
    aliases:
    - path
    description:
    - The file on the Bitbucket Server to fetch. This I(must) be a file, not a directory.
    required: true
    type: path

url:
    description:
    - Bitbucket Server URL.
    required: false
    type: str

sleep:
    default: 5
    description:
    - Number of seconds to sleep between API retries.
    type: int

token:
    description:
    - Token parameter for authentication.
    - This is only needed when not using I(username) and I(password).
    required: false
    type: str

retries:
    default: 3
    description:
    - Number of retries to call Bitbucket API URL before failure.
    type: int

password:
    description:
    - Password used for authentication.
    - This is only needed when not using I(token).
    - Required when I(username) is provided.
    required: false
    type: str

username:
    aliases:
    - user
    description:
    - Username used for authentication.
    - This is only needed when not using I(token).
    - Required when I(password) is provided.
    required: false
    type: str

use_proxy:
    default: true
    description:
    - If C(no), it will not use a proxy, even if one is defined in an environment variable
      on the target hosts.
    type: bool

repository:
    aliases:
    - name
    description:
    - Repository name.
    required: true
    type: str

project_key:
    aliases:
    - project
    description:
    - Bitbucket project key.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - If C(no), SSL certificates will not be validated.
    - This should only set to C(no) used on personally controlled sites using self-signed
      certificates.
    type: bool

Outputs

content:
  description: Encoded file content
  returned: success
  sample: LS0tCmhlbGxvOiB3b3JsZAoK
  type: str
encoding:
  description: Type of encoding used for file
  returned: success
  sample: base64
  type: str
url:
  description: Actual URL of file slurped
  returned: success
  sample: https://bitbucket.example.com/rest/api/1.0/projects/FOO/repos/bar/raw/path/to/baz.yml
  type: str