More test fixes for split controller/remote tests.

This commit is contained in:
Matt Clay 2019-01-25 19:37:56 -08:00
parent 73636175da
commit a8116497ba
49 changed files with 217 additions and 135 deletions

View file

@ -84,7 +84,7 @@
- debug: msg="TEST COMPLETE" - debug: msg="TEST COMPLETE"
- name: block with includes - name: block with includes
hosts: localhost hosts: testhost
gather_facts: yes gather_facts: yes
strategy: "{{test_strategy|default('linear')}}" strategy: "{{test_strategy|default('linear')}}"
vars: vars:

View file

@ -1,6 +1,6 @@
--- ---
# Run withhout --check # Run withhout --check
- hosts: localhost - hosts: testhost
gather_facts: False gather_facts: False
tasks: tasks:
- command: 'echo ran' - command: 'echo ran'
@ -12,7 +12,7 @@
that: that:
- '"ran" in command_out["stdout"]' - '"ran" in command_out["stdout"]'
- hosts: localhost - hosts: testhost
gather_facts: False gather_facts: False
check_mode: True check_mode: True
tasks: tasks:
@ -24,7 +24,7 @@
that: that:
- '"check mode" in command_out["msg"]' - '"check mode" in command_out["msg"]'
- hosts: localhost - hosts: testhost
gather_facts: False gather_facts: False
tasks: tasks:
- command: 'echo ran' - command: 'echo ran'

View file

@ -1,6 +1,6 @@
--- ---
# Run with --check # Run with --check
- hosts: localhost - hosts: testhost
gather_facts: False gather_facts: False
tasks: tasks:
- command: 'echo ran' - command: 'echo ran'
@ -11,7 +11,7 @@
that: that:
- '"check mode" in command_out["msg"]' - '"check mode" in command_out["msg"]'
- hosts: localhost - hosts: testhost
gather_facts: False gather_facts: False
check_mode: False check_mode: False
tasks: tasks:
@ -23,7 +23,7 @@
that: that:
- '"ran" in command_out["stdout"]' - '"ran" in command_out["stdout"]'
- hosts: localhost - hosts: testhost
gather_facts: False gather_facts: False
tasks: tasks:
- command: 'echo ran' - command: 'echo ran'

View file

@ -1,3 +1,10 @@
- hosts: testhost
gather_facts: no
tasks:
- name: get PATH from target
command: echo $PATH
register: target_path
- hosts: testhost - hosts: testhost
vars: vars:
- test1: - test1:
@ -9,7 +16,7 @@
- name: ensure special case with ansible_env is skipped but others still work - name: ensure special case with ansible_env is skipped but others still work
assert: assert:
that: that:
- lookup('env', 'PATH') == ansible_env.PATH - target_path.stdout == ansible_env.PATH
- "'/lola' not in ansible_env.PATH" - "'/lola' not in ansible_env.PATH"
- ansible_env.lola == 'ido' - ansible_env.lola == 'ido'

View file

@ -396,8 +396,8 @@
- name: Test headers string - name: Test headers string
assert: assert:
that: that:
- (result["content"] | b64decode | from_json).headers.get('Foo') == 'bar' - (result.content | b64decode | from_json).headers.get('Foo') == 'bar'
- (result["content"] | b64decode | from_json).headers.get('Baz') == 'qux' - (result.content | b64decode | from_json).headers.get('Baz') == 'qux'
- name: Test headers string invalid format - name: Test headers string invalid format
get_url: get_url:
@ -425,8 +425,8 @@
- name: Test headers dict - name: Test headers dict
assert: assert:
that: that:
- (result["content"] | b64decode | from_json).headers.get('Foo') == 'bar' - (result.content | b64decode | from_json).headers.get('Foo') == 'bar'
- (result["content"] | b64decode | from_json).headers.get('Baz') == 'qux' - (result.content | b64decode | from_json).headers.get('Baz') == 'qux'
- name: Test client cert auth, with certs - name: Test client cert auth, with certs
get_url: get_url:
@ -444,5 +444,5 @@
- name: Assert that the ssl_client_verify file contains the correct content - name: Assert that the ssl_client_verify file contains the correct content
assert: assert:
that: that:
- '(result["content"] | b64decode) == "ansible.http.tests:SUCCESS"' - '(result.content | b64decode) == "ansible.http.tests:SUCCESS"'
when: has_httptester when: has_httptester

