---
- name: 'A play with unicode: ¢ £ ¤ ¥'
  hosts: localhost
  connection: local
  vars:
    test_var: 'Ī Ä« Ĭ Ä­ Ä® į Ä° ı IJ ij Ä´ ĵ Ķ Ä· ĸ Ĺ ĺ Ä» ļ Ľ ľ Ä¿ Å Å Å Å Å Å Å Å Å Å Å Å Å Å Å Å Å Å Å'
    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: Run raw with non-ascii options
      raw: "/bin/echo ZażóÅÄ gÄÅlÄ jaźÅ"
      register: results

    - name: Check that raw output the right thing
      assert:
        that:
          - "'ZażóÅÄ gÄÅlÄ jaźÅ' in results.stdout_lines"

    - name: Run a script with non-ascii options and environment
      script: unicode-test-script --option "ZażóÅÄ gÄÅlÄ jaźÅ"
      environment:
        option: ZażóÅÄ
      register: results

    - name: Check that script output includes the nonascii arguments and environment values
      assert:
        that:
          - "'--option ZażóÅÄ gÄÅlÄ jaźÅ' in results.stdout_lines"
          - "'ZażóÅÄ' in results.stdout_lines"

    - name: Ping with non-ascii environment variable and option
      ping:
        data: "ZażóÅÄ gÄÅlÄ jaźÅ"
      environment:
        option: ZażóÅÄ
      register: results

    - name: Check that ping with non-ascii data was correct
      assert:
        that:
          - "'ZażóÅÄ gÄÅlÄ jaźÅ' == results.ping"

    - name: Command that echos a non-ascii env var
      command: "echo $option"
      environment:
        option: ZażóÅÄ
      register: results

    - name: Check that a non-ascii env var was passed to the command module
      assert:
        that:
          - "'ZażóÅÄ' in results.stdout_lines"

    - name: Clean a temp directory
      file:
        path: /var/tmp/ansible_test_unicode_get_put
        state: absent

    - name: Create a temp directory
      file:
        path: /var/tmp/ansible_test_unicode_get_put
        state: directory

    - name: Create a file with a non-ascii filename
      file:
        path: /var/tmp/ansible_test_unicode_get_put/ZażóÅÄ
        state: touch
      delegate_to: localhost

    - name: Put with unicode filename
      copy:
        src: /var/tmp/ansible_test_unicode_get_put/ZażóÅÄ
        dest: /var/tmp/ansible_test_unicode_get_put/ZażóÅÄ2

    - name: Fetch with unicode filename
      fetch:
        src: /var/tmp/ansible_test_unicode_get_put/ZażóÅÄ2
        dest: /var/tmp/ansible_test_unicode_get_put/

    - name: Clean a temp directory
      file:
        path: /var/tmp/ansible_test_unicode_get_put
        state: absent

- 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