mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
88a20e7a20
1. The test did "name: '{{hostnames}}.{{item}}'" inside a with_sequence loop, which didn't do what was intended: it expanded hostnames into an array, appended ".1", and set name to the resulting string. This can be converted to a simple with_items loop. 2. Some of the entries in hostnames contained punctuation characters, which I see no reason to support in inventory hostnames anyway. 3. Once the add_host failures are fixed, the playbook later fails when the unicode hostnames are interpolated into debug output in ssh.py due to an encoding error. This is only one of the many places that may fail when using unicode inventory hostnames; we work around it by providing an ansible_ssh_host setting.
74 lines
2.6 KiB
YAML
74 lines
2.6 KiB
YAML
---
|
||
- name: 'A play with unicode: ¢ £ ¤ ¥'
|
||
hosts: localhost
|
||
connection: local
|
||
vars:
|
||
test_var: 'Ī ī Ĭ ĭ Į į İ ı IJ ij Ĵ ĵ Ķ ķ ĸ Ĺ ĺ Ļ ļ Ľ ľ Ŀ ŀ Ł ł Ń ń Ņ ņ Ň ň ʼn Ŋ ŋ Ō ō Ŏ ŏ Ő ő Œ'
|
||
hostnames:
|
||
- 'host-ϬϭϮϯϰ'
|
||
- 'host-fóöbär'
|
||
- 'host-ΙΚΛΜΝΞ'
|
||
- 'host-στυφχψ'
|
||
- 'host-ϬϭϮϯϰϱ'
|
||
|
||
tasks:
|
||
- name: 'A task name with unicode: è é ê ë'
|
||
debug: msg='hi there'
|
||
|
||
- name: 'A task with unicode parameters'
|
||
debug: var=test_var
|
||
|
||
# € ‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ®'
|
||
|
||
- name: 'A task using with_items containing unicode'
|
||
debug: msg='{{item}}'
|
||
with_items:
|
||
- '¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö ×'
|
||
- 'Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ Ā'
|
||
- 'ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě Ĝ ĝ Ğ ğ Ġ ġ Ģ ģ Ĥ ĥ Ħ ħ Ĩ ĩ'
|
||
|
||
- add_host:
|
||
name: '{{item}}'
|
||
groups: 'ĪīĬĭ'
|
||
ansible_ssh_host: 127.0.0.1
|
||
ansible_connection: local
|
||
with_items: hostnames
|
||
|
||
- name: 'A task with unicode extra vars'
|
||
debug: var=extra_var
|
||
|
||
- name: 'A task with unicode host vars'
|
||
debug: var=unicode_host_var
|
||
|
||
- name: 'A task with unicode shell parameters'
|
||
shell: echo '¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö ×'
|
||
register: output
|
||
|
||
- name: 'Assert that the unicode was echoed'
|
||
assert:
|
||
that:
|
||
- "'¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö ×' in output.stdout_lines"
|
||
|
||
- name: 'A play for hosts in group: ĪīĬĭ'
|
||
hosts: 'ĪīĬĭ'
|
||
gather_facts: true
|
||
tasks:
|
||
- debug: msg='Unicode is a good thing ™'
|
||
- debug: msg=АБВГД
|
||
|
||
# Run this test by adding to the CLI: -e start_at_task=True --start-at-task '*¶'
|
||
- name: 'Show that we can skip to unicode named tasks'
|
||
hosts: localhost
|
||
gather_facts: false
|
||
vars:
|
||
flag: 'original'
|
||
start_at_task: False
|
||
tasks:
|
||
- name: 'Override flag var'
|
||
set_fact: flag='new'
|
||
|
||
- name: 'A unicode task at the end of the playbook: ¶'
|
||
assert:
|
||
that:
|
||
- 'flag == "original"'
|
||
when: start_at_task|bool
|