View file

@ -169,7 +169,7 @@
- name: DEPTH | check update arrived - name: DEPTH | check update arrived
assert: assert:
that: that:
- "{{ a_file['content'] | b64decode | trim }} == 3" - "{{ a_file.content | b64decode | trim }} == 3"
- git_fetch is changed - git_fetch is changed
- name: DEPTH | clear checkout_dir - name: DEPTH | clear checkout_dir

View file

@ -47,7 +47,7 @@
- name: LOCALMODS | check update arrived - name: LOCALMODS | check update arrived
assert: assert:
that: that:
- "{{ a_file['content'] | b64decode | trim }} == 2" - "{{ a_file.content | b64decode | trim }} == 2"
- git_fetch_force is changed - git_fetch_force is changed
- name: LOCALMODS | clear checkout_dir - name: LOCALMODS | clear checkout_dir
@ -105,7 +105,7 @@
- name: LOCALMODS | check update arrived - name: LOCALMODS | check update arrived
assert: assert:
that: that:
- "{{ a_file['content'] | b64decode | trim }} == 2" - "{{ a_file.content | b64decode | trim }} == 2"
- git_fetch_force is changed - git_fetch_force is changed
- name: LOCALMODS | clear checkout_dir - name: LOCALMODS | clear checkout_dir

View file

@ -18,13 +18,13 @@
- name: debug hash behaviour result - name: debug hash behaviour result
debug: debug:
var: ansible_env.ANSIBLE_HASH_BEHAVIOUR var: "{{ lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') }}"
verbosity: 2 verbosity: 2
- name: assert hash behaviour is merge or replace - name: assert hash behaviour is merge or replace
assert: assert:
that: that:
- ansible_env.ANSIBLE_HASH_BEHAVIOUR in ('merge', 'replace') - lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') in ('merge', 'replace')
- name: debug test_hash var - name: debug test_hash var
debug: debug:
@ -34,4 +34,4 @@
- name: assert the dictionary values match - name: assert the dictionary values match
assert: assert:
that: that:
- "ansible_env.ANSIBLE_HASH_BEHAVIOUR == 'merge' and test_hash == merged_hash or ansible_env.ANSIBLE_HASH_BEHAVIOUR == 'replace' and test_hash == replaced_hash" - "lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') == 'merge' and test_hash == merged_hash or lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') == 'replace' and test_hash == replaced_hash"

View file

@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir

View file

