From 650ee5abf8cb682efb2ce474d25d9afdb874f40b Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Fri, 28 Feb 2025 08:37:38 -0800 Subject: [PATCH] core: update b64encode and b64decode doc (#84757) --- lib/ansible/plugins/filter/b64decode.yml | 10 ++++++++++ lib/ansible/plugins/filter/b64encode.yml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/ansible/plugins/filter/b64decode.yml b/lib/ansible/plugins/filter/b64decode.yml index 339de3a724d..5dc82e0d6bb 100644 --- a/lib/ansible/plugins/filter/b64decode.yml +++ b/lib/ansible/plugins/filter/b64decode.yml @@ -15,6 +15,12 @@ DOCUMENTATION: description: A Base64 string to decode. type: string required: true + encoding: + description: + - The encoding to use to transform from a text string to a byte string. + - Defaults to using 'utf-8'. + type: string + required: false EXAMPLES: | # Base64 decode a string @@ -23,6 +29,10 @@ EXAMPLES: | # Base64 decode the content of 'b64stuff' variable stuff: "{{ b64stuff | b64decode }}" + # Base64 decode the content with different encoding + stuff: "{{ 'QQBuAHMAaQBiAGwAZQAgAC0AIABPMIkwaDB/MAoA' | b64decode(encoding='utf-16-le') }}" + # => 'Ansible - くらとみ\n' + RETURN: _value: description: The contents of the Base64 encoded string. diff --git a/lib/ansible/plugins/filter/b64encode.yml b/lib/ansible/plugins/filter/b64encode.yml index ed32bfb8066..199202730c2 100644 --- a/lib/ansible/plugins/filter/b64encode.yml +++ b/lib/ansible/plugins/filter/b64encode.yml @@ -11,6 +11,12 @@ DOCUMENTATION: description: A string to encode. type: string required: true + encoding: + description: + - The encoding to use to transform from a text string to a byte string. + - Defaults to using 'utf-8'. + type: string + required: false EXAMPLES: | # Base64 encode a string @@ -19,6 +25,10 @@ EXAMPLES: | # Base64 encode the content of 'stuff' variable b64stuff: "{{ stuff | b64encode }}" + # Base64 encode the content with different encoding + b64stuff: "{{ 'Ansible - くらとみ\n' | b64encode(encoding='utf-16-le') }}" + # => 'QQBuAHMAaQBiAGwAZQAgAC0AIABPMIkwaDB/MAoA' + RETURN: _value: description: A Base64 encoded string.