Merge commit 'cea2e7b98dc9e255b87f64471ed808a8e004afc1' into release-0.3.10
commit
6f903b28de
@ -1,92 +1,94 @@
|
||||
# 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
|
||||
tasks:
|
||||
- name: Create tiny file
|
||||
copy:
|
||||
dest: /tmp/copy-tiny-file
|
||||
content:
|
||||
this is a tiny file.
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
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
|
||||
|
||||
- name: Create large file
|
||||
files: "{{ sourced_files + inline_files }}"
|
||||
tasks:
|
||||
- name: Create sourced files
|
||||
copy:
|
||||
dest: /tmp/copy-large-file
|
||||
# Must be larger than Connection.SMALL_SIZE_LIMIT.
|
||||
content: "{% for x in range(200000) %}x{% endfor %}"
|
||||
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 copied files
|
||||
- name: Cleanup lingering destination files
|
||||
file:
|
||||
path: "{{ item.dest }}"
|
||||
state: absent
|
||||
path: "{{item}}"
|
||||
with_items:
|
||||
- /tmp/copy-tiny-file.out
|
||||
- /tmp/copy-large-file.out
|
||||
- /tmp/copy-tiny-inline-file.out
|
||||
- /tmp/copy-large-inline-file.out
|
||||
with_items: "{{ files }}"
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
|
||||
- name: Copy large file
|
||||
- name: Copy sourced files
|
||||
copy:
|
||||
dest: /tmp/copy-large-file.out
|
||||
src: /tmp/copy-large-file
|
||||
|
||||
- name: Copy tiny file
|
||||
copy:
|
||||
dest: /tmp/copy-tiny-file.out
|
||||
src: /tmp/copy-tiny-file
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: u=rw,go=r
|
||||
with_items: "{{ sourced_files }}"
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
|
||||
- name: Copy tiny inline file
|
||||
- name: Copy inline files
|
||||
copy:
|
||||
dest: /tmp/copy-tiny-inline-file.out
|
||||
content: "tiny inline content"
|
||||
|
||||
- name: Copy large inline file
|
||||
copy:
|
||||
dest: /tmp/copy-large-inline-file.out
|
||||
content: |
|
||||
{% for x in range(200000) %}y{% endfor %}
|
||||
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}}"
|
||||
with_items:
|
||||
- /tmp/copy-tiny-file.out
|
||||
- /tmp/copy-large-file.out
|
||||
- /tmp/copy-tiny-inline-file.out
|
||||
- /tmp/copy-large-inline-file.out
|
||||
path: "{{ item.dest }}"
|
||||
with_items: "{{ files }}"
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
register: stat
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- stat.results[0].stat.checksum == "f29faa9a6f19a700a941bf2aa5b281643c4ec8a0"
|
||||
- stat.results[1].stat.checksum == "62951f943c41cdd326e5ce2b53a779e7916a820d"
|
||||
- stat.results[2].stat.checksum == "b26dd6444595e2bdb342aa0a91721b57478b5029"
|
||||
- stat.results[3].stat.checksum == "d675f47e467eae19e49032a2cc39118e12a6ee72"
|
||||
fail_msg: stat={{stat}}
|
||||
- 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 files
|
||||
- name: Cleanup destination files
|
||||
file:
|
||||
path: "{{ item.dest }}"
|
||||
state: absent
|
||||
path: "{{item}}"
|
||||
with_items:
|
||||
- /tmp/copy-tiny-file
|
||||
- /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)
|
||||
with_items: "{{ files }}"
|
||||
loop_control:
|
||||
label: "{{ item.dest }}"
|
||||
tags:
|
||||
- copy
|
||||
- issue_1110
|
||||
|
@ -1,3 +1,5 @@
|
||||
- import_playbook: args.yml
|
||||
- import_playbook: config.yml
|
||||
- import_playbook: password.yml
|
||||
- import_playbook: timeouts.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