@ -18,7 +18,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: record the output directory - name: record the output directory
set_fact: output_file={{output_dir}}/foo.ini set_fact: output_file={{ remote_tmp_dir }}/foo.ini
- name: add "fav=lemonade" is in section "[drinks]" in specified file - name: add "fav=lemonade" is in section "[drinks]" in specified file
ini_file: ini_file:
@ -34,13 +34,18 @@
- result1.changed == True - result1.changed == True
- result1.msg == 'section and option added' - result1.msg == 'section and option added'
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
expected1: |- expected1: |
[drinks] [drinks]
fav = lemonade fav = lemonade
content1: "{{ lookup('file', output_file) }}" content1: "{{ output_content.content | b64decode }}"
- name: Verify content of ini file is as expected - name: Verify content of ini file is as expected
assert: assert:
@ -69,14 +74,19 @@
value: coke value: coke
register: result3 register: result3
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
expected3: |- expected3: |
[drinks] [drinks]
fav = lemonade fav = lemonade
beverage = coke beverage = coke
content3: "{{ lookup('file', output_file) }}" content3: "{{ output_content.content | b64decode }}"
- name: assert 'changed' is true and content is OK - name: assert 'changed' is true and content is OK
assert: assert:
@ -93,9 +103,14 @@
state: absent state: absent
register: result4 register: result4
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: get ini file content - name: get ini file content
set_fact: set_fact:
content4: "{{ lookup('file', output_file) }}" content4: "{{ output_content.content | b64decode }}"
- name: assert changed and content is as expected - name: assert changed and content is as expected
assert: assert:
@ -111,16 +126,21 @@
state: absent state: absent
register: result5 register: result5
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: get current ini file content - name: get current ini file content
set_fact: set_fact:
content5: "{{ lookup('file', output_file) }}" content5: "{{ output_content.content | b64decode }}"
- name: assert changed and content is empty - name: assert changed and content is empty
assert: assert:
that: that:
- result5.changed == True - result5.changed == True
- result5.msg == 'section removed' - result5.msg == 'section removed'
- content5 == "" - content5 == "\n"
# allow_no_value # allow_no_value
@ -163,11 +183,16 @@
- { o: "skip-name-resolve", v: null } - { o: "skip-name-resolve", v: null }
- { o: "max_connections", v: "500" } - { o: "max_connections", v: "500" }
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
content7: "{{ lookup('file', output_file) }}" content7: "{{ output_content.content | b64decode }}"
expected7: |- expected7: |
[mysqld] [mysqld]
skip-name skip-name
skip-name-resolve skip-name-resolve
@ -186,11 +211,16 @@
value: myvalue value: myvalue
register: result8 register: result8
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
content8: "{{ lookup('file', output_file) }}" content8: "{{ output_content.content | b64decode }}"
expected8: |- expected8: |
[mysqld] [mysqld]
skip-name = myvalue skip-name = myvalue
skip-name-resolve skip-name-resolve
@ -211,11 +241,16 @@
allow_no_value: yes allow_no_value: yes
register: result9 register: result9
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
content9: "{{ lookup('file', output_file) }}" content9: "{{ output_content.content | b64decode }}"
expected9: |- expected9: |
[mysqld] [mysqld]
skip-name skip-name
skip-name-resolve skip-name-resolve
@ -236,11 +271,16 @@
state: absent state: absent
register: result10 register: result10
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
content10: "{{ lookup('file', output_file) }}" content10: "{{ output_content.content | b64decode }}"
expected10: |- expected10: |
[mysqld] [mysqld]
skip-name skip-name
max_connections = 500 max_connections = 500
@ -266,10 +306,15 @@
value: coke value: coke
register: result11 register: result11
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
expected11: "beverage = coke" expected11: "beverage = coke\n\n"
content11: "{{ lookup('file', output_file) }}" content11: "{{ output_content.content | b64decode }}"
- name: assert 'changed' is true and content is OK (no section) - name: assert 'changed' is true and content is OK (no section)
assert: assert:
@ -286,11 +331,16 @@
section: section:
register: result12 register: result12
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
expected12: "beverage = water" expected12: "beverage = water\n\n"
content12: "{{ lookup('file', output_file) }}" content12: "{{ output_content.content | b64decode }}"
- name: assert 'changed' is true and content is OK (no section) - name: assert 'changed' is true and content is OK (no section)
assert: assert:
@ -307,16 +357,21 @@
state: absent state: absent
register: result13 register: result13
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: get current ini file content - name: get current ini file content
set_fact: set_fact:
content13: "{{ lookup('file', output_file) }}" content13: "{{ output_content.content | b64decode }}"
- name: assert changed (no section) - name: assert changed (no section)
assert: assert:
that: that:
- result13 is changed - result13 is changed
- result13.msg == 'option changed' - result13.msg == 'option changed'
- content13 == "" - content13 == "\n"
- name: Check add option without section before existing section - name: Check add option without section before existing section
block: block:
@ -333,14 +388,19 @@
option: like option: like
value: tea value: tea
- name: read content from output file
slurp:
src: "{{ output_file }}"
register: output_content
- name: set expected content and get current ini file content - name: set expected content and get current ini file content
set_fact: set_fact:
expected14: |- expected14: |
like = tea like = tea
[drinks] [drinks]
beverage = water beverage = water
content14: "{{ lookup('file', output_file) }}" content14: "{{ output_content.content | b64decode }}"
- name: Verify content of ini file is as expected - name: Verify content of ini file is as expected
assert: assert:

View file

@ -0,0 +1 @@
bar

View file

@ -0,0 +1 @@
foo

View file

