commit
80efb4668d
@ -1,92 +1,94 @@
|
|||||||
# Verify copy module for small and large files, and inline content.
|
# 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
|
- name: integration/action/copy.yml
|
||||||
hosts: test-targets
|
hosts: test-targets
|
||||||
tasks:
|
vars:
|
||||||
- name: Create tiny file
|
sourced_files:
|
||||||
copy:
|
- src: /tmp/copy-tiny-file
|
||||||
dest: /tmp/copy-tiny-file
|
dest: /tmp/copy-tiny-file.out
|
||||||
content:
|
content: this is a tiny file.
|
||||||
this is a tiny file.
|
expected_checksum: f29faa9a6f19a700a941bf2aa5b281643c4ec8a0
|
||||||
delegate_to: localhost
|
- src: /tmp/copy-large-file
|
||||||
run_once: true
|
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
|
||||||
|
|
||||||
- name: Create large file
|
files: "{{ sourced_files + inline_files }}"
|
||||||
|
tasks:
|
||||||
|
- name: Create sourced files
|
||||||
copy:
|
copy:
|
||||||
dest: /tmp/copy-large-file
|
dest: "{{ item.src }}"
|
||||||
# Must be larger than Connection.SMALL_SIZE_LIMIT.
|
content: "{{ item.content }}"
|
||||||
content: "{% for x in range(200000) %}x{% endfor %}"
|
mode: u=rw,go=r
|
||||||
|
with_items: "{{ sourced_files }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.src }}"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|
||||||
- name: Cleanup copied files
|
- name: Cleanup lingering destination files
|
||||||
file:
|
file:
|
||||||
|
path: "{{ item.dest }}"
|
||||||
state: absent
|
state: absent
|
||||||
path: "{{item}}"
|
with_items: "{{ files }}"
|
||||||
with_items:
|
loop_control:
|
||||||
- /tmp/copy-tiny-file.out
|
label: "{{ item.dest }}"
|
||||||
- /tmp/copy-large-file.out
|
|
||||||
- /tmp/copy-tiny-inline-file.out
|
|
||||||
- /tmp/copy-large-inline-file.out
|
|
||||||
|
|
||||||
- name: Copy large file
|
- name: Copy sourced files
|
||||||
copy:
|
copy:
|
||||||
dest: /tmp/copy-large-file.out
|
src: "{{ item.src }}"
|
||||||
src: /tmp/copy-large-file
|
dest: "{{ item.dest }}"
|
||||||
|
mode: u=rw,go=r
|
||||||
- name: Copy tiny file
|
with_items: "{{ sourced_files }}"
|
||||||
copy:
|
loop_control:
|
||||||
dest: /tmp/copy-tiny-file.out
|
label: "{{ item.dest }}"
|
||||||
src: /tmp/copy-tiny-file
|
|
||||||
|
|
||||||
- name: Copy tiny inline file
|
- name: Copy inline files
|
||||||
copy:
|
copy:
|
||||||
dest: /tmp/copy-tiny-inline-file.out
|
dest: "{{ item.dest }}"
|
||||||
content: "tiny inline content"
|
content: "{{ item.content }}"
|
||||||
|
mode: u=rw,go=r
|
||||||
- name: Copy large inline file
|
with_items: "{{ inline_files }}"
|
||||||
copy:
|
loop_control:
|
||||||
dest: /tmp/copy-large-inline-file.out
|
label: "{{ item.dest }}"
|
||||||
content: |
|
|
||||||
{% for x in range(200000) %}y{% endfor %}
|
|
||||||
|
|
||||||
# stat results
|
# stat results
|
||||||
|
|
||||||
- name: Stat copied files
|
- name: Stat copied files
|
||||||
stat:
|
stat:
|
||||||
path: "{{item}}"
|
path: "{{ item.dest }}"
|
||||||
with_items:
|
with_items: "{{ files }}"
|
||||||
- /tmp/copy-tiny-file.out
|
loop_control:
|
||||||
- /tmp/copy-large-file.out
|
label: "{{ item.dest }}"
|
||||||
- /tmp/copy-tiny-inline-file.out
|
|
||||||
- /tmp/copy-large-inline-file.out
|
|
||||||
register: stat
|
register: stat
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- stat.results[0].stat.checksum == "f29faa9a6f19a700a941bf2aa5b281643c4ec8a0"
|
- item.stat.checksum == item.item.expected_checksum
|
||||||
- stat.results[1].stat.checksum == "62951f943c41cdd326e5ce2b53a779e7916a820d"
|
quiet: true # Avoid spamming stdout with 400 kB of item.item.content
|
||||||
- stat.results[2].stat.checksum == "b26dd6444595e2bdb342aa0a91721b57478b5029"
|
fail_msg: item={{ item }}
|
||||||
- stat.results[3].stat.checksum == "d675f47e467eae19e49032a2cc39118e12a6ee72"
|
with_items: "{{ stat.results }}"
|
||||||
fail_msg: stat={{stat}}
|
loop_control:
|
||||||
|
label: "{{ item.stat.path }}"
|
||||||
|
|
||||||
- name: Cleanup files
|
- name: Cleanup destination files
|
||||||
file:
|
file:
|
||||||
|
path: "{{ item.dest }}"
|
||||||
state: absent
|
state: absent
|
||||||
path: "{{item}}"
|
with_items: "{{ files }}"
|
||||||
with_items:
|
loop_control:
|
||||||
- /tmp/copy-tiny-file
|
label: "{{ item.dest }}"
|
||||||
- /tmp/copy-tiny-file.out
|
|
||||||
- /tmp/copy-no-mode
|
|
||||||
- /tmp/copy-no-mode.out
|
|
||||||
- /tmp/copy-with-mode
|
|
||||||
- /tmp/copy-with-mode.out
|
|
||||||
- /tmp/copy-large-file
|
|
||||||
- /tmp/copy-large-file.out
|
|
||||||
- /tmp/copy-tiny-inline-file.out
|
|
||||||
- /tmp/copy-large-inline-file
|
|
||||||
- /tmp/copy-large-inline-file.out
|
|
||||||
|
|
||||||
# end of cleaning out files (again)
|
|
||||||
tags:
|
tags:
|
||||||
- copy
|
- copy
|
||||||
|
- issue_1110
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
- import_playbook: args.yml
|
||||||
- import_playbook: config.yml
|
- import_playbook: config.yml
|
||||||
|
- import_playbook: password.yml
|
||||||
- import_playbook: timeouts.yml
|
- import_playbook: timeouts.yml
|
||||||
- import_playbook: variables.yml
|
- import_playbook: variables.yml
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
- name: integration/ssh/args.yml
|
||||||
|
hosts: issue905
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
# Test that ansible_ssh_common_args are templated; ansible_ssh_args &
|
||||||
|
# ansible_ssh_extra_args aren't directly tested, we assume they're similar.
|
||||||
|
# FIXME This test currently relies on variables set in the host group.
|
||||||
|
# Ideally they'd be set here, and the host group eliminated, but
|
||||||
|
# Mitogen currently fails to template when defined in the play.
|
||||||
|
# TODO Replace LocalCommand canary with SetEnv canary, to simplify test.
|
||||||
|
# Requires modification of sshd_config files to add AcceptEnv ...
|
||||||
|
- name: Test templating of ansible_ssh_common_args et al
|
||||||
|
block:
|
||||||
|
- name: Ensure no lingering canary files
|
||||||
|
file:
|
||||||
|
path: "{{ ssh_args_canary_file }}"
|
||||||
|
state: absent
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Reset connections to force new ssh execution
|
||||||
|
meta: reset_connection
|
||||||
|
|
||||||
|
- name: Perform SSH connection, to trigger side effect
|
||||||
|
ping:
|
||||||
|
|
||||||
|
# LocalCommand="touch {{ ssh_args_canary_file }}" in ssh_*_args
|
||||||
|
- name: Stat for canary file created by side effect
|
||||||
|
stat:
|
||||||
|
path: "{{ ssh_args_canary_file }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
register: ssh_args_canary_stat
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- ssh_args_canary_stat.stat.exists == true
|
||||||
|
quiet: true
|
||||||
|
success_msg: "Canary found: {{ ssh_args_canary_file }}"
|
||||||
|
fail_msg: |
|
||||||
|
ssh_args_canary_file={{ ssh_args_canary_file }}
|
||||||
|
ssh_args_canary_stat={{ ssh_args_canary_stat }}
|
||||||
|
always:
|
||||||
|
- name: Cleanup canary files
|
||||||
|
file:
|
||||||
|
path: "{{ ssh_args_canary_file }}"
|
||||||
|
state: absent
|
||||||
|
delegate_to: localhost
|
||||||
|
tags:
|
||||||
|
- issue_905
|
@ -0,0 +1,51 @@
|
|||||||
|
- name: integration/ssh/password.yml
|
||||||
|
hosts: test-targets[0]
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
ansible_user: mitogen__user1
|
||||||
|
tasks:
|
||||||
|
- meta: reset_connection
|
||||||
|
- name: ansible_password
|
||||||
|
vars:
|
||||||
|
ansible_password: user1_password
|
||||||
|
ping:
|
||||||
|
|
||||||
|
- meta: reset_connection
|
||||||
|
- name: ansible_ssh_pass
|
||||||
|
vars:
|
||||||
|
ansible_ssh_pass: user1_password
|
||||||
|
ping:
|
||||||
|
|
||||||
|
- meta: reset_connection
|
||||||
|
- name: absent password should fail
|
||||||
|
ping:
|
||||||
|
ignore_errors: true
|
||||||
|
ignore_unreachable: true
|
||||||
|
register: ssh_no_password_result
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- ssh_no_password_result.unreachable == True
|
||||||
|
fail_msg: ssh_no_password_result={{ ssh_no_password_result }}
|
||||||
|
|
||||||
|
- meta: reset_connection
|
||||||
|
- name: ansible_ssh_pass should override ansible_password
|
||||||
|
ping:
|
||||||
|
vars:
|
||||||
|
ansible_password: wrong
|
||||||
|
ansible_ssh_pass: user1_password
|
||||||
|
|
||||||
|
# Tests that ansible_ssh_pass has priority over ansible_password
|
||||||
|
# and that a wrong password causes a target to be marked unreachable.
|
||||||
|
- meta: reset_connection
|
||||||
|
- name: ansible_password should not override
|
||||||
|
vars:
|
||||||
|
ansible_password: user1_password
|
||||||
|
ansible_ssh_pass: wrong
|
||||||
|
ping:
|
||||||
|
ignore_errors: true
|
||||||
|
ignore_unreachable: true
|
||||||
|
register: ssh_wrong_password_result
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- ssh_wrong_password_result.unreachable == True
|
||||||
|
fail_msg: ssh_wrong_password_result={{ ssh_wrong_password_result }}
|
@ -0,0 +1,43 @@
|
|||||||
|
- name: regression/issue_1087__template_streamerror.yml
|
||||||
|
# Ansible's template module has been seen to raise mitogen.core.StreamError
|
||||||
|
# iif there is a with_items loop and the destination path has an extension.
|
||||||
|
# This printed an error message and left file permissions incorrect,
|
||||||
|
# but did not cause the task/playbook to fail.
|
||||||
|
hosts: test-targets
|
||||||
|
gather_facts: false
|
||||||
|
become: false
|
||||||
|
vars:
|
||||||
|
foos:
|
||||||
|
- dest: /tmp/foo
|
||||||
|
- dest: /tmp/foo.txt
|
||||||
|
foo: Foo
|
||||||
|
bar: Bar
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: Test template does not cause StreamError
|
||||||
|
delegate_to: localhost
|
||||||
|
run_once: true
|
||||||
|
environment:
|
||||||
|
ANSIBLE_VERBOSITY: "{{ ansible_verbosity }}"
|
||||||
|
command:
|
||||||
|
cmd: >
|
||||||
|
ansible-playbook
|
||||||
|
{% for inv in ansible_inventory_sources %}
|
||||||
|
-i "{{ inv }}"
|
||||||
|
{% endfor %}
|
||||||
|
regression/template_test.yml
|
||||||
|
chdir: ../
|
||||||
|
register: issue_1087_cmd
|
||||||
|
failed_when:
|
||||||
|
- issue_1087_cmd is failed
|
||||||
|
or issue_1087_cmd.stdout is search('ERROR|mitogen\.core\.CallError')
|
||||||
|
or issue_1087_cmd.stderr is search('ERROR|mitogen\.core\.CallError')
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup
|
||||||
|
file:
|
||||||
|
path: "{{ item.dest }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{ foos }}"
|
||||||
|
tags:
|
||||||
|
- issue_1087
|
@ -0,0 +1,28 @@
|
|||||||
|
- name: regression/template_test.yml
|
||||||
|
# Ansible's template module has been seen to raise mitogen.core.StreamError
|
||||||
|
# iif there is a with_items loop and the destination path has an extension
|
||||||
|
hosts: test-targets
|
||||||
|
gather_facts: false
|
||||||
|
become: false
|
||||||
|
vars:
|
||||||
|
foos:
|
||||||
|
- dest: /tmp/foo
|
||||||
|
- dest: /tmp/foo.txt
|
||||||
|
foo: Foo
|
||||||
|
bar: Bar
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: Template files
|
||||||
|
template:
|
||||||
|
src: foo.bar.j2
|
||||||
|
dest: "{{ item.dest }}"
|
||||||
|
mode: u=rw,go=r
|
||||||
|
# This has to be with_items, loop: doesn't trigger the bug
|
||||||
|
with_items: "{{ foos }}"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup
|
||||||
|
file:
|
||||||
|
path: "{{ item.dest }}"
|
||||||
|
state: absent
|
||||||
|
with_items: "{{ foos }}"
|
@ -0,0 +1 @@
|
|||||||
|
A {{ foo }} walks into a {{ bar }}. Ow!
|
@ -0,0 +1,39 @@
|
|||||||
|
[test-targets]
|
||||||
|
{% for c in containers %}
|
||||||
|
{{ c.name }} ansible_host={{ c.hostname }} ansible_port={{ c.port }} ansible_python_interpreter={{ c.python_path }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
[test-targets:vars]
|
||||||
|
ansible_user=mitogen__has_sudo_nopw
|
||||||
|
ansible_password=has_sudo_nopw_password
|
||||||
|
|
||||||
|
{% for distro, hostnames in distros | dictsort %}
|
||||||
|
[{{ distro }}]
|
||||||
|
{% for hostname in hostnames %}
|
||||||
|
{{ hostname }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for family, hostnames in families | dictsort %}
|
||||||
|
[{{ family }}]
|
||||||
|
{% for hostname in hostnames %}
|
||||||
|
{{ hostname }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
[linux:children]
|
||||||
|
test-targets
|
||||||
|
|
||||||
|
[linux_containers:children]
|
||||||
|
test-targets
|
||||||
|
|
||||||
|
[issue905]
|
||||||
|
{% for c in containers[:1] %}
|
||||||
|
ssh-common-args ansible_host={{ c.hostname }} ansible_port={{ c.port }} ansible_python_interpreter={{ c.python_path }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
[issue905:vars]
|
||||||
|
ansible_user=mitogen__has_sudo_nopw
|
||||||
|
ansible_password=has_sudo_nopw_password
|
||||||
|
ansible_ssh_common_args=-o PermitLocalCommand=yes -o LocalCommand="touch {{ '{{' }} ssh_args_canary_file {{ '}}' }}"
|
||||||
|
ssh_args_canary_file=/tmp/ssh_args_{{ '{{' }} inventory_hostname {{ '}}' }}
|
Loading…
Reference in New Issue