summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/preflight_encoding/tasks/main.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/preflight_encoding/tasks/main.yml
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/preflight_encoding/tasks/main.yml')
-rw-r--r--test/integration/targets/preflight_encoding/tasks/main.yml62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/integration/targets/preflight_encoding/tasks/main.yml b/test/integration/targets/preflight_encoding/tasks/main.yml
new file mode 100644
index 0000000..aa33b6c
--- /dev/null
+++ b/test/integration/targets/preflight_encoding/tasks/main.yml
@@ -0,0 +1,62 @@
+- name: find bash
+ shell: command -v bash
+ register: bash
+ ignore_errors: true
+
+- meta: end_host
+ when: bash is failed
+
+- name: get available locales
+ command: locale -a
+ register: locale_a
+ ignore_errors: true
+
+- set_fact:
+ non_utf8: '{{ locale_a.stdout_lines | select("contains", ".") | reject("search", "(?i)(\.UTF-?8$)") | default([None], true) | first }}'
+ has_cutf8: '{{ locale_a.stdout_lines | select("search", "(?i)C.UTF-?8") != [] }}'
+
+- name: Test successful encodings
+ shell: '{{ item }} ansible --version'
+ args:
+ executable: '{{ bash.stdout_lines|first }}'
+ loop:
+ - LC_ALL={{ utf8 }}
+ - LC_ALL={{ cutf8 }}
+ - LC_ALL= LC_CTYPE={{ utf8 }}
+ - LC_ALL= LC_CTYPE={{ cutf8 }}
+ when: cutf8 not in item or (cutf8 in item and has_cutf8)
+
+- name: test locales error
+ shell: LC_ALL=ham_sandwich LC_CTYPE={{ utf8 }} ansible --version
+ args:
+ executable: '{{ bash.stdout_lines|first }}'
+ ignore_errors: true
+ register: locales_error
+
+- assert:
+ that:
+ - locales_error is failed
+ - >-
+ 'ERROR: Ansible could not initialize the preferred locale' in locales_error.stderr
+
+- meta: end_host
+ when: non_utf8 is falsy
+
+- name: Test unsuccessful encodings
+ shell: '{{ item }} ansible --version'
+ args:
+ executable: '{{ bash.stdout_lines|first }}'
+ loop:
+ - LC_ALL={{ non_utf8 }}
+ - LC_ALL= LC_CTYPE={{ non_utf8 }}
+ ignore_errors: true
+ register: result
+
+- assert:
+ that:
+ - result is failed
+ - result.results | select('failed') | length == 2
+ - >-
+ 'ERROR: Ansible requires the locale encoding to be UTF-8' in result.results[0].stderr
+ - >-
+ 'ERROR: Ansible requires the locale encoding to be UTF-8' in result.results[1].stderr