@ -201,25 +201,19 @@
# WITH_FIRST_FOUND # WITH_FIRST_FOUND
- name: create file for test
shell: echo "foo" > {{ output_dir }}/foo1
- name: create file for test
shell: echo "bar" > {{ output_dir }}/bar1
- name: test with_first_found - name: test with_first_found
#shell: echo {{ item }} #shell: echo {{ item }}
set_fact: "first_found={{ item }}" set_fact: "first_found={{ item }}"
with_first_found: with_first_found:
- "{{ output_dir + '/does_not_exist' }}" - "{{ role_path + '/files/does_not_exist' }}"
- "{{ output_dir + '/foo1' }}" - "{{ role_path + '/files/foo1' }}"
- "{{ output_dir + '/bar1' }}" - "{{ role_path + '/files/bar1' }}"
- name: set expected - name: set expected
set_fact: first_expected="{{ output_dir | expanduser + '/foo1' }}" set_fact: first_expected="{{ role_path + '/files/foo1' }}"
- name: set unexpected - name: set unexpected
set_fact: first_unexpected="{{ output_dir | expanduser + '/bar1' }}" set_fact: first_unexpected="{{ role_path + '/files/bar1' }}"
- name: verify with_first_found results - name: verify with_first_found results
assert: assert:

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
tasks: tasks:
- name: Use standard ping module - name: Use standard ping module

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
tasks: tasks:
- name: Use ping from library path - name: Use ping from library path

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
vars: vars:
expected_location: "role: foo" expected_location: "role: foo"

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
vars: vars:
expected_location: "role: bar" expected_location: "role: bar"

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
roles: roles:
- foo - foo

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
tasks: tasks:
- name: Use a specially crafted module to see if things were imported correctly - name: Use a specially crafted module to see if things were imported correctly

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
gather_facts: no gather_facts: no
tasks: tasks:
- name: Use a specially crafted module to see if things were imported correctly - name: Use a specially crafted module to see if things were imported correctly

View file

@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir

View file

@ -27,8 +27,13 @@
that: that:
- 'goodbye_ansible.msg == "Goodbye, Ansible!"' - 'goodbye_ansible.msg == "Goodbye, Ansible!"'
- name: Copy module to remote
copy:
src: "{{ role_path }}/library/helloworld.sh"
dest: "{{ remote_tmp_dir }}/helloworld.sh"
- name: Execute module directly - name: Execute module directly
command: '/bin/sh {{ role_path }}/library/helloworld.sh' command: '/bin/sh {{ remote_tmp_dir }}/helloworld.sh'
register: direct register: direct
ignore_errors: true ignore_errors: true

View file

@ -1,4 +1,4 @@
- hosts: localhost - hosts: testhost
serial: "{{ testing_omitted_variable | default(omit) }}" serial: "{{ testing_omitted_variable | default(omit) }}"
tasks: tasks:
- debug: - debug:

View file

@ -1,2 +1,2 @@
setup/always/setup_pexpect needs/target/setup_pexpect
shippable/posix/group3 shippable/posix/group3

View file

@ -1,5 +1,5 @@
- name: Test pause module in default state - name: Test pause module in default state
hosts: testhost hosts: localhost
become: no become: no
gather_facts: no gather_facts: no

View file

@ -1,5 +1,5 @@
- name: Test pause module with custom prompt - name: Test pause module with custom prompt
hosts: testhost hosts: localhost
become: no become: no
gather_facts: no gather_facts: no

View file

@ -1,5 +1,5 @@
- name: Test pause module with pause - name: Test pause module with pause
hosts: testhost hosts: localhost
become: no become: no
gather_facts: no gather_facts: no

View file

@ -1,5 +1,5 @@
- name: Test pause module with pause and custom prompt - name: Test pause module with pause and custom prompt
hosts: testhost hosts: localhost
become: no become: no
gather_facts: no gather_facts: no

View file

@ -1,5 +1,5 @@
- name: Test pause module echo output - name: Test pause module echo output
hosts: testhost hosts: localhost
become: no become: no
gather_facts: no gather_facts: no

View file

