File: copy.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 (95 lines) | stat: -rw-r--r-- 2,707 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Verify copy module for small and large files, and inline content.
# To exercise https://github.com/mitogen-hq/mitogen/pull/1110 destination
# files must have extensions and loops must use `with_items:`.

- name: integration/action/copy.yml
  hosts: test-targets
  vars:
    sourced_files:
      - src: /tmp/copy-tiny-file
        dest: /tmp/copy-tiny-file.out
        content: this is a tiny file.
        expected_checksum: f29faa9a6f19a700a941bf2aa5b281643c4ec8a0
      - src: /tmp/copy-large-file
        dest: /tmp/copy-large-file.out
        content: "{{ 'x' * 200000 }}"
        expected_checksum: 62951f943c41cdd326e5ce2b53a779e7916a820d

    inline_files:
      - dest: /tmp/copy-tiny-inline-file.out
        content: tiny inline content
        expected_checksum: b26dd6444595e2bdb342aa0a91721b57478b5029
      - dest: /tmp/copy-large-inline-file.out
        content: |
          {{ 'y' * 200000 }}
        expected_checksum: d675f47e467eae19e49032a2cc39118e12a6ee72

    files: "{{ sourced_files + inline_files }}"
  tasks:
    - name: Create sourced files
      copy:
        dest: "{{ item.src }}"
        content: "{{ item.content }}"
        mode: u=rw,go=r
      with_items: "{{ sourced_files }}"
      loop_control:
        label: "{{ item.src }}"
      delegate_to: localhost
      run_once: true

    - name: Cleanup lingering destination files
      file:
        path: "{{ item.dest }}"
        state: absent
      with_items: "{{ files }}"
      loop_control:
        label: "{{ item.dest }}"

    - name: Copy sourced files
      copy:
        src: "{{ item.src }}"
        dest: "{{ item.dest }}"
        mode: u=rw,go=r
      with_items: "{{ sourced_files }}"
      loop_control:
        label: "{{ item.dest }}"

    - name: Copy inline files
      copy:
        dest: "{{ item.dest }}"
        content: "{{ item.content }}"
        mode: u=rw,go=r
      with_items: "{{ inline_files }}"
      loop_control:
        label: "{{ item.dest }}"

    # stat results

    - name: Stat copied files
      stat:
        path: "{{ item.dest }}"
      with_items: "{{ files }}"
      loop_control:
        label: "{{ item.dest }}"
      register: stat

    - assert:
        that:
          - item.stat.checksum == item.item.expected_checksum
        quiet: true  # Avoid spamming stdout with 400 kB of item.item.content
        fail_msg: |
          item={{ item }}
      with_items: "{{ stat.results }}"
      loop_control:
        label: "{{ item.stat.path }}"

    - name: Cleanup destination files
      file:
        path: "{{ item.dest }}"
        state: absent
      with_items: "{{ files }}"
      loop_control:
        label: "{{ item.dest }}"
  tags:
    - copy
    - issue_1110