esp / esp.bitbucket / 1.4.1 / lookup / bitbucket_file Read file contents from Bitbucket Server | "added in version" 1.0.0 of esp.bitbucket" Authors: Krzysztof Lewandowski <krzysztof.lewandowski@nordea.com>esp.bitbucket.bitbucket_file (1.4.1) — lookup
Install with ansible-galaxy collection install esp.bitbucket:==1.4.1
collections: - name: esp.bitbucket version: 1.4.1
Returns a list of strings.
For each file in the list of files you pass in, returns a string containing a base64-encoded blob contents of the file from Bitbucket Server.
- name: Display file contents ansible.builtin.debug: msg: "{{ lookup('esp.bitbucket.bitbucket_file', 'path/to/baz.yml', project_key='FOO', repository='bar', validate_certs='no', url='https://bitbucket.example.com', username='SVCxxxxxx', password='secret') | b64decode | from_yaml }}"
- name: Display multiple files contents ansible.builtin.debug: msg: "{{ item | b64decode }}" loop: "{{ query('esp.bitbucket.bitbucket_file', 'path/to/baz.yml', 'qux.json', project_key='FOO', repository='bar', at='master', validate_certs='no', url='https://bitbucket.example.com', token='MjA2M...hqP58' ) }}" loop_control: label: "[Processing a file from Bitbucket Server ..]"
- name: lookup | Read vaulted file, do not decrypt it ansible.builtin.debug: msg: "{{ lookup('esp.bitbucket.bitbucket_file', 'path/to/vault.yml', project_key='FOO', repository='bar', validate_certs='no', url='https://bitbucket.example.com', username='SVCxxxxxx', password='secret', unvault='no' ) | b64decode | from_yaml }}"
- name: lookup | Read vaulted file, decrypt it ansible.builtin.debug: msg: "{{ lookup('esp.bitbucket.bitbucket_file', 'path/to/vault.yml', project_key='FOO', repository='bar', validate_certs='no', url='https://bitbucket.example.com', username='SVCxxxxxx', password='secret', unvault='yes' ) | b64decode | from_yaml }}"
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 url: description: - Bitbucket Server URL. required: false type: str sleep: default: 5 description: - Number of seconds to sleep between API retries. required: false type: int token: description: - Token parameter for authentication. - This is only needed when not using I(username) and I(password). required: false type: str _terms: description: Path(s) of file(s) on the Bitbucket Server to fetch content from. required: true retries: default: 3 description: - Number of retries to call Bitbucket API URL before failure. required: false type: int unvault: default: false description: - If C(yes), read vaulted file(s) contents and decrypt it. required: false type: bool 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: 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: false description: - If C(no), it will not use a proxy, even if one is defined in an environment variable on the target hosts. required: false type: bool repository: description: - Repository name. required: true type: str project_key: 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. required: false type: bool
_raw: description: - content of file(s) elements: str type: list