@ -2,10 +2,12 @@
set -eux set -eux
ANSIBLE_ROLES_PATH=../ ansible-playbook setup.yml
# Test pause module when no tty and non-interactive. This is to prevent playbooks # Test pause module when no tty and non-interactive. This is to prevent playbooks
# from hanging in cron and Tower jobs. # from hanging in cron and Tower jobs.
/usr/bin/env bash << EOF /usr/bin/env bash << EOF
ansible-playbook test-pause-no-tty.yml -i ../../inventory 2>&1 | \ ansible-playbook test-pause-no-tty.yml 2>&1 | \
grep '\[WARNING\]: Not waiting for response to prompt as stdin is not interactive' && { grep '\[WARNING\]: Not waiting for response to prompt as stdin is not interactive' && {
echo 'Successfully skipped pause in no TTY mode' >&2 echo 'Successfully skipped pause in no TTY mode' >&2
exit 0 exit 0
@ -17,12 +19,12 @@ EOF
# Test redirecting stdout # Test redirecting stdout
# Issue #41717 # Issue #41717
ansible-playbook pause-3.yml -i ../../inventory > /dev/null \ ansible-playbook pause-3.yml > /dev/null \
&& echo "Successfully redirected stdout" \ && echo "Successfully redirected stdout" \
|| echo "Failure when attempting to redirect stdout" || echo "Failure when attempting to redirect stdout"
# Test pause with seconds and minutes specified # Test pause with seconds and minutes specified
ansible-playbook test-pause.yml -i ../../inventory "$@" ansible-playbook test-pause.yml "$@"
# Interactively test pause # Interactively test pause
python test-pause.py -i ../../inventory "$@" python test-pause.py "$@"

View file

@ -0,0 +1,4 @@
- hosts: localhost
gather_facts: no
roles:
- setup_pexpect

View file

@ -1,5 +1,5 @@
- name: Test pause - name: Test pause
hosts: testhost hosts: localhost
gather_facts: no gather_facts: no
become: no become: no

View file

@ -1,5 +1,5 @@
- name: Test pause - name: Test pause
hosts: testhost hosts: localhost
gather_facts: no gather_facts: no
become: no become: no

View file

@ -61,7 +61,6 @@
unique: no unique: no
delimiter: ';' delimiter: ';'
register: users_nonunique register: users_nonunique
delegate_to: localhost
- assert: - assert:
that: that:
@ -96,7 +95,6 @@
dag,500,500,Dag Wieërs dag,500,500,Dag Wieërs
jeroen,501,500,Jeroen Hoekx jeroen,501,500,Jeroen Hoekx
dest: users_noheader.csv dest: users_noheader.csv
delegate_to: localhost
# Read a CSV file and access user 'dag' # Read a CSV file and access user 'dag'
- name: Read users from CSV file and return a dictionary - name: Read users from CSV file and return a dictionary

View file

@ -45,7 +45,6 @@
assert: assert:
that: that:
- "script_result0.rc == 0" - "script_result0.rc == 0"
- "script_result0.stderr == ''"
- "script_result0.stdout == 'win'" - "script_result0.stdout == 'win'"
- name: Execute a script with a space in the path - name: Execute a script with a space in the path

View file

@ -1 +1,2 @@
shippable/posix/group1 shippable/posix/group1
needs/root

View file

@ -22,24 +22,23 @@
- default - default
register: client register: client
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ client_file }}" src: "{{ client_file }}"
register: client_stat register: client_config
- name: Assert that client data was set successfully and properly - name: Assert that client data was set successfully and properly
assert: assert:
that: that:
- "client is successful" - "client is successful"
- "client is changed" - "client is changed"
- "client_stat.stat.exists == true"
- "client['config']['name'] == 'client'" - "client['config']['name'] == 'client'"
- "'default' in client['config']['subscriptions']" - "'default' in client['config']['subscriptions']"
- "client['file'] == client_file" - "client['file'] == client_file"
- name: Assert that the client configuration file is actually configured properly - name: Assert that the client configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', client_file) | from_json }}" config: "{{ client_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "config['client']['keepalives'] == true" - "config['client']['keepalives'] == true"
@ -129,10 +128,10 @@
occurrences: "3" occurrences: "3"
register: client_twice register: client_twice
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ client_file }}" src: "{{ client_file }}"
register: client_stat register: client_config
- name: Assert that client data was set successfully and properly - name: Assert that client data was set successfully and properly
assert: assert:
@ -141,7 +140,6 @@
- "client is changed" - "client is changed"
- "client_twice is successful" - "client_twice is successful"
- "client_twice is not changed" - "client_twice is not changed"
- "client_stat.stat.exists == true"
- "client['config']['name'] == 'custom'" - "client['config']['name'] == 'custom'"
- "client['config']['address'] == 'host.fqdn'" - "client['config']['address'] == 'host.fqdn'"
- "'default' in client['config']['subscriptions']" - "'default' in client['config']['subscriptions']"
@ -155,7 +153,7 @@
- name: Assert that the client configuration file is actually configured properly - name: Assert that the client configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', client_file) | from_json }}" config: "{{ client_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "config['client']['name'] == 'custom'" - "config['client']['name'] == 'custom'"

