File: low_level_execute_command.yml

package info (click to toggle)
python-mitogen 0.3.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,708 kB
  • sloc: python: 24,457; sh: 198; makefile: 74; perl: 19; ansic: 18
file content (46 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Verify the behaviour of _low_level_execute_command().

- name: integration/action/low_level_execute_command.yml
  hosts: test-targets
  tasks:

    # "echo -en" to test we actually hit bash shell too.
    - name: Run raw module without sudo
      raw: 'echo -en $((1 + 1))'
      register: raw

    - name: Verify raw module output.
      assert:
        that:
          - 'raw.rc == 0'
          - 'raw.stdout_lines[-1]|to_text == "2"'
          - 'raw.stdout[-1]|to_text == "2"'
        fail_msg: |
          raw={{ raw }}

    - name: Run raw module with sudo
      become: true
      raw: 'whoami'
      register: raw

    - debug: msg="x{{raw}}x"

    # Can't test stdout because TTY inserts \r in Ansible version.
    - name: Verify raw module output.
      assert:
        that:
        - raw.rc == 0
        # WHY DOES VANILLA INSERT NEWLINES HERE!?!?!?!?!?!ONE
        #- raw.stdout in ("\r\nroot\r\n", "root\r\n")
        - '(raw.stdout|to_text).endswith("root\r\n")'
        - |
          raw.stdout_lines|to_text in (
            ["\r\n"],
            ["", "root"],
            ["root\r\n"],
            ["root"],
          )
        fail_msg: |
          raw={{ raw }}
  tags:
    - low_level_execute_command