View file

@ -1 +1,2 @@
shippable/posix/group1 shippable/posix/group1
needs/root

View file

@ -28,10 +28,10 @@
state: "present" state: "present"
register: handler_twice register: handler_twice
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ handler['file'] }}" src: "{{ handler['file'] }}"
register: handler_stat register: handler_config
- name: Assert that handler data was set successfully and properly - name: Assert that handler data was set successfully and properly
assert: assert:
@ -40,7 +40,6 @@
- "handler is changed" - "handler is changed"
- "handler_twice is successful" - "handler_twice is successful"
- "handler_twice is not changed" - "handler_twice is not changed"
- "handler_stat.stat.exists == true"
- "handler['name'] == 'handler'" - "handler['name'] == 'handler'"
- "handler['file'] == '/etc/sensu/conf.d/handlers/handler.json'" - "handler['file'] == '/etc/sensu/conf.d/handlers/handler.json'"
- "handler['config']['type'] == 'pipe'" - "handler['config']['type'] == 'pipe'"
@ -51,7 +50,7 @@
- name: Assert that the handler configuration file is actually configured properly - name: Assert that the handler configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', handler['file']) | from_json }}" config: "{{ handler_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "'handler' in config['handlers']" - "'handler' in config['handlers']"

View file

@ -19,17 +19,16 @@
- anotherhandler - anotherhandler
register: handler register: handler
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ handler['file'] }}" src: "{{ handler['file'] }}"
register: handler_stat register: handler_config
- name: Validate set handler return data - name: Validate set handler return data
assert: assert:
that: that:
- "handler is successful" - "handler is successful"
- "handler is changed" - "handler is changed"
- "handler_stat.stat.exists == true"
- "handler['name'] == 'set'" - "handler['name'] == 'set'"
- "handler['file'] == '/etc/sensu/conf.d/handlers/set.json'" - "handler['file'] == '/etc/sensu/conf.d/handlers/set.json'"
- "handler['config']['type'] == 'set'" - "handler['config']['type'] == 'set'"
@ -39,7 +38,7 @@
- name: Assert that the handler configuration file is actually configured properly - name: Assert that the handler configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', handler['file']) | from_json }}" config: "{{ handler_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "'set' in config['handlers']" - "'set' in config['handlers']"

View file

@ -20,17 +20,16 @@
port: 8000 port: 8000
register: handler register: handler
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ handler['file'] }}" src: "{{ handler['file'] }}"
register: handler_stat register: handler_config
- name: Validate tcp handler return data - name: Validate tcp handler return data
assert: assert:
that: that:
- "handler is successful" - "handler is successful"
- "handler is changed" - "handler is changed"
- "handler_stat.stat.exists == true"
- "handler['name'] == 'tcp'" - "handler['name'] == 'tcp'"
- "handler['file'] == '/etc/sensu/conf.d/handlers/tcp.json'" - "handler['file'] == '/etc/sensu/conf.d/handlers/tcp.json'"
- "handler['config']['type'] == 'tcp'" - "handler['config']['type'] == 'tcp'"
@ -41,7 +40,7 @@
- name: Assert that the handler configuration file is actually configured properly - name: Assert that the handler configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', handler['file']) | from_json }}" config: "{{ handler_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "'tcp' in config['handlers']" - "'tcp' in config['handlers']"

View file

@ -20,17 +20,16 @@
name: "transport_handler" name: "transport_handler"
register: handler register: handler
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ handler['file'] }}" src: "{{ handler['file'] }}"
register: handler_stat register: handler_config
- name: Validate transport handler return data - name: Validate transport handler return data
assert: assert:
that: that:
- "handler is successful" - "handler is successful"
- "handler is changed" - "handler is changed"
- "handler_stat.stat.exists == true"
- "handler['name'] == 'transport'" - "handler['name'] == 'transport'"
- "handler['file'] == '/etc/sensu/conf.d/handlers/transport.json'" - "handler['file'] == '/etc/sensu/conf.d/handlers/transport.json'"
- "handler['config']['type'] == 'transport'" - "handler['config']['type'] == 'transport'"
@ -41,7 +40,7 @@
- name: Assert that the handler configuration file is actually configured properly - name: Assert that the handler configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', handler['file']) | from_json }}" config: "{{ handler_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "'transport' in config['handlers']" - "'transport' in config['handlers']"

View file

@ -20,17 +20,16 @@
port: 8000 port: 8000
register: handler register: handler
- name: Retrieve configuration file stat - name: Retrieve configuration file
stat: slurp:
path: "{{ handler['file'] }}" src: "{{ handler['file'] }}"
register: handler_stat register: handler_config
- name: Validate udp handler return data - name: Validate udp handler return data
assert: assert:
that: that:
- "handler is successful" - "handler is successful"
- "handler is changed" - "handler is changed"
- "handler_stat.stat.exists == true"
- "handler['name'] == 'udp'" - "handler['name'] == 'udp'"
- "handler['file'] == '/etc/sensu/conf.d/handlers/udp.json'" - "handler['file'] == '/etc/sensu/conf.d/handlers/udp.json'"
- "handler['config']['type'] == 'udp'" - "handler['config']['type'] == 'udp'"
@ -41,7 +40,7 @@
- name: Assert that the handler configuration file is actually configured properly - name: Assert that the handler configuration file is actually configured properly
vars: vars:
config: "{{ lookup('file', handler['file']) | from_json }}" config: "{{ handler_config.content | b64decode | from_json }}"
assert: assert:
that: that:
- "'udp' in config['handlers']" - "'udp' in config['handlers']"

View file

@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir

View file

@ -1,12 +1,15 @@
- shell: mktemp - set_fact:
register: temppath temppath: "{{ remote_tmp_dir }}/output.txt"
- include: taskorder-include.yml - include: taskorder-include.yml
with_items: with_items:
- 1 - 1
- 2 - 2
- 3 - 3
- assert: - slurp:
that: lookup('file', temppath.stdout) == "one.1.two.1.three.1.four.1.one.2.two.2.three.2.four.2.one.3.two.3.three.3.four.3." src: "{{ temppath }}"
register: tempout
- file: path="{{temppath.stdout}}" state=absent - assert:
that: tempout.content | b64decode == "one.1.two.1.three.1.four.1.one.2.two.2.three.2.four.2.one.3.two.3.three.3.four.3."

View file

@ -2,9 +2,9 @@
# There have been regressions where included tasks and # There have been regressions where included tasks and
# nested blocks ran out of order... # nested blocks ran out of order...
- shell: printf one.{{ item }}. >> {{ temppath.stdout }} - shell: printf one.{{ item }}. >> {{ temppath }}
- block: - block:
- shell: printf two.{{ item }}. >> {{ temppath.stdout }} - shell: printf two.{{ item }}. >> {{ temppath }}
- block: - block:
- shell: printf three.{{ item }}. >> {{ temppath.stdout }} - shell: printf three.{{ item }}. >> {{ temppath }}
- shell: printf four.{{ item }}. >> {{ temppath.stdout }} - shell: printf four.{{ item }}. >> {{ temppath }}

View file

@ -1,6 +1,6 @@
--- ---
- name: 'Test templating in name' - name: 'Test templating in name'
hosts: localhost hosts: testhost
connection: local connection: local
vars: vars:
a_list: a_list:

View file

@ -0,0 +1,2 @@
dependencies:
- setup_remote_tmp_dir

View file

@ -27,8 +27,13 @@
that: that:
- 'goodbye_ansible.msg == "Goodbye, Ansible!"' - 'goodbye_ansible.msg == "Goodbye, Ansible!"'
- name: Copy module to remote
copy:
src: "{{ role_path }}/library/helloworld.py"
dest: "{{ remote_tmp_dir }}/helloworld.py"
- name: Execute module directly - name: Execute module directly
command: '{{ ansible_python_interpreter|default(ansible_playbook_python) }} {{ role_path }}/library/helloworld.py' command: '{{ ansible_python_interpreter|default(ansible_playbook_python) }} {{ remote_tmp_dir }}/helloworld.py'
register: direct register: direct
ignore_errors: true ignore_errors: true