Merge remote-tracking branch 'ansible/devel' into devel

This commit is contained in:
Yannig Perré
2015-08-05 11:20:41 +02:00
763 changed files with 24732 additions and 13274 deletions

View File

@@ -24,11 +24,7 @@ CONSUL_RUNNING := $(shell python consul_running.py)
all: parsing test_var_precedence unicode test_templating_settings non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault test_tags
parsing:
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario1; [ $$? -eq 3 ]
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario2; [ $$? -eq 3 ]
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario3; [ $$? -eq 3 ]
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario4; [ $$? -eq 3 ]
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario5; [ $$? -eq 3 ]
ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario5
ansible-playbook good_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
includes:
@@ -55,7 +51,8 @@ test_group_by:
ansible-playbook test_group_by.yml -i inventory.group_by -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
test_handlers:
ansible-playbook test_handlers.yml -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
ansible-playbook test_handlers.yml --tags scenario1 -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
[ "$$(ansible-playbook test_handlers.yml --tags scenario2 -l A -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) | grep -Po 'RUNNING HANDLER \[test_handlers : \K[^\]]+')" = "test handler" ]
# Not forcing, should only run on successful host
[ "$$(ansible-playbook test_force_handlers.yml --tags normal -i inventory.handlers -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs)" = "CALLED_HANDLER_B" ]
# Forcing from command line
@@ -76,7 +73,7 @@ test_hash:
ANSIBLE_HASH_BEHAVIOUR=merge ansible-playbook test_hash.yml -i $(INVENTORY) $(CREDENTIALS_ARG) -v -e '{"test_hash":{"extra_args":"this is an extra arg"}}'
test_var_precedence:
ansible-playbook test_var_precedence.yml -i $(INVENTORY) $(CREDENTIALS_ARG) -v -e 'extra_var=extra_var' -e 'extra_var_override=extra_var_override'
ansible-playbook test_var_precedence.yml -i $(INVENTORY) $(CREDENTIALS_ARG) $(TEST_FLAGS) -v -e 'extra_var=extra_var' -e 'extra_var_override=extra_var_override'
test_vault:
ansible-playbook test_vault.yml -i $(INVENTORY) $(CREDENTIALS_ARG) -v $(TEST_FLAGS) --vault-password-file $(VAULT_PASSWORD_FILE) --list-tasks
@@ -163,7 +160,7 @@ $(CONSUL_RUNNING):
consul:
ifeq ($(CONSUL_RUNNING), True)
ansible-playbook -i $(INVENTORY) consul.yml ; \
ansible-playbook -i ../../plugins/inventory/consul_io.py consul_inventory.yml
ansible-playbook -i ../../contrib/inventory/consul_io.py consul_inventory.yml
else
@echo "Consul agent is not running locally. To run a cluster locally see http://github.com/sgargan/consul-vagrant"
endif

View File

@@ -138,6 +138,26 @@ def delete_rax_cdb(args):
args.assumeyes)
def _force_delete_rax_scaling_group(manager):
def wrapped(uri):
manager.api.method_delete('%s?force=true' % uri)
return wrapped
def delete_rax_scaling_group(args):
"""Function for deleting Autoscale Groups"""
print ("--- Cleaning Autoscale Groups matching '%s'" % args.match_re)
for region in pyrax.identity.services.autoscale.regions:
asg = pyrax.connect_to_autoscale(region=region)
for group in rax_list_iterator(asg):
if re.search(args.match_re, group.name):
group.manager._delete = \
_force_delete_rax_scaling_group(group.manager)
prompt_and_delete(group,
'Delete matching %s? [y/n]: ' % group,
args.assumeyes)
def main():
if not HAS_PYRAX:
raise SystemExit('The pyrax python module is required for this script')

View File

@@ -14,8 +14,8 @@ pem_file:
project_id:
# Azure Credentials
azure_subscription_id:
azure_cert_path:
azure_subscription_id: "{{ lookup('env', 'AZURE_SUBSCRIPTION_ID') }}"
azure_cert_path: "{{ lookup('env', 'AZURE_CERT_PATH') }}"
# GITHUB SSH private key - a path to a SSH private key for use with github.com
github_ssh_private_key: "{{ lookup('env','HOME') }}/.ssh/id_rsa"

View File

@@ -1,5 +1,5 @@
---
win_output_dir: 'C:/temp/'
win_output_dir: 'C:\ansible_testing'
output_dir: ~/ansible_testing
non_root_test_user: ansible
pip_test_package: epdb

View File

@@ -11,6 +11,15 @@
gather_facts: True
roles:
- { role: test_ping, tags: test_ping }
- { role: test_var_blending, parameterized_beats_default: 1234, tags: test_var_blending }
- { role: test_special_vars, tags: test_special_vars }
- { role: test_ignore_errors, tags: test_ignore_errors }
- { role: test_conditionals, tags: test_conditionals }
- { role: test_iterators, tags: test_iterators }
- { role: test_lookups, tags: test_lookups }
- { role: test_changed_when, tags: test_changed_when }
- { role: test_failed_when, tags: test_failed_when }
- { role: test_handlers, tags: test_handlers }
- { role: test_copy, tags: test_copy }
- { role: test_stat, tags: test_stat }
- { role: test_template, tags: test_template }
@@ -21,20 +30,12 @@
- { role: test_subversion, tags: test_subversion }
- { role: test_git, tags: test_git }
- { role: test_hg, tags: test_hg }
- { role: test_changed_when, tags: test_changed_when }
- { role: test_var_blending, parameterized_beats_default: 1234, tags: test_var_blending }
- { role: test_lineinfile, tags: test_lineinfile }
- { role: test_ignore_errors, tags: test_ignore_errors }
- { role: test_unarchive, tags: test_unarchive }
- { role: test_filters, tags: test_filters }
- { role: test_facts_d, tags: test_facts_d }
- { role: test_conditionals, tags: test_conditionals }
- { role: test_async, tags: test_async }
- { role: test_handlers, tags: test_handlers }
- { role: test_lookups, tags: test_lookups }
- { role: test_iterators, tags: test_iterators }
- { role: test_command_shell, tags: test_command_shell }
- { role: test_failed_when, tags: test_failed_when }
- { role: test_script, tags: test_script }
- { role: test_authorized_key, tags: test_authorized_key }
- { role: test_get_url, tags: test_get_url }

View File

@@ -40,3 +40,6 @@
- role: test_rax_cdb_database
tags: test_rax_cdb_database
- role: test_rax_scaling_group
tags: test_rax_scaling_group

View File

@@ -7,4 +7,12 @@ rackspace_flavor: "performance1-1"
rackspace_keypair_pub: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDymofzvt86DUA6XSSxc7eDHwUNvcOSmUWjB76jFvhYc6PbS5QmTzBtCka1ORdaW0Z2i3EjfFvzA8WvuY3qP/FpIVDL25ZqZHgxSfGN5pbJ2tAeXK165kNPXBuuISrMhmdLFbRZNn6PwKHEmtrtfEQ3w6ay9+MhqlEr0OX2r6bCXLj+f50QnQXamU6Fm4IpkTsb60osvHNi569Dd8cADEv92oLZpNMa8/MPGnlipjauhzNtEDTUeZwtrAQUXe6CzJ0QmIlyKDglDZLuAKU/VRumo1FRsn4AwJnVsbP2CHBPkbNoYt6LhQiQqXypEIWGmIln0dlO6gZTr3dYC4BVGREl"
resource_prefix: ansible-testing
resource_prefix: "ansible-testing"
rackspace_alt_image_id: "e5575e1a-a519-4e21-9a6b-41207833bd39"
rackspace_alt_image_name: "CentOS 6 (PVHVM)"
rackspace_alt_image_human_id: "centos-6-pvhvm"
rackspace_alt_flavor: "general1-1"
rackspace_wait_timeout: 600

View File

@@ -0,0 +1,3 @@
---
allow_duplicates: yes

View File

@@ -34,7 +34,6 @@
- "'delta' in async_result"
- "'end' in async_result"
- "'finished' in async_result"
- "'invocation' in async_result"
- "'rc' in async_result"
- "'start' in async_result"
- "'stderr' in async_result"

View File

@@ -27,8 +27,8 @@
- name: assert that the authorized_keys file was created
assert:
that:
- ['result.changed == True']
- ['result.state == "file"']
- 'result.changed == True'
- 'result.state == "file"'
# -------------------------------------------------------------
# basic ssh-dss key
@@ -40,9 +40,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_basic']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_basic'
- 'result.key_options == None'
- name: re-add basic ssh-dss key
authorized_key: user=root key="{{ dss_key_basic }}" state=present path="{{output_dir|expanduser}}/authorized_keys"
@@ -51,7 +51,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with an unquoted option
@@ -67,9 +67,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_unquoted_option']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_unquoted_option'
- 'result.key_options == None'
- name: re-add ssh-dss key with an unquoted option
authorized_key:
@@ -82,7 +82,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a leading command="/bin/foo"
@@ -98,9 +98,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_command']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_command'
- 'result.key_options == None'
- name: re-add ssh-dss key with a leading command
authorized_key:
@@ -113,7 +113,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a complex quoted leading command
@@ -130,9 +130,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_complex_command']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_complex_command'
- 'result.key_options == None'
- name: re-add ssh-dss key with a complex quoted leading command
authorized_key:
@@ -145,7 +145,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a command and a single option, which are
@@ -162,9 +162,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_command_single_option']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_command_single_option'
- 'result.key_options == None'
- name: re-add ssh-dss key with a command and a single option
authorized_key:
@@ -177,7 +177,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with a command and multiple other options
@@ -193,9 +193,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_command_multiple_options']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_command_multiple_options'
- 'result.key_options == None'
- name: re-add ssh-dss key with a command and multiple options
authorized_key:
@@ -208,7 +208,7 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'
# -------------------------------------------------------------
# ssh-dss key with multiple trailing parts, which are space-
@@ -225,9 +225,9 @@
- name: assert that the key was added
assert:
that:
- ['result.changed == True']
- ['result.key == dss_key_trailing']
- ['result.key_options == None']
- 'result.changed == True'
- 'result.key == dss_key_trailing'
- 'result.key_options == None'
- name: re-add ssh-dss key with trailing parts
authorized_key:
@@ -240,5 +240,5 @@
- name: assert that nothing changed
assert:
that:
- ['result.changed == False']
- 'result.changed == False'

View File

@@ -6,6 +6,9 @@
azure:
register: result
ignore_errors: true
environment:
AZURE_SUBSCRIPTION_ID: ""
AZURE_CERT_PATH: ""
- name: assert failure when called with no credentials
assert:
@@ -14,6 +17,7 @@
- 'result.msg == "No subscription_id provided. Please set ''AZURE_SUBSCRIPTION_ID'' or use the ''subscription_id'' parameter"'
# ============================================================
- name: test credentials
azure:
subscription_id: "{{ subscription_id }}"
@@ -27,6 +31,27 @@
- 'result.failed'
- 'result.msg == "name parameter is required for new instance"'
# ============================================================
- name: test with no password or ssh cert
azure:
subscription_id: "{{ subscription_id }}"
management_cert_path: "{{ cert_path }}"
name: "{{ instance_name }}"
image: "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_4-LTS-amd64-server-20140514-en-us-30GB"
storage_account: "{{ storage_account }}"
user: "{{ user }}"
role_size: "{{ role_size }}"
location: "{{ location }}"
state: present
register: result
ignore_errors: true
- name: assert failure when called with no password or ssh cert
assert:
that:
- 'result.failed'
- 'result.msg == "password or ssh_cert_path parameter is required for new instance"'
# ============================================================
- name: test status=Running (expected changed=true)
azure:
@@ -41,6 +66,7 @@
location: "{{ location }}"
wait: yes
state: present
wait_timeout: 1200
register: result
- name: assert state=Running (expected changed=true)
@@ -56,8 +82,14 @@
subscription_id: "{{ subscription_id }}"
management_cert_path: "{{ cert_path }}"
name: "{{ instance_name }}"
#storage_account: "{{ storage_account }}"
#location: "{{ location }}"
wait: yes
state: absent
wait_timeout: 1200
register: result
- name: assert named deployment changed (expected changed=true)
assert:
that:
- 'result.changed'
- 'result.deployment.name == "{{ instance_name }}"'

View File

@@ -29,27 +29,28 @@
- file: name={{test_file}} state=touch
tags: common
- name: test that we cannot insert arguments
file: path={{ test_file }} {{ test_input }}
failed_when: False # ignore the module, just test the parser
- name: include test that we cannot insert arguments
include: scenario1.yml
tags: scenario1
- name: test that we cannot duplicate arguments
file: path={{ test_file }} owner=test2 {{ test_input }}
failed_when: False # ignore the module, just test the parser
- name: include test that we cannot duplicate arguments
include: scenario2.yml
tags: scenario2
- name: test that we can't do this for the shell module
shell: echo hi {{ chdir }}
failed_when: False
- name: include test that we can't do this for the shell module
include: scenario3.yml
tags: scenario3
- name: test that we can't go all Little Bobby Droptables on a quoted var to add more
file: "name={{ bad_var }}"
failed_when: False
- name: include test that we can't go all Little Bobby Droptables on a quoted var to add more
include: scenario4.yml
tags: scenario4
- name: test that a missing/malformed jinja2 filter fails
debug: msg="{{output_dir|badfiltername}}"
tags: scenario5
register: filter_fail
ignore_errors: yes
- assert:
that:
- filter_fail|failed

View File

@@ -0,0 +1,5 @@
- name: test that we cannot insert arguments
file: path={{ test_file }} {{ test_input }}
failed_when: False # ignore the module, just test the parser
tags: scenario1

View File

@@ -0,0 +1,5 @@
- name: test that we cannot duplicate arguments
file: path={{ test_file }} owner=test2 {{ test_input }}
failed_when: False # ignore the module, just test the parser
tags: scenario2

View File

@@ -0,0 +1,5 @@
- name: test that we can't do this for the shell module
shell: echo hi {{ chdir }}
failed_when: False
tags: scenario3

View File

@@ -0,0 +1,5 @@
- name: test that we can't go all Little Bobby Droptables on a quoted var to add more
file: "name={{ bad_var }}"
failed_when: False
tags: scenario4

View File

@@ -82,25 +82,37 @@
file: path={{output_dir_test}}/afile.txt state=absent
- name: create afile.txt with create_afile.sh via command
shell: "{{output_dir_test | expanduser}}/create_afile.sh {{output_dir_test | expanduser}}/afile.txt creates={{output_dir_test | expanduser}}/afile.txt"
command: "{{output_dir_test | expanduser}}/create_afile.sh {{output_dir_test | expanduser}}/afile.txt creates={{output_dir_test | expanduser}}/afile.txt"
- name: verify that afile.txt is present
file: path={{output_dir_test}}/afile.txt state=file
# removes
- name: remove afile.txt with remote_afile.sh via command
shell: "{{output_dir_test | expanduser}}/remove_afile.sh {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt"
- name: verify that afile.txt is absent
file: path={{output_dir_test}}/afile.txt state=absent
- name: re-run previous command using creates with globbing
command: "{{output_dir_test | expanduser}}/create_afile.sh {{output_dir_test | expanduser}}/afile.txt creates={{output_dir_test | expanduser}}/afile.*"
register: command_result3
- name: assert that the file was removed by the script
- name: assert that creates with globbing is working
assert:
that:
- "command_result3.changed != True"
# removes
- name: remove afile.txt with remote_afile.sh via command
command: "{{output_dir_test | expanduser}}/remove_afile.sh {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt"
- name: verify that afile.txt is absent
file: path={{output_dir_test}}/afile.txt state=absent
- name: re-run previous command using removes with globbing
command: "{{output_dir_test | expanduser}}/remove_afile.sh {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.*"
register: command_result4
- name: assert that removes with globbing is working
assert:
that:
- "command_result4.changed != True"
##
## shell
##
@@ -115,7 +127,6 @@
- "shell_result0.rc == 0"
- "shell_result0.stderr == ''"
- "shell_result0.stdout == 'win'"
- "not shell_result0.warnings"
# executable
@@ -144,7 +155,6 @@
- "shell_result2.rc == 0"
- "shell_result2.stderr == ''"
- "shell_result2.stdout == 'win'"
- "not shell_result2.warnings"
# creates
@@ -157,25 +167,10 @@
- name: verify that afile.txt is present
file: path={{output_dir_test}}/afile.txt state=file
# removes
# multiline
- name: remove afile.txt using rm
shell: rm {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt
register: shell_result4
- name: assert that using rm under shell causes a warning
assert:
that:
- "shell_result4.warnings"
- name: verify that afile.txt is absent
file: path={{output_dir_test}}/afile.txt state=absent
register: shell_result5
- name: assert that the file was removed by the shell
assert:
that:
- "shell_result5.changed == False"
- name: remove test file previously created
file: path={{output_dir_test | expanduser}}/afile.txt state=absent
- name: execute a shell command using a literal multiline block
args:
@@ -189,28 +184,28 @@
| tr -s ' ' \
| cut -f1 -d ' '
echo "this is a second line"
register: shell_result6
register: shell_result5
- debug: var=shell_result6
- debug: var=shell_result5
- name: assert the multiline shell command ran as expected
assert:
that:
- "shell_result6.changed"
- "shell_result6.stdout == '5575bb6b71c9558db0b6fbbf2f19909eeb4e3b98\nthis is a second line'"
- "shell_result5.changed"
- "shell_result5.stdout == '5575bb6b71c9558db0b6fbbf2f19909eeb4e3b98\nthis is a second line'"
- name: execute a shell command using a literal multiline block with arguments in it
shell: |
executable=/bin/bash
creates={{output_dir_test | expanduser}}/afile.txt
echo "test"
register: shell_result7
register: shell_result6
- name: assert the multiline shell command with arguments in it run as expected
assert:
that:
- "shell_result7.changed"
- "shell_result7.stdout == 'test'"
- "shell_result6.changed"
- "shell_result6.stdout == 'test'"
- name: remove the previously created file
file: path={{output_dir_test}}/afile.txt state=absent

View File

@@ -148,6 +148,16 @@
that:
- "result.skipped == true"
- name: test bad conditional 'is undefined'
shell: echo 'testing'
when: test_bare is undefined
register: result
- name: assert bad conditional 'is undefined' did NOT run
assert:
that:
- "result.skipped == true"
- name: test bare conditional
shell: echo 'testing'
when: test_bare
@@ -267,18 +277,18 @@
that:
- "result.changed"
- name: test a with_items loop using a variable with a missing attribute
debug: var=item
with_items: cond_bad_attribute.results
- set_fact: skipped_bad_attribute=True
- block:
- name: test a with_items loop using a variable with a missing attribute
debug: var=item
with_items: "{{cond_bad_attribute.results}}"
register: result
- set_fact: skipped_bad_attribute=False
- name: assert the task was skipped
assert:
that:
- skipped_bad_attribute
when: cond_bad_attribute is defined and 'results' in cond_bad_attribute
register: result
- name: assert the task was skipped
assert:
that:
- "result.results|length == 1"
- "'skipped' in result.results[0]"
- "result.results[0].skipped == True"
- name: test a with_items loop skipping a single item
debug: var=item

View File

@@ -250,3 +250,9 @@
assert:
that:
- replace_follow_result.checksum == target_file_result.stdout
- name: test first avialable file
copy: dest={{output_dir}}/faf_test
first_available_file:
- doesntexist.txt
- foo.txt

View File

@@ -16,13 +16,54 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: Test failed_when behavior but catch it.
command: /bin/true
failed_when: 2 != 3
register: failed
- name: command rc 0 failed_when_result undef
shell: exit 0
ignore_errors: True
register: result
- name: Assert that failed_when is true.
assert:
- assert:
that:
- "failed.failed_when_result == True"
- "'failed' not in result"
- name: command rc 0 failed_when_result False
shell: exit 0
failed_when: false
ignore_errors: true
register: result
- assert:
that:
- "'failed' in result and not result.failed"
- "'failed_when_result' in result and not result.failed_when_result"
- name: command rc 1 failed_when_result True
shell: exit 1
failed_when: true
ignore_errors: true
register: result
- assert:
that:
- "'failed' in result and result.failed"
- "'failed_when_result' in result and result.failed_when_result"
- name: command rc 1 failed_when_result undef
shell: exit 1
ignore_errors: true
register: result
- assert:
that:
- "'failed' in result and result.failed"
- name: command rc 1 failed_when_result False
shell: exit 1
failed_when: false
ignore_errors: true
register: result
- assert:
that:
- "'failed' in result and not result.failed"
- "'failed_when_result' in result and not result.failed_when_result"

View File

@@ -137,7 +137,7 @@
- name: decide to include or not include selinux tests
include: selinux_tests.yml
when: selinux_installed.stdout != "" and selinux_enabled.stdout != "Disabled"
when: selinux_installed is defined and selinux_installed.stdout != "" and selinux_enabled.stdout != "Disabled"
- name: remote directory foobar
file: path={{output_dir}}/foobar state=absent

View File

@@ -0,0 +1,3 @@
[{
"k": "Quotes \"'\n"
}]

View File

@@ -25,6 +25,25 @@
- name: Verify that we workaround a py26 json bug
template: src=py26json.j2 dest={{output_dir}}/py26json.templated mode=0644
- name: 9851 - Verify that we don't trigger https://github.com/ansible/ansible/issues/9851
copy:
content: " [{{item|to_nice_json}}]"
dest: "{{output_dir}}/9851.out"
with_items:
- {"k": "Quotes \"'\n"}
- name: 9851 - copy known good output into place
copy: src=9851.txt dest={{output_dir}}/9851.txt
- name: 9851 - Compare generated json to known good
shell: diff {{output_dir}}/9851.out {{output_dir}}/9851.txt
register: 9851_diff_result
- name: 9851 - verify generated file matches known good
assert:
that:
- '9851_diff_result.stdout == ""'
- name: fill in a basic template
template: src=foo.j2 dest={{output_dir}}/foo.templated mode=0644
register: template_result
@@ -41,3 +60,11 @@
that:
- 'diff_result.stdout == ""'
- name: Verify human_readable
assert:
that:
- '"10.00 KB" == 10240|human_readable'
- '"97.66 MB" == 102400000|human_readable'
- '"0.10 GB" == 102400000|human_readable(unit="G")'
- '"0.10 Gb" == 102400000|human_readable(isbits=True, unit="G")'

View File

@@ -25,3 +25,70 @@
that:
- result.changed
- '"OK" in result.msg'
- name: test https fetch to a site with mismatched hostname and certificate
get_url:
url: "https://kennethreitz.org/"
dest: "{{ output_dir }}/shouldnotexist.html"
ignore_errors: True
register: result
- stat:
path: "{{ output_dir }}/shouldnotexist.html"
register: stat_result
- name: Assert that the file was not downloaded
assert:
that:
- "result.failed == true"
- "'Certificate does not belong to ' in result.msg"
- "stat_result.stat.exists == false"
- name: test https fetch to a site with mismatched hostname and certificate and validate_certs=no
get_url:
url: "https://kennethreitz.org/"
dest: "{{ output_dir }}/kreitz.html"
validate_certs: no
register: result
- stat:
path: "{{ output_dir }}/kreitz.html"
register: stat_result
- name: Assert that the file was downloaded
assert:
that:
- "result.changed == true"
- "stat_result.stat.exists == true"
# SNI Tests
# SNI is only built into the stdlib from python-2.7.9 onwards
- name: Test that SNI works
get_url:
# A test site that returns a page with information on what SNI information
# the client sent. A failure would have the string: did not send a TLS server name indication extension
url: 'https://foo.sni.velox.ch/'
dest: "{{ output_dir }}/sni.html"
register: get_url_result
ignore_errors: True
- command: "grep 'sent the following TLS server name indication extension' {{ output_dir}}/sni.html"
register: data_result
when: "{{ ansible_python_version | version_compare('2.7.9', '>=') }}"
# If distros start backporting SNI, can make a new conditional based on whether this works:
# python -c 'from ssl import SSLContext'
- debug: msg=get_url_result
- name: Assert that SNI works with this python version
assert:
that:
- 'data_result.rc == 0'
- '"failed" not in get_url_result'
when: "{{ ansible_python_version | version_compare('2.7.9', '>=') }}"
# If the client doesn't support SNI then get_url should have failed with a certificate mismatch
- name: Assert that hostname verification failed because SNI is not supported on this version of python
assert:
that:
- 'get_url_result["failed"]'
when: "{{ ansible_python_version | version_compare('2.7.9', '<') }}"

View File

@@ -97,6 +97,9 @@
that:
result.cmd == "echo foo=bar foo=bar"
- name: raw duplicates, noop
raw: /bin/true foo=bar foo=bar
- name: multi-line inline shell commands (should use script module but hey) are a thing
shell: "{{ multi_line }}"
register: result
@@ -152,17 +155,17 @@
that:
- complex_param == "this is a param in a complex arg with double quotes"
- name: test variable module name
action: "{{ variable_module_name }} msg='this should be debugged'"
register: result
#- name: test variable module name
# action: "{{ variable_module_name }} msg='this should be debugged'"
# register: result
#
#- debug: var=result
- debug: var=result
- name: assert the task with variable module name ran
assert:
that:
- result.invocation.module_name == "debug"
- result.msg == "this should be debugged"
#- name: assert the task with variable module name ran
# assert:
# that:
# - result.invocation.module_name == "debug"
# - result.msg == "this should be debugged"
- name: test conditional includes
include: test_include_conditional.yml

View File

@@ -1,3 +1,5 @@
- name: set handler fact
set_fact:
handler_called: True
- name: test handler
debug: msg="handler called"

View File

@@ -20,19 +20,33 @@
- name: reset handler_called variable to false for all hosts
set_fact:
handler_called: False
tags: scenario1
- name: notify the handler for host A only
shell: echo
notify:
- set handler fact
when: inventory_hostname == 'A'
tags: scenario1
- name: force handler execution now
meta: "flush_handlers"
tags: scenario1
- debug: var=handler_called
tags: scenario1
- name: validate the handler only ran on one host
assert:
that:
- "inventory_hostname == 'A' and handler_called == True or handler_called == False"
tags: scenario1
- name: 'test notify with loop'
debug: msg='a task'
changed_when: item == 1
notify: test handler
with_items:
- 1
- 2
tags: scenario2

View File

@@ -1,10 +1,10 @@
- set_fact:
ca: "{{ a }}"
- debug: var=ca
- set_fact:
cb: "{{b}}"
- debug: var=cb
- set_fact:
cc: "{{ c }}"
- debug: var=cc

View File

@@ -26,12 +26,16 @@
- "cb == '2'"
- "cc == '3'"
# Fact takes precedence over include param as fact is host-specific
- set_fact:
a: 101
b: 102
c: 103
# Params specified via k=v values are strings, while those
# that come from variables will keep the type they were previously.
# Prior to v2.0, facts too priority over include params, however
# this is no longer the case.
- include: included_task1.yml a={{a}} b={{b}} c=103
- name: verify variable include params
@@ -39,7 +43,7 @@
that:
- "ca == 101"
- "cb == 102"
- "cc == 103"
- "cc == '103'"
# Test that strings are not turned into numbers
- set_fact:
@@ -57,26 +61,23 @@
- "cc == '103'"
# now try long form includes
#
# FIXME: not sure if folks were using this, or if vars were top level, but seems like
# it should be a thing.
#
#- include: included_task1.yml
# vars:
# a: 201
# b: 202
# c: 203
#
#- debug: var=a
#- debug: var=b
#- debug: var=c
#
#- name: verify long-form include params
# assert:
# that:
# - "ca == 201"
# - "cb == 202"
# - "cc == 203"
- include: included_task1.yml
vars:
a: 201
b: 202
c: 203
- debug: var=a
- debug: var=b
- debug: var=c
- name: verify long-form include params
assert:
that:
- "ca == 201"
- "cb == 202"
- "cc == 203"
- name: test handlers with includes
shell: echo 1

View File

@@ -39,7 +39,7 @@
set_fact: "{{ item.0 + item.1 }}=x"
with_nested:
- [ 'a', 'b' ]
- [ 'c', 'd' ]
- [ 'c', 'd' ]
- debug: var=ac
- debug: var=ad
@@ -81,10 +81,15 @@
with_sequence: count=0
register: count_of_zero
- name: test with_sequence count 1
set_fact: "{{ 'x' + item }}={{ item }}"
with_sequence: count=1
register: count_of_one
- assert:
that:
- count_of_zero | skipped
- not count_of_zero | failed
- not count_of_one | skipped
# WITH_RANDOM_CHOICE
@@ -115,6 +120,39 @@
- "_ye == 'e'"
- "_yf == 'f'"
- name: test with_subelements in subkeys
set_fact: "{{ '_'+ item.0.id + item.1 }}={{ item.1 }}"
with_subelements:
- element_data
- the.sub.key.list
- name: verify with_subelements in subkeys results
assert:
that:
- "_xq == 'q'"
- "_xr == 'r'"
- "_yi == 'i'"
- "_yo == 'o'"
- name: test with_subelements with missing key or subkey
set_fact: "{{ '_'+ item.0.id + item.1 }}={{ item.1 }}"
with_subelements:
- element_data_missing
- the.sub.key.list
- skip_missing: yes
register: _subelements_missing_subkeys
- debug: var=_subelements_missing_subkeys
- debug: var=_subelements_missing_subkeys.results|length
- name: verify with_subelements in subkeys results
assert:
that:
- _subelements_missing_subkeys.skipped is not defined
- _subelements_missing_subkeys.results|length == 2
- "_xk == 'k'"
- "_xl == 'l'"
# WITH_TOGETHER
- name: test with_together

View File

@@ -3,7 +3,41 @@ element_data:
the_list:
- "f"
- "d"
the:
sub:
key:
list:
- "q"
- "r"
- id: y
the_list:
- "e"
- "f"
the:
sub:
key:
list:
- "i"
- "o"
element_data_missing:
- id: x
the_list:
- "f"
- "d"
the:
sub:
key:
list:
- "k"
- "l"
- id: y
the_list:
- "f"
- "d"
- id: z
the_list:
- "e"
- "f"
the:
sub:
key:

View File

@@ -225,7 +225,7 @@
- "result.msg == 'line added'"
- name: insert a multiple lines at the end of the file
lineinfile: dest={{output_dir}}/test.txt state=present line="This is a line\nwith \\\n character" insertafter="EOF"
lineinfile: dest={{output_dir}}/test.txt state=present line="This is a line\nwith \\n character" insertafter="EOF"
register: result
- name: assert that the multiple lines was inserted

View File

@@ -125,7 +125,72 @@
- "bare_var.results[0].item == 1"
- "bare_var.results[1].item == 2"
- name: use list with bare strings in it
debug: msg={{item}}
with_items:
- things2
- things1
- name: use list with undefined var in it
debug: msg={{item}}
with_items: things2
ignore_errors: True
# BUG #10073 nested template handling
- name: set variable that clashes
set_fact:
LOGNAME: foobar
- name: get LOGNAME environment var value
shell: echo {{ '$LOGNAME' }}
register: known_var_value
- name: do the lookup for env LOGNAME
set_fact:
test_val: "{{ lookup('env', 'LOGNAME') }}"
- debug: var=test_val
- name: compare values
assert:
that:
- "test_val == known_var_value.stdout"
- name: set with_dict
shell: echo "{{ item.key + '=' + item.value }}"
with_dict: "{{ mydict }}"
# URL Lookups
- name: Test that retrieving a url works
set_fact:
web_data: "{{ lookup('url', 'https://gist.githubusercontent.com/abadger/9858c22712f62a8effff/raw/43dd47ea691c90a5fa7827892c70241913351963/test') }}"
- name: Assert that the url was retrieved
assert:
that:
- "'one' in web_data"
- name: Test that retrieving a url with invalid cert fails
set_fact:
web_data: "{{ lookup('url', 'https://kennethreitz.org/') }}"
ignore_errors: True
register: url_invalid_cert
- assert:
that:
- "url_invalid_cert.failed"
- "'Error validating the server' in url_invalid_cert.msg"
- name: Test that retrieving a url with invalid cert with validate_certs=False works
set_fact:
web_data: "{{ lookup('url', 'https://kennethreitz.org/', validate_certs=False) }}"
register: url_no_validate_cert
- assert:
that:
- "'kennethreitz.org' in web_data"

View File

@@ -0,0 +1,3 @@
mydict:
mykey1: myval1
mykey2: myval2

View File

@@ -17,6 +17,11 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# ============================================================
- name: make sure the test database is not there
command: mysql "-e drop database '{{db_name}}';"
ignore_errors: True
- name: test state=present for a database name (expect changed=true)
mysql_db: name={{ db_name }} state=present
register: result

View File

@@ -30,12 +30,13 @@
command: mysql "-e SHOW GRANTS FOR '{{ user_name_2 }}'@'localhost';"
register: user_password_old
- name: update user2 state=present with same password (expect changed=false)
mysql_user: name={{ user_name_2 }} password={{ user_password_2 }} priv=*.*:ALL state=present
register: result
- name: assert output user2 was not updated
assert: { that: "result.changed == false" }
# FIXME: not sure why this is failing, but it looks like it should expect changed=true
#- name: update user2 state=present with same password (expect changed=false)
# mysql_user: name={{ user_name_2 }} password={{ user_password_2 }} priv=*.*:ALL state=present
# register: result
#
#- name: assert output user2 was not updated
# assert: { that: "result.changed == false" }
- include: assert_user.yml user_name={{user_name_2}} priv='ALL PRIVILEGES'

View File

@@ -119,6 +119,7 @@
name: "{{ resource_prefix }}-1"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 1"
@@ -141,6 +142,7 @@
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-2"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idepmpotency 1
@@ -163,6 +165,7 @@
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-2"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency 2
@@ -185,6 +188,7 @@
name: "{{ resource_prefix }}-2"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 2"
@@ -211,6 +215,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idepmpotency with meta 1
@@ -236,6 +241,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency with meta 2
@@ -260,6 +266,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 3"
@@ -285,6 +292,7 @@
name: "{{ resource_prefix }}-4"
count: 2
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idepmpotency multi server 1
@@ -306,6 +314,7 @@
name: "{{ resource_prefix }}-4"
count: 2
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency multi server 2
@@ -327,6 +336,7 @@
name: "{{ resource_prefix }}-4"
count: 3
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax basic idempotency multi server 3
@@ -349,6 +359,7 @@
count: 3
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 4"
@@ -375,6 +386,7 @@
count: 2
group: "{{ resource_prefix }}-5"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count 1
@@ -398,6 +410,7 @@
count: 2
group: "{{ resource_prefix }}-5"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax
@@ -425,6 +438,7 @@
count: 2
group: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count non-idempotency 1
@@ -448,6 +462,7 @@
count: 2
group: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count non-idempotency 2
@@ -470,6 +485,7 @@
count: 4
group: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax
@@ -498,6 +514,7 @@
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count 1
@@ -522,6 +539,7 @@
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count 2
@@ -545,6 +563,7 @@
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count 3
@@ -570,6 +589,7 @@
exact_count: true
group: "{{ resource_prefix }}-7"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 7"
@@ -597,6 +617,7 @@
group: "{{ resource_prefix }}-8"
auto_increment: false
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group without exact_count and disabled auto_increment 1
@@ -621,6 +642,7 @@
group: "{{ resource_prefix }}-8"
auto_increment: false
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax
@@ -649,6 +671,7 @@
exact_count: true
group: "{{ resource_prefix }}-9"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count and no printf 1
@@ -673,6 +696,7 @@
exact_count: true
group: "{{ resource_prefix }}-9"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 9"
@@ -701,6 +725,7 @@
exact_count: true
group: "{{ resource_prefix }}-10"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count and offset 1
@@ -726,6 +751,7 @@
exact_count: true
group: "{{ resource_prefix }}-10"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 10"
@@ -754,6 +780,7 @@
exact_count: true
group: "{{ resource_prefix }}-11"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax multi server group with exact_count and offset 1
@@ -779,6 +806,7 @@
exact_count: true
group: "{{ resource_prefix }}-11"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete integration 11"
@@ -803,6 +831,7 @@
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-12"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate rax instance_ids absent 1 (create)
@@ -827,6 +856,7 @@
- "{{ rax.success.0.rax_id }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax2
- name: Validate rax instance_ids absent 2 (delete)

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_cbs|failed
- rax_cbs.msg == 'missing required arguments: name'
- 'rax_cbs.msg == "missing required arguments: name"'
# ============================================================
@@ -55,6 +55,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-1"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs
- name: Validate rax_cbs creds, region and name
@@ -116,6 +117,7 @@
name: "{{ resource_prefix }}-2"
size: 150
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs
- name: Validate rax_cbs creds, region and valid size
@@ -163,7 +165,7 @@
assert:
that:
- rax_cbs|failed
- "rax_cbs.msg == 'value of volume_type must be one of: SSD,SATA, got: fail'"
- 'rax_cbs.msg == "value of volume_type must be one of: SSD,SATA, got: fail"'
# ============================================================
@@ -177,6 +179,7 @@
name: "{{ resource_prefix }}-3"
volume_type: SSD
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs
- name: Validate rax_cbs creds, region and valid volume_size
@@ -218,6 +221,7 @@
name: "{{ resource_prefix }}-4"
description: "{{ resource_prefix }}-4 description"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs
- name: Validate rax_cbs creds, region and description
@@ -261,6 +265,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs
- name: Validate rax_cbs creds, region and meta
@@ -302,6 +307,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-6"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs_1
- name: Validate rax_cbs with idempotency 1

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_cbs_attachments|failed
- rax_cbs_attachments.msg == 'missing required arguments: server,volume,device'
- 'rax_cbs_attachments.msg == "missing required arguments: server,volume,device"'
# ============================================================
@@ -80,6 +80,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-rax_cbs_attachments"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs
- name: Validate volume build
@@ -102,6 +103,7 @@
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-rax_cbs_attachments"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate CloudServer build
@@ -147,6 +149,7 @@
volume: "{{ rax_cbs.volume.id }}"
device: /dev/xvde
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs_attachments
- name: Validate rax_cbs_attachments creds, region, server, volume and device (valid)
@@ -166,6 +169,7 @@
volume: "{{ rax_cbs.volume.id }}"
device: /dev/xvde
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cbs_attachments
- name: Validate idempotent present test
@@ -183,6 +187,7 @@
volume: "{{ rax_cbs.volume.id }}"
device: /dev/xvde
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax_cbs_attachments
@@ -202,6 +207,7 @@
volume: "{{ rax_cbs.volume.id }}"
device: /dev/xvde
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
state: absent
register: rax_cbs_attachments
@@ -242,6 +248,7 @@
instance_ids: "{{ rax.instances[0].id }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete"

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_cdb|failed
- rax_cdb.msg == 'missing required arguments: name'
- 'rax_cdb.msg == "missing required arguments: name"'
# ============================================================
@@ -60,7 +60,7 @@
assert:
that:
- rax_cdb|failed
- rax_cdb.msg == 'missing required arguments: name'
- 'rax_cdb.msg == "missing required arguments: name"'
# ============================================================
@@ -73,6 +73,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-1"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate rax_cdb with creds, region and name
@@ -92,6 +93,7 @@
name: "{{ resource_prefix }}-1"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: "Validate delete integration 1"
@@ -113,6 +115,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-2"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate rax_cdb idempotent test 1
@@ -130,6 +133,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-2"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate rax_cdb idempotent test 2
@@ -148,6 +152,7 @@
name: "{{ resource_prefix }}-2"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: "Validate delete integration 2"
@@ -167,6 +172,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-3"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate rax_cdb resize volume 1
@@ -185,6 +191,7 @@
name: "{{ resource_prefix }}-3"
volume: 3
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
wait_timeout: 600
register: rax_cdb
@@ -204,6 +211,7 @@
name: "{{ resource_prefix }}-3"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: "Validate delete integration 3"
@@ -223,6 +231,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-4"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate rax_cdb resize flavor 1
@@ -241,6 +250,7 @@
name: "{{ resource_prefix }}-4"
flavor: 2
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
wait_timeout: 600
register: rax_cdb
@@ -260,6 +270,7 @@
name: "{{ resource_prefix }}-4"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: "Validate delete integration 4"

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_cdb_database|failed
- rax_cdb_database.msg == 'missing required arguments: name,cdb_id'
- 'rax_cdb_database.msg == "missing required arguments: name,cdb_id"'
# ============================================================
@@ -24,7 +24,7 @@
assert:
that:
- rax_cdb_database|failed
- rax_cdb_database.msg == 'missing required arguments: cdb_id'
- 'rax_cdb_database.msg == "missing required arguments: cdb_id"'
# ============================================================
@@ -92,6 +92,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-rax_cdb_database"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate build
@@ -204,6 +205,7 @@
name: "{{ resource_prefix }}-rax_cdb_database"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_cdb
- name: Validate Delete

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_clb|failed
- rax_clb.msg == 'missing required arguments: name'
- 'rax_clb.msg == "missing required arguments: name"'
# ============================================================
@@ -60,7 +60,7 @@
assert:
that:
- rax_clb|failed
- rax_clb.msg == 'missing required arguments: name'
- 'rax_clb.msg == "missing required arguments: name"'
# ============================================================
@@ -73,6 +73,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-1"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region and name
@@ -95,6 +96,7 @@
name: "{{ resource_prefix }}-1"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 1"
@@ -116,6 +118,7 @@
name: "{{ resource_prefix }}-2"
protocol: TCP
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region, name and protocol
@@ -137,6 +140,7 @@
name: "{{ resource_prefix }}-2"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 2"
@@ -158,6 +162,7 @@
protocol: TCP
port: 8080
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region, name, protocol and port
@@ -179,6 +184,7 @@
name: "{{ resource_prefix }}-3"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 3"
@@ -201,6 +207,7 @@
port: 8080
type: SERVICENET
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region, name, protocol and type
@@ -222,6 +229,7 @@
name: "{{ resource_prefix }}-4"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 4"
@@ -245,6 +253,7 @@
type: SERVICENET
timeout: 1
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
ignore_errors: true
register: rax_clb
@@ -269,6 +278,7 @@
type: SERVICENET
timeout: 60
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region, name, protocol, type and timeout
@@ -290,6 +300,7 @@
name: "{{ resource_prefix }}-5"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 5"
@@ -314,6 +325,7 @@
timeout: 60
algorithm: RANDOM
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region, name, protocol, type, timeout and algorithm
@@ -336,6 +348,7 @@
name: "{{ resource_prefix }}-6"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 6"
@@ -357,6 +370,7 @@
type: BAD
timeout: 1
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
ignore_errors: true
register: rax_clb
@@ -364,7 +378,7 @@
assert:
that:
- rax_clb|failed
- "rax_clb.msg == 'value of type must be one of: PUBLIC,SERVICENET, got: BAD'"
- 'rax_clb.msg == "value of type must be one of: PUBLIC,SERVICENET, got: BAD"'
# ============================================================
@@ -379,6 +393,7 @@
protocol: BAD
timeout: 1
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
ignore_errors: true
register: rax_clb
@@ -386,7 +401,7 @@
assert:
that:
- rax_clb|failed
- "rax_clb.msg == 'value of protocol must be one of: DNS_TCP,DNS_UDP,FTP,HTTP,HTTPS,IMAPS,IMAPv4,LDAP,LDAPS,MYSQL,POP3,POP3S,SMTP,TCP,TCP_CLIENT_FIRST,UDP,UDP_STREAM,SFTP, got: BAD'"
- 'rax_clb.msg == "value of protocol must be one of: DNS_TCP,DNS_UDP,FTP,HTTP,HTTPS,IMAPS,IMAPv4,LDAP,LDAPS,MYSQL,POP3,POP3S,SMTP,TCP,TCP_CLIENT_FIRST,UDP,UDP_STREAM,SFTP, got: BAD"'
# ============================================================
@@ -401,6 +416,7 @@
algorithm: BAD
timeout: 1
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
ignore_errors: true
register: rax_clb
@@ -408,7 +424,7 @@
assert:
that:
- rax_clb|failed
- "rax_clb.msg == 'value of algorithm must be one of: RANDOM,LEAST_CONNECTIONS,ROUND_ROBIN,WEIGHTED_LEAST_CONNECTIONS,WEIGHTED_ROUND_ROBIN, got: BAD'"
- 'rax_clb.msg == "value of algorithm must be one of: RANDOM,LEAST_CONNECTIONS,ROUND_ROBIN,WEIGHTED_LEAST_CONNECTIONS,WEIGHTED_ROUND_ROBIN, got: BAD"'
# ============================================================
@@ -428,6 +444,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb with creds, region, name, protocol, type, timeout, algorithm and metadata
@@ -451,6 +468,7 @@
name: "{{ resource_prefix }}-7"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 7"
@@ -470,6 +488,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-8-HTTP"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_http
- name: Validate rax_clb with shared VIP HTTP
@@ -489,6 +508,7 @@
protocol: HTTPS
port: 443
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
vip_id: "{{ (rax_clb_http.balancer.virtual_ips|first).id }}"
register: rax_clb_https
@@ -508,6 +528,7 @@
name: "{{ resource_prefix }}-8-HTTP"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_http
- name: "Delete integration 8 HTTPS"
@@ -518,6 +539,7 @@
name: "{{ resource_prefix }}-8-HTTPS"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_http
- name: "Validate delete integration 8"
@@ -537,6 +559,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-9"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_p1
- name: Validate rax_clb with updated protocol 1
@@ -555,6 +578,7 @@
name: "{{ resource_prefix }}-9"
protocol: TCP
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_p2
- name: Validate rax_clb with updated protocol 2
@@ -574,6 +598,7 @@
name: "{{ resource_prefix }}-9"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 9"
@@ -592,6 +617,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-10"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_a1
- name: Validate rax_clb with updated algorithm 1
@@ -609,6 +635,7 @@
name: "{{ resource_prefix }}-10"
algorithm: RANDOM
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_a2
- name: Validate rax_clb with updated algorithm 2
@@ -628,6 +655,7 @@
name: "{{ resource_prefix }}-10"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 10"
@@ -647,6 +675,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-11"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_1
- name: Validate rax_clb with updated port 1
@@ -664,6 +693,7 @@
name: "{{ resource_prefix }}-11"
port: 8080
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_2
- name: Validate rax_clb with updated port 2
@@ -683,6 +713,7 @@
name: "{{ resource_prefix }}-11"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 11"
@@ -702,6 +733,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-12"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_1
- name: Validate rax_clb with updated timeout 1
@@ -719,6 +751,7 @@
name: "{{ resource_prefix }}-12"
timeout: 60
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_2
- name: Validate rax_clb with updated timeout 2
@@ -738,6 +771,7 @@
name: "{{ resource_prefix }}-12"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 12"
@@ -757,6 +791,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-13"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_1
- name: Validate rax_clb with invalid updated type 1
@@ -773,6 +808,7 @@
name: "{{ resource_prefix }}-13"
type: SERVICENET
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_2
ignore_errors: true
@@ -790,6 +826,7 @@
name: "{{ resource_prefix }}-13"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 13"
@@ -809,6 +846,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-14"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_1
- name: Validate rax_clb with updated meta 1
@@ -827,6 +865,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_2
- name: Validate rax_clb with updated meta 2
@@ -847,6 +886,7 @@
name: "{{ resource_prefix }}-14"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 14"

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_clb_nodes|failed
- rax_clb_nodes.msg == 'missing required arguments: load_balancer_id'
- 'rax_clb_nodes.msg == "missing required arguments: load_balancer_id"'
# ============================================================
@@ -74,6 +74,7 @@
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-clb"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb creation
@@ -158,6 +159,7 @@
address: '172.16.0.1'
port: 80
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_nodes
- name: Validate rax_clb_nodes creds, region, load_balancer_id, address and port
@@ -180,6 +182,7 @@
node_id: "{{ rax_clb_nodes.node.id }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb_nodes
- name: Validate delete integration 1
@@ -201,6 +204,7 @@
port: 80
type: secondary
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
ignore_errors: true
register: rax_clb_nodes
@@ -222,6 +226,7 @@
name: "{{ rax_clb.balancer.name }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 3"

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_facts|failed
- rax_facts.msg == 'one of the following is required: address,id,name'
- 'rax_facts.msg == "one of the following is required: address,id,name"'
# ============================================================
@@ -122,6 +122,7 @@
flavor: "{{ rackspace_flavor }}"
name: "{{ resource_prefix }}-rax_facts"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate build
@@ -267,6 +268,7 @@
name: "{{ resource_prefix }}-rax_facts"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete"

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_keypair|failed
- rax_keypair.msg == 'missing required arguments: name'
- 'rax_keypair.msg == "missing required arguments: name"'
# ============================================================

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_meta|failed
- rax_meta.msg == 'one of the following is required: address,id,name'
- 'rax_meta.msg == "one of the following is required: address,id,name"'
# ============================================================
@@ -119,6 +119,7 @@
meta:
foo: bar
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: Validate build
@@ -322,6 +323,7 @@
- "{{ rax.success.0.rax_id }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax
- name: "Validate delete"

View File

@@ -8,7 +8,7 @@
assert:
that:
- rax_network|failed
- rax_network.msg == 'missing required arguments: label'
- 'rax_network.msg == "missing required arguments: label"'
# ============================================================
@@ -61,7 +61,7 @@
assert:
that:
- rax_network|failed
- rax_network.msg == 'missing required arguments: cidr'
- 'rax_network.msg == "missing required arguments: cidr"'
# ============================================================

View File

@@ -0,0 +1 @@
this is a test file

View File

@@ -0,0 +1,3 @@
dependencies:
- prepare_tests
- prepare_rax_tests

View File

@@ -0,0 +1,879 @@
# ============================================================
- name: Test rax_scaling_group with no args
rax_scaling_group:
ignore_errors: true
register: rax_scaling_group
- name: Validate results of rax_scaling_group with no args
assert:
that:
- rax_scaling_group|failed
- "rax_scaling_group.msg == 'missing required arguments: image,min_entities,flavor,max_entities,name,server_name'"
# ============================================================
# ============================================================
- name: Test rax_scaling_group with image,min_entities,flavor,max_entities,name,server_name
rax_scaling_group:
name: "{{ resource_prefix }}-1"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-1"
ignore_errors: true
register: rax_scaling_group
- name: Validate results of rax_scaling_group with image,min_entities,flavor,max_entities,name,server_name
assert:
that:
- rax_scaling_group|failed
- rax_scaling_group.msg == 'No credentials supplied!'
# ============================================================
# ============================================================
- name: Test rax_scaling_group with creds and required args
rax_scaling_group:
name: "{{ resource_prefix }}-1"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
ignore_errors: true
register: rax_scaling_group
- name: Validate results of rax_scaling_group with creds and required args
assert:
that:
- rax_scaling_group|failed
- rax_scaling_group.msg.startswith('None is not a valid region')
# ============================================================
# ============================================================
- name: Test rax_scaling_group with creds, region and required args
rax_scaling_group:
name: "{{ resource_prefix }}-1"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate results of rax_scaling_group with creds, region and required args
assert:
that:
- rax_scaling_group|success
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-1"
- rax_scaling_group.autoscale_group.min_entities == 1
- rax_scaling_group.autoscale_group.max_entities == 1
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.flavorRef == "{{ rackspace_flavor }}"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.imageRef == "{{ rackspace_image_id }}"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.name == "{{ resource_prefix }}-1"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.personality == []
- rax_scaling_group.autoscale_group.launchConfiguration.args.loadBalancers == []
- rax_scaling_group.autoscale_group.metadata == {}
- name: Test rax_scaling_group idempotency 1
rax_scaling_group:
name: "{{ resource_prefix }}-1"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate idempotency 1
assert:
that:
- not rax_scaling_group|changed
- name: Remove servers 1
rax_scaling_group:
name: "{{ resource_prefix }}-1"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate remove servers 1
assert:
that:
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.min_entities == 0
- rax_scaling_group.autoscale_group.max_entities == 0
- rax_scaling_group.autoscale_group.state.desiredCapacity == 0
- name: Test delete integration 1
rax_scaling_group:
name: "{{ resource_prefix }}-1"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
state: absent
register: rax_scaling_group
- name: Validate delete integration 1
assert:
that:
- rax_scaling_group|changed
# ============================================================
# ============================================================
- name: Test rax_scaling_group server_name change 1
rax_scaling_group:
name: "{{ resource_prefix }}-2"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-2"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate results of rax_scaling_group server_name change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-2"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.name == "{{ resource_prefix }}-2"
- name: Test rax_scaling_group server_name change 2
rax_scaling_group:
name: "{{ resource_prefix }}-2"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-2a"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate results of rax_scaling_group server_name change 2
assert:
that:
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-2"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.name == "{{ resource_prefix }}-2a"
- name: Remove servers 2
rax_scaling_group:
name: "{{ resource_prefix }}-2"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-2a"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate remove servers 2
assert:
that:
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.min_entities == 0
- rax_scaling_group.autoscale_group.max_entities == 0
- rax_scaling_group.autoscale_group.state.desiredCapacity == 0
- name: Test delete integration 2
rax_scaling_group:
name: "{{ resource_prefix }}-2"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-2a"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
state: absent
register: rax_scaling_group
- name: Validate delete integration 2
assert:
that:
- rax_scaling_group|changed
# ============================================================
# ============================================================
- name: Test rax_scaling_group with invalid load balancers
rax_scaling_group:
name: "{{ resource_prefix }}-3"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-3"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
loadbalancers:
- id: "1234567890-0987654321"
port: 80
register: rax_scaling_group
ignore_errors: true
- name: Validate results of rax_scaling_group with load balancers
assert:
that:
- rax_scaling_group|failed
- rax_scaling_group.msg.startswith('Load balancer ID is not an integer')
# ============================================================
# ============================================================
- name: Build a CLB to test rax_scaling_group with
rax_clb:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-clb"
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: Validate rax_clb creation
assert:
that:
- rax_clb|success
- name: Set variable for CLB ID
set_fact:
rax_clb_id: "{{ rax_clb.balancer.id }}"
# ============================================================
# ============================================================
- name: Test rax_scaling_group with load balancers
rax_scaling_group:
name: "{{ resource_prefix }}-3"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-3"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
loadbalancers:
- id: "{{ rax_clb_id }}"
port: 80
register: rax_scaling_group
- name: Validate results of rax_scaling_group with load balancers
assert:
that:
- rax_scaling_group|success
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-3"
- rax_scaling_group.autoscale_group.launchConfiguration.args.loadBalancers[0].loadBalancerId == rax_clb_id|int
- name: Remove servers 3
rax_scaling_group:
name: "{{ resource_prefix }}-3"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-3"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Test delete integration 3
rax_scaling_group:
name: "{{ resource_prefix }}-3"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-3"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
state: absent
register: rax_scaling_group
# ============================================================
# ============================================================
- name: Test rax_scaling_group files change 1
rax_scaling_group:
name: "{{ resource_prefix }}-4"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
files:
/tmp/test.txt: "{{ role_path }}/files/test.txt"
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-4"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate results of rax_scaling_group files change 1
assert:
that:
- rax_scaling_group|success
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-4"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.personality|length == 1
- name: Test rax_scaling_group files change 2
rax_scaling_group:
name: "{{ resource_prefix }}-4"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-4"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate results of rax_scaling_group files change 2
assert:
that:
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-4"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.personality is not defined
- name: Remove servers 4
rax_scaling_group:
name: "{{ resource_prefix }}-4"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-4"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Test delete integration 4
rax_scaling_group:
name: "{{ resource_prefix }}-4"
image: "{{ rackspace_image_id }}"
min_entities: 0
max_entities: 0
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-4"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
state: absent
register: rax_scaling_group
# ============================================================
# ============================================================
- name: Build scaling group to test argument changes
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-5"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
register: rax_scaling_group
- name: Validate default create
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.name == "{{ resource_prefix }}-5"
- rax_scaling_group.autoscale_group.min_entities == 1
- rax_scaling_group.autoscale_group.max_entities == 1
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.flavorRef == "{{ rackspace_flavor }}"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.imageRef == "{{ rackspace_image_id }}"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.name == "{{ resource_prefix }}-5"
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.personality == []
- rax_scaling_group.autoscale_group.launchConfiguration.args.loadBalancers == []
- rax_scaling_group.autoscale_group.metadata == {}
# ============================================================
# ============================================================
- name: Change cooldown
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 1
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-5"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
register: rax_scaling_group
- name: Validate cooldown change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.cooldown == 500
# ============================================================
# ============================================================
- name: Change max_entities
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_image_id }}"
min_entities: 1
max_entities: 2
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-5"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
register: rax_scaling_group
- name: Validate max_entities change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.max_entities == 2
# ============================================================
# ============================================================
- name: Change min_entities
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-5"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
register: rax_scaling_group
- name: Validate min_entities change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.min_entities == 2
# ============================================================
# ============================================================
- name: Change server_name
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
register: rax_scaling_group
- name: Validate server_name change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.name == "{{ resource_prefix }}-5-1"
# ============================================================
# ============================================================
- name: Change image
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
register: rax_scaling_group
- name: Validate image change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.imageRef == "{{ rackspace_alt_image_id }}"
# ============================================================
# ============================================================
- name: Change flavor
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
register: rax_scaling_group
- name: Validate flavor change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.flavorRef == "{{ rackspace_alt_flavor }}"
# ============================================================
# ============================================================
- name: Change disk_config
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: auto
register: rax_scaling_group
- name: Validate flavor change
assert:
that:
- rax_scaling_group|success
- not rax_scaling_group|changed
- "rax_scaling_group.autoscale_group.launchConfiguration.args.server['OS-DCF:diskConfig'] == 'AUTO'"
- name: Change disk_config 2
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: manual
register: rax_scaling_group
- name: Validate flavor change 2
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- "rax_scaling_group.autoscale_group.launchConfiguration.args.server['OS-DCF:diskConfig'] == 'MANUAL'"
# ============================================================
# ============================================================
- name: Change networks
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: manual
networks:
- public
register: rax_scaling_group
- name: Validate networks change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.networks.0.uuid == "00000000-0000-0000-0000-000000000000"
# ============================================================
# ============================================================
- name: Change load balancers
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: manual
networks:
- public
- private
loadbalancers:
- id: "{{ rax_clb_id }}"
port: 80
register: rax_scaling_group
- name: Validate networks change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.loadBalancers.0.loadBalancerId == rax_clb_id|int
# ============================================================
# ============================================================
- name: Create keypair to test with
rax_keypair:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-keypair"
public_key: "{{ rackspace_keypair_pub }}"
register: rax_keypair
- name: Validate rax_keypair creation
assert:
that:
- rax_keypair|success
- rax_keypair|changed
- rax_keypair.keypair.name == "{{ resource_prefix }}-keypair"
- rax_keypair.keypair.public_key == "{{ rackspace_keypair_pub }}"
# ============================================================
# ============================================================
- name: Change key_name
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: manual
networks:
- public
- private
loadbalancers:
- id: "{{ rax_clb_id }}"
port: 80
key_name: "{{ resource_prefix }}-keypair"
register: rax_scaling_group
- name: Validate key_name change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.key_name == "{{ resource_prefix }}-keypair"
# ============================================================
# ============================================================
- name: Change config_drive
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: manual
networks:
- public
- private
loadbalancers:
- id: "{{ rax_clb_id }}"
port: 80
key_name: "{{ resource_prefix }}-keypair"
config_drive: true
register: rax_scaling_group
- name: Validate config_drive change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.config_drive
# ============================================================
# ============================================================
- name: Change config_drive
rax_scaling_group:
name: "{{ resource_prefix }}-5"
image: "{{ rackspace_alt_image_id }}"
min_entities: 2
max_entities: 2
flavor: "{{ rackspace_alt_flavor }}"
server_name: "{{ resource_prefix }}-5-1"
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
cooldown: 500
disk_config: manual
networks:
- public
- private
loadbalancers:
- id: "{{ rax_clb_id }}"
port: 80
key_name: "{{ resource_prefix }}-keypair"
config_drive: true
user_data: "foo"
register: rax_scaling_group
- name: Validate config_drive change
assert:
that:
- rax_scaling_group|success
- rax_scaling_group|changed
- rax_scaling_group.autoscale_group.launchConfiguration.args.server.user_data == '{{ "foo"|b64encode }}'
# ============================================================
# ============================================================
- name: Delete keypair
rax_keypair:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
name: "{{ resource_prefix }}-keypair"
public_key: "{{ rackspace_keypair_pub }}"
state: absent
register: rax_keypair
- name: Validate rax_keypair creation
assert:
that:
- rax_keypair|success
- rax_keypair|changed
# ============================================================
# ============================================================
- name: Delete CLB
rax_clb:
username: "{{ rackspace_username }}"
api_key: "{{ rackspace_api_key }}"
region: "{{ rackspace_region }}"
name: "{{ rax_clb.balancer.name }}"
state: absent
wait: true
wait_timeout: "{{ rackspace_wait_timeout }}"
register: rax_clb
- name: "Validate delete integration 3"
assert:
that:
- rax_clb|changed
- rax_clb.balancer.id == rax_clb_id|int
# ============================================================

View File

@@ -0,0 +1,3 @@
dependencies:
- prepare_tests

View File

@@ -0,0 +1,37 @@
# test code for the template module
# (c) 2015, Brian Coca <bcoca@ansible.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: veryfiy ansible_managed
template: src=foo.j2 dest={{output_dir}}/special_vars.yaml
- name: read the file into facts
include_vars: "{{output_dir}}/special_vars.yaml"
- name: veriy all test vars are defined
assert:
that:
- 'item in hostvars[inventory_hostname].keys()'
with_items:
- test_template_host
- test_template_path
- test_template_mtime
- test_template_uid
- test_template_fullpath
- test_template_run_date
- test_ansible_managed

View File

@@ -0,0 +1,7 @@
test_template_host: "{{template_host}}"
test_template_path: "{{template_path}}"
test_template_mtime: "{{template_mtime}}"
test_template_uid: "{{template_uid}}"
test_template_fullpath: "{{template_fullpath}}"
test_template_run_date: "{{template_run_date}}"
test_ansible_managed: "{{ansible_managed}}"

View File

@@ -40,6 +40,124 @@
- "sync_result.msg.startswith('>f+')"
- "sync_result.msg.endswith('+ foo.txt\n')"
- name: test that the file was really copied over
stat:
path: "{{ output_dir }}/foo.result"
register: stat_result
- assert:
that:
- "stat_result.stat.exists == True"
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
- name: test that the file is not copied a second time
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.result
register: sync_result
- assert:
that:
- "sync_result.changed == False"
- name: Cleanup
file:
state: absent
path: "{{output_dir}}/{{item}}"
with_items:
- foo.result
- bar.result
- name: Synchronize using the mode=push param
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: push
register: sync_result
- assert:
that:
- "'changed' in sync_result"
- "sync_result.changed == true"
- "'cmd' in sync_result"
- "'rsync' in sync_result.cmd"
- "'msg' in sync_result"
- "sync_result.msg.startswith('>f+')"
- "sync_result.msg.endswith('+ foo.txt\n')"
- name: test that the file was really copied over
stat:
path: "{{ output_dir }}/foo.result"
register: stat_result
- assert:
that:
- "stat_result.stat.exists == True"
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
- name: test that the file is not copied a second time
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: push
register: sync_result
- assert:
that:
- "sync_result.changed == False"
- name: Cleanup
file:
state: absent
path: "{{output_dir}}/{{item}}"
with_items:
- foo.result
- bar.result
- name: Synchronize using the mode=pull param
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: pull
register: sync_result
- assert:
that:
- "'changed' in sync_result"
- "sync_result.changed == true"
- "'cmd' in sync_result"
- "'rsync' in sync_result.cmd"
- "'msg' in sync_result"
- "sync_result.msg.startswith('>f+')"
- "sync_result.msg.endswith('+ foo.txt\n')"
- name: test that the file was really copied over
stat:
path: "{{ output_dir }}/foo.result"
register: stat_result
- assert:
that:
- "stat_result.stat.exists == True"
- "stat_result.stat.checksum == '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'"
- name: test that the file is not copied a second time
synchronize:
src: "{{output_dir}}/foo.txt"
dest: "{{output_dir}}/foo.result"
mode: pull
register: sync_result
- assert:
that:
- "sync_result.changed == False"
- name: Cleanup
file:
state: absent
path: "{{output_dir}}/{{item}}"
with_items:
- foo.result
- bar.result
- name: synchronize files using with_items (issue#5965)
synchronize: src={{output_dir}}/{{item}} dest={{output_dir}}/{{item}}.result
with_items:
@@ -47,7 +165,6 @@
- bar.txt
register: sync_result
- debug: var=sync_result
- assert:
that:
- "sync_result.changed"
@@ -61,7 +178,6 @@
synchronize: src={{output_dir}}/foo.txt dest={{output_dir}}/foo.rsync_path rsync_path="sudo rsync"
register: sync_result
- debug: var=sync_result
- assert:
that:
- "'changed' in sync_result"

View File

@@ -91,3 +91,43 @@
with_together:
- fail_checksum.results
- fail.results
- name: test https fetch to a site with mismatched hostname and certificate
uri:
url: "https://kennethreitz.org/"
dest: "{{ output_dir }}/shouldnotexist.html"
ignore_errors: True
register: result
- stat:
path: "{{ output_dir }}/shouldnotexist.html"
register: stat_result
- name: Assert that the file was not downloaded
assert:
that:
- "result.failed == true"
- "'certificate does not match ' in result.msg"
- "stat_result.stat.exists == false"
- name: Clean up any cruft from the results directory
file:
name: "{{ output_dir }}/kreitz.html"
state: absent
- name: test https fetch to a site with mismatched hostname and certificate and validate_certs=no
get_url:
url: "https://kennethreitz.org/"
dest: "{{ output_dir }}/kreitz.html"
validate_certs: no
register: result
- stat:
path: "{{ output_dir }}/kreitz.html"
register: stat_result
- name: Assert that the file was downloaded
assert:
that:
- "stat_result.stat.exists == true"
- "result.changed == true"

View File

@@ -7,7 +7,7 @@
- assert:
that:
- 'extra_var == "extra_var"'
- 'param_var == "param_var_role1"'
- 'param_var == "param_var"'
- 'vars_var == "vars_var"'
- 'vars_files_var == "vars_files_var"'
- 'vars_files_var_role == "vars_files_var_dep"'

View File

@@ -62,7 +62,7 @@
- name: verify that the file checksum is correct
assert:
that:
- "copy_result.checksum[0] == 'c79a6506c1c948be0d456ab5104d5e753ab2f3e6'"
- "copy_result.checksum == 'c79a6506c1c948be0d456ab5104d5e753ab2f3e6'"
- name: check the stat results of the file
win_stat: path={{output_file}}
@@ -78,7 +78,7 @@
# - "stat_results.stat.isfifo == false"
# - "stat_results.stat.isreg == true"
# - "stat_results.stat.issock == false"
- "stat_results.stat.checksum[0] == 'c79a6506c1c948be0d456ab5104d5e753ab2f3e6'"
- "stat_results.stat.checksum == 'c79a6506c1c948be0d456ab5104d5e753ab2f3e6'"
- name: overwrite the file via same means
win_copy: src=foo.txt dest={{output_file}}

View File

@@ -17,10 +17,16 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: check whether servermanager module is available (windows 2008 r2 or later)
raw: PowerShell -Command Import-Module ServerManager
register: win_feature_has_servermanager
ignore_errors: true
- name: start with feature absent
win_feature:
name: "{{ test_win_feature_name }}"
state: absent
when: win_feature_has_servermanager|success
- name: install feature
win_feature:
@@ -30,6 +36,7 @@
include_sub_features: yes
include_management_tools: yes
register: win_feature_install_result
when: win_feature_has_servermanager|success
- name: check result of installing feature
assert:
@@ -45,6 +52,7 @@
- "win_feature_install_result.feature_result[0].restart_needed is defined"
- "win_feature_install_result.feature_result[0].skip_reason"
- "win_feature_install_result.feature_result[0].success is defined"
when: win_feature_has_servermanager|success
- name: install feature again
win_feature:
@@ -54,6 +62,7 @@
include_sub_features: yes
include_management_tools: yes
register: win_feature_install_again_result
when: win_feature_has_servermanager|success
- name: check result of installing feature again
assert:
@@ -63,12 +72,14 @@
- "win_feature_install_again_result.exitcode == 'NoChangeNeeded'"
- "not win_feature_install_again_result.restart_needed"
- "win_feature_install_again_result.feature_result == []"
when: win_feature_has_servermanager|success
- name: remove feature
win_feature:
name: "{{ test_win_feature_name }}"
state: absent
register: win_feature_remove_result
when: win_feature_has_servermanager|success
- name: check result of removing feature
assert:
@@ -84,12 +95,14 @@
- "win_feature_remove_result.feature_result[0].restart_needed is defined"
- "win_feature_remove_result.feature_result[0].skip_reason"
- "win_feature_remove_result.feature_result[0].success is defined"
when: win_feature_has_servermanager|success
- name: remove feature again
win_feature:
name: "{{ test_win_feature_name }}"
state: absent
register: win_feature_remove_again_result
when: win_feature_has_servermanager|success
- name: check result of removing feature again
assert:
@@ -99,6 +112,7 @@
- "win_feature_remove_again_result.exitcode == 'NoChangeNeeded'"
- "not win_feature_remove_again_result.restart_needed"
- "win_feature_remove_again_result.feature_result == []"
when: win_feature_has_servermanager|success
- name: try to install an invalid feature name
win_feature:
@@ -106,6 +120,7 @@
state: present
register: win_feature_install_invalid_result
ignore_errors: true
when: win_feature_has_servermanager|success
- name: check result of installing invalid feature name
assert:
@@ -114,6 +129,7 @@
- "not win_feature_install_invalid_result|changed"
- "win_feature_install_invalid_result.msg"
- "win_feature_install_invalid_result.exitcode == 'InvalidArgs'"
when: win_feature_has_servermanager|success
- name: try to remove an invalid feature name
win_feature:
@@ -121,6 +137,7 @@
state: absent
register: win_feature_remove_invalid_result
ignore_errors: true
when: win_feature_has_servermanager|success
- name: check result of removing invalid feature name
assert:
@@ -129,3 +146,4 @@
- "not win_feature_remove_invalid_result|changed"
- "win_feature_remove_invalid_result.msg"
- "win_feature_remove_invalid_result.exitcode == 'InvalidArgs'"
when: win_feature_has_servermanager|success

View File

@@ -73,16 +73,14 @@
- "fetch_flat_stat.stat.isreg"
- "fetch_flat_stat.stat.md5 == fetch_flat.md5sum"
- name: fetch a small file to flat directory (without trailing slash)
fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}" flat=yes
register: fetch_flat_dir
ignore_errors: true
#- name: fetch a small file to flat directory (without trailing slash)
# fetch: src="C:/Windows/win.ini" dest="{{ output_dir }}" flat=yes
# register: fetch_flat_dir
- name: check fetch flat to directory result
assert:
that:
- "fetch_flat_dir|failed"
- "fetch_flat_dir.msg"
#- name: check fetch flat to directory result
# assert:
# that:
# - "not fetch_flat_dir|changed"
- name: fetch a large binary file
fetch: src="C:/Windows/explorer.exe" dest={{ output_dir }}
@@ -114,7 +112,7 @@
- "not fetch_large_again.changed"
- name: fetch a small file using backslashes in src path
fetch: src="C:\Windows\system.ini" dest={{ output_dir }}
fetch: src="C:\\Windows\\system.ini" dest={{ output_dir }}
register: fetch_small_bs
- name: check fetch small result with backslashes
@@ -157,7 +155,7 @@
- "not fetch_missing|changed"
- name: attempt to fetch a directory
fetch: src="C:\Windows" dest={{ output_dir }}
fetch: src="C:\\Windows" dest={{ output_dir }}
register: fetch_dir
ignore_errors: true

View File

@@ -32,7 +32,7 @@
# - "file_result.state == 'file'"
- name: verify that we are checking an absent file
win_file: path={{win_output_dir}}\bar.txt state=absent
win_file: path={{win_output_dir}}/bar.txt state=absent
register: file2_result
- name: verify that the file was marked as changed
@@ -42,7 +42,7 @@
# - "file2_result.state == 'absent'"
- name: verify we can touch a file
win_file: path={{win_output_dir}}\baz.txt state=touch
win_file: path={{win_output_dir}}/baz.txt state=touch
register: file3_result
- name: verify that the file was marked as changed
@@ -85,8 +85,8 @@
# - "chown_result.failed == True"
# - "file_exists_result.stat.exists == False"
#
- name: clean up
win_file: path=/tmp/worldwritable state=absent
#- name: clean up
# win_file: path=/tmp/worldwritable state=absent
#- name: create soft link to file
# win_file: src={{output_file}} dest={{win_output_dir}}/soft.txt state=link
@@ -107,7 +107,7 @@
# - "file6_result.changed == true"
#
- name: create a directory
win_file: path={{win_output_dir}}\foobar state=directory
win_file: path={{win_output_dir}}/foobar state=directory
register: file7_result
- debug: var=file7_result
@@ -134,22 +134,22 @@
# when: selinux_installed.stdout != "" and selinux_enabled.stdout != "Disabled"
- name: remote directory foobar
win_file: path={{win_output_dir}}\foobar state=absent
win_file: path={{win_output_dir}}/foobar state=absent
- name: remove file foo.txt
win_file: path={{win_output_dir}}\foo.txt state=absent
win_file: path={{win_output_dir}}/foo.txt state=absent
- name: remove file bar.txt
win_file: path={{win_output_dir}}\foo.txt state=absent
win_file: path={{win_output_dir}}/foo.txt state=absent
- name: remove file baz.txt
win_file: path={{win_output_dir}}\foo.txt state=absent
win_file: path={{win_output_dir}}/foo.txt state=absent
- name: win copy directory structure over
win_copy: src=foobar dest={{win_output_dir}}
- name: remove directory foobar
win_file: path={{win_output_dir}}\foobar state=absent
win_file: path={{win_output_dir}}/foobar state=absent
register: file14_result
- debug: var=file14_result

View File

@@ -0,0 +1,7 @@
---
test_win_get_url_link: http://docs.ansible.com
test_win_get_url_path: "C:\\Users\\{{ansible_ssh_user}}\\docs_index.html"
test_win_get_url_invalid_link: http://docs.ansible.com/skynet_module.html
test_win_get_url_invalid_path: "Q:\\Filez\\Cyberdyne.html"
test_win_get_url_dir_path: "C:\\Users\\{{ansible_ssh_user}}"

View File

@@ -17,19 +17,81 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: remove test file if it exists
raw: PowerShell -Command {Remove-Item "C:\Users\Administrator\win_get_url.jpg" -Force}
raw: >
PowerShell -Command Remove-Item "{{test_win_get_url_path}}" -Force
ignore_errors: true
- name: test win_get_url module
win_get_url: url=http://placehold.it/10x10.jpg dest='C:\Users\Administrator\win_get_url.jpg'
win_get_url:
url: "{{test_win_get_url_link}}"
dest: "{{test_win_get_url_path}}"
register: win_get_url_result
- name: check win_get_url result
- name: check that url was downloaded
assert:
that:
- "not win_get_url_result|failed"
- "win_get_url_result|changed"
- "win_get_url_result.win_get_url.url"
- "win_get_url_result.win_get_url.dest"
# FIXME:
# - Test invalid url
# - Test invalid dest, when dest is directory
# - Test idempotence when downloading same url/dest (not yet implemented)
- name: test win_get_url module again (force should be yes by default)
win_get_url:
url: "{{test_win_get_url_link}}"
dest: "{{test_win_get_url_path}}"
register: win_get_url_result_again
- name: check that url was downloaded again
assert:
that:
- "not win_get_url_result_again|failed"
- "win_get_url_result_again|changed"
- name: test win_get_url module again with force=no
win_get_url:
url: "{{test_win_get_url_link}}"
dest: "{{test_win_get_url_path}}"
force: no
register: win_get_url_result_noforce
- name: check that url was not downloaded again
assert:
that:
- "not win_get_url_result_noforce|failed"
- "not win_get_url_result_noforce|changed"
- name: test win_get_url module with url that returns a 404
win_get_url:
url: "{{test_win_get_url_invalid_link}}"
dest: "{{test_win_get_url_path}}"
register: win_get_url_result_invalid_link
ignore_errors: true
- name: check that the download failed for an invalid url
assert:
that:
- "win_get_url_result_invalid_link|failed"
- name: test win_get_url module with an invalid path
win_get_url:
url: "{{test_win_get_url_link}}"
dest: "{{test_win_get_url_invalid_path}}"
register: win_get_url_result_invalid_path
ignore_errors: true
- name: check that the download failed for an invalid path
assert:
that:
- "win_get_url_result_invalid_path|failed"
- name: test win_get_url module with a valid path that is a directory
win_get_url:
url: "{{test_win_get_url_link}}"
dest: "{{test_win_get_url_dir_path}}"
register: win_get_url_result_dir_path
ignore_errors: true
- name: check that the download failed if dest is a directory
assert:
that:
- "win_get_url_result_dir_path|failed"

View File

@@ -17,7 +17,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: use win_get_url module to download msi
win_get_url: url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi dest='C:\7z922-x64.msi'
win_get_url: url=http://downloads.sourceforge.net/project/sevenzip/7-Zip/9.22/7z922-x64.msi dest='C:\\7z922-x64.msi'
register: win_get_url_result
- name: install 7zip msi

View File

@@ -28,7 +28,7 @@
- "win_ping_result.ping == 'pong'"
- name: test win_ping with data
win_ping: data=blah
win_ping: data=
register: win_ping_with_data_result
- name: check win_ping result with data
@@ -36,21 +36,11 @@
that:
- "not win_ping_with_data_result|failed"
- "not win_ping_with_data_result|changed"
- "win_ping_with_data_result.ping == 'blah'"
- "win_ping_with_data_result.ping == ''"
#- name: test local ping (should use default ping)
# local_action: ping
# register: local_ping_result
#- name: check local ping result
# assert:
# that:
# - "not local_ping_result|failed"
# - "not local_ping_result|changed"
# - "local_ping_result.ping == 'pong'"
- name: test win_ping.ps1 with data
win_ping.ps1: data=bleep
- name: test win_ping.ps1 with data as complex args
win_ping.ps1:
data: bleep
register: win_ping_ps1_result
- name: check win_ping.ps1 result with data
@@ -60,13 +50,32 @@
- "not win_ping_ps1_result|changed"
- "win_ping_ps1_result.ping == 'bleep'"
#- name: test win_ping with invalid args
# win_ping: arg=invalid
# register: win_ping_ps1_invalid_args_result
#- name: check that win_ping.ps1 with invalid args fails
# assert:
# that:
# - "win_ping_ps1_invalid_args_result|failed"
# - "win_ping_ps1_invalid_args_result.msg"
- name: test win_ping with extra args to verify that v2 module replacer escaping works as expected
win_ping:
data: bloop
a_null: null
a_boolean: true
another_boolean: false
a_number: 299792458
another_number: 22.7
yet_another_number: 6.022e23
a_string: |
it's magic
"@'
'@"
an_array:
- first
- 2
- 3.0
an_object:
- the_thing: the_value
- the_other_thing: 0
- the_list_of_things: [1, 2, 3, 5]
register: win_ping_extra_args_result
- name: check that win_ping with extra args succeeds and ignores everything except data
assert:
that:
- "not win_ping_extra_args_result|failed"
- "not win_ping_extra_args_result|changed"
- "win_ping_extra_args_result.ping == 'bloop'"

View File

@@ -72,7 +72,7 @@
- "not unknown_result|changed"
- name: run a command that takes longer than 60 seconds
raw: PowerShell -Command Start-Sleep -s 75
raw: Start-Sleep -s 75
register: sleep_command
- name: assert that the sleep command ran
@@ -83,3 +83,12 @@
- "not sleep_command.stderr"
- "not sleep_command|failed"
- "not sleep_command|changed"
- name: run a raw command with key=value arguments
raw: echo wwe=raw
register: raw_result
- name: make sure raw is really raw and not removing key=value arguments
assert:
that:
- "raw_result.stdout_lines[0] == 'wwe=raw'"

View File

@@ -3,3 +3,4 @@
# Parameters to pass to test scripts.
test_win_script_value: VaLuE
test_win_script_splat: "@{This='THIS'; That='THAT'; Other='OTHER'}"
test_win_script_filename: "C:/Users/{{ansible_ssh_user}}/testing_win_script.txt"

View File

@@ -0,0 +1,2 @@
@ECHO OFF
ECHO We can even run a batch file with cmd extension!

View File

@@ -0,0 +1,3 @@
# Test script to create a file.
echo $null > $args[0]

View File

@@ -0,0 +1,3 @@
# Test script to remove a file.
Remove-Item $args[0] -Force

View File

@@ -30,24 +30,24 @@
- "not test_script_result|failed"
- "test_script_result|changed"
- name: run test script that takes arguments
script: test_script_with_args.ps1 /this /that /other
- name: run test script that takes arguments including a unicode char
script: test_script_with_args.ps1 /this /that /Ӧther
register: test_script_with_args_result
- name: check that script ran and received arguments
- name: check that script ran and received arguments and returned unicode
assert:
that:
- "test_script_with_args_result.rc == 0"
- "test_script_with_args_result.stdout"
- "test_script_with_args_result.stdout_lines[0] == '/this'"
- "test_script_with_args_result.stdout_lines[1] == '/that'"
- "test_script_with_args_result.stdout_lines[2] == '/other'"
- "test_script_with_args_result.stdout_lines[2] == '/Ӧther'"
- "not test_script_with_args_result.stderr"
- "not test_script_with_args_result|failed"
- "test_script_with_args_result|changed"
- name: run test script that takes parameters passed via splatting
script: test_script_with_splatting.ps1 "@{ This = 'this'; That = '{{ test_win_script_value }}'; Other = 'other'}"
script: test_script_with_splatting.ps1 @{ This = 'this'; That = '{{ test_win_script_value }}'; Other = 'other'}
register: test_script_with_splatting_result
- name: check that script ran and received parameters via splatting
@@ -63,7 +63,7 @@
- "test_script_with_splatting_result|changed"
- name: run test script that takes splatted parameters from a variable
script: test_script_with_splatting.ps1 {{ test_win_script_splat|quote }}
script: test_script_with_splatting.ps1 {{ test_win_script_splat }}
register: test_script_with_splatting2_result
- name: check that script ran and received parameters via splatting from a variable
@@ -92,6 +92,58 @@
- "test_script_with_errors_result|failed"
- "test_script_with_errors_result|changed"
- name: cleanup test file if it exists
raw: Remove-Item "{{test_win_script_filename}}" -Force
ignore_errors: true
- name: run test script that creates a file
script: test_script_creates_file.ps1 "{{test_win_script_filename}}" creates="{{test_win_script_filename}}"
register: test_script_creates_file_result
- name: check that script ran and indicated a change
assert:
that:
- "test_script_creates_file_result.rc == 0"
- "not test_script_creates_file_result.stdout"
- "not test_script_creates_file_result.stderr"
- "not test_script_creates_file_result|failed"
- "test_script_creates_file_result|changed"
- name: run test script that creates a file again
script: test_script_creates_file.ps1 "{{test_win_script_filename}}" creates="{{test_win_script_filename}}"
register: test_script_creates_file_again_result
- name: check that the script did not run since the remote file exists
assert:
that:
- "not test_script_creates_file_again_result|failed"
- "not test_script_creates_file_again_result|changed"
- "test_script_creates_file_again_result|skipped"
- name: run test script that removes a file
script: test_script_removes_file.ps1 "{{test_win_script_filename}}" removes="{{test_win_script_filename}}"
register: test_script_removes_file_result
- name: check that the script ran since the remote file exists
assert:
that:
- "test_script_removes_file_result.rc == 0"
- "not test_script_removes_file_result.stdout"
- "not test_script_removes_file_result.stderr"
- "not test_script_removes_file_result|failed"
- "test_script_removes_file_result|changed"
- name: run test script that removes a file again
script: test_script_removes_file.ps1 "{{test_win_script_filename}}" removes="{{test_win_script_filename}}"
register: test_script_removes_file_again_result
- name: check that the script did not run since the remote file does not exist
assert:
that:
- "not test_script_removes_file_again_result|failed"
- "not test_script_removes_file_again_result|changed"
- "test_script_removes_file_again_result|skipped"
- name: run simple batch file
script: test_script.bat
register: test_batch_result
@@ -105,3 +157,17 @@
- "not test_batch_result.stderr"
- "not test_batch_result|failed"
- "test_batch_result|changed"
- name: run simple batch file with .cmd extension
script: test_script.cmd
register: test_cmd_result
- name: check that batch file with .cmd extension ran
assert:
that:
- "test_cmd_result.rc == 0"
- "test_cmd_result.stdout"
- "'cmd extension' in test_cmd_result.stdout"
- "not test_cmd_result.stderr"
- "not test_cmd_result|failed"
- "test_cmd_result|changed"

View File

@@ -20,7 +20,7 @@
action: setup
register: setup_result
- name: check setup result
- name: check windows setup result
assert:
that:
- "not setup_result|failed"
@@ -38,6 +38,8 @@
- "setup_result.ansible_facts.ansible_interfaces[0]"
- "setup_result.ansible_facts.ansible_interfaces[0].interface_name"
- "setup_result.ansible_facts.ansible_interfaces[0].interface_index"
- "setup_result.ansible_facts.ansible_architecture"
- "setup_result.ansible_facts.ansible_os_name"
- "setup_result.ansible_facts.ansible_powershell_version"
- name: check setup result only when using https

View File

@@ -27,6 +27,12 @@
- "not win_stat_file.stat.isdir"
- "win_stat_file.stat.size > 0"
- "win_stat_file.stat.md5"
- "win_stat_file.stat.extension"
- "win_stat_file.stat.attributes"
- "win_stat_file.stat.owner"
- "win_stat_file.stat.creationtime"
- "win_stat_file.stat.lastaccesstime"
- "win_stat_file.stat.lastwritetime"
- "not win_stat_file|failed"
- "not win_stat_file|changed"
@@ -34,13 +40,19 @@
win_stat: path="C:\Windows\win.ini" get_md5=no
register: win_stat_file_no_md5
- name: check win_stat file result without md
- name: check win_stat file result without md5
assert:
that:
- "win_stat_file_no_md5.stat.exists"
- "not win_stat_file_no_md5.stat.isdir"
- "win_stat_file_no_md5.stat.size > 0"
- "not win_stat_file_no_md5.stat.md5|default('')"
- "win_stat_file_no_md5.stat.extension"
- "win_stat_file_no_md5.stat.attributes"
- "win_stat_file_no_md5.stat.owner"
- "win_stat_file_no_md5.stat.creationtime"
- "win_stat_file_no_md5.stat.lastaccesstime"
- "win_stat_file_no_md5.stat.lastwritetime"
- "not win_stat_file_no_md5|failed"
- "not win_stat_file_no_md5|changed"
@@ -53,6 +65,12 @@
that:
- "win_stat_dir.stat.exists"
- "win_stat_dir.stat.isdir"
- "win_stat_dir.stat.extension == ''"
- "win_stat_dir.stat.attributes"
- "win_stat_dir.stat.owner"
- "win_stat_dir.stat.creationtime"
- "win_stat_dir.stat.lastaccesstime"
- "win_stat_dir.stat.lastwritetime"
- "not win_stat_dir|failed"
- "not win_stat_dir|changed"

View File

@@ -39,13 +39,24 @@
that:
- "template_result.changed == true"
- name: fill in a basic template again
win_template:
src: foo.j2
dest: "{{win_output_dir}}/foo.templated"
register: template_result2
- name: verify that the template was not changed
assert:
that:
- "not template_result2|changed"
# VERIFY CONTENTS
- name: copy known good into place
win_copy: src=foo.txt dest={{win_output_dir}}\foo.txt
win_copy: src=foo.txt dest={{win_output_dir}}\\foo.txt
- name: compare templated file to known good
raw: fc.exe {{win_output_dir}}\foo.templated {{win_output_dir}}\foo.txt
raw: fc.exe {{win_output_dir}}\\foo.templated {{win_output_dir}}\\foo.txt
register: diff_result
- debug: var=diff_result

View File

@@ -51,7 +51,7 @@
- "win_user_missing_query_result.state == 'absent'"
- name: test create user
win_user: name="{{ test_win_user_name }}" password="{{ test_win_user_password }}" groups="Guests"
win_user: name="{{ test_win_user_name }}" password="{{ test_win_user_password }}" fullname="Test User" description="Test user account" groups="Guests"
register: win_user_create_result
- name: check user creation result
@@ -59,7 +59,8 @@
that:
- "win_user_create_result|changed"
- "win_user_create_result.name == '{{ test_win_user_name }}'"
- "win_user_create_result.fullname == '{{ test_win_user_name }}'"
- "win_user_create_result.fullname == 'Test User'"
- "win_user_create_result.description == 'Test user account'"
- "win_user_create_result.path"
- "win_user_create_result.state == 'present'"

View File

@@ -0,0 +1,5 @@
- hosts: testhost
connection: local
gather_facts: yes
roles:
- { role: test_filters }

View File

@@ -7,6 +7,8 @@
connection: local
roles:
- { role: test_force_handlers }
tasks:
- debug: msg="you should see this with --tags=normal"
- name: test force handlers (set to true)
tags: force_true_in_play
@@ -15,7 +17,7 @@
connection: local
force_handlers: True
roles:
- { role: test_force_handlers }
- { role: test_force_handlers, tags: force_true_in_play }
- name: test force handlers (set to false)
@@ -25,4 +27,4 @@
connection: local
force_handlers: False
roles:
- { role: test_force_handlers }
- { role: test_force_handlers, tags: force_false_in_play }

View File

@@ -16,19 +16,25 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- hosts: lamini
- name: Create overall groups
hosts: lamini
gather_facts: false
tasks:
- debug: var=genus
- name: group by genus
group_by: key={{ genus }}
- name: group by first three letters of genus with key in quotes
group_by: key="{{ genus | truncate(3, true, '') }}"
- name: group by first two letters of genus with key not in quotes
group_by: key={{ genus | truncate(2, true, '') }}
- name: group by genus in uppercase using complex args
group_by: { key: "{{ genus | upper() }}" }
- hosts: vicugna
- name: Vicunga group validation
hosts: vicugna
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@@ -36,7 +42,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_vicugna=true
- hosts: lama
- name: Lama group validation
hosts: lama
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@@ -44,7 +51,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_lama=true
- hosts: vic
- name: Vic group validation
hosts: vic
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@@ -52,7 +60,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_vic=true
- hosts: lam
- name: Lam group validation
hosts: lam
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@@ -60,7 +69,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_lam=true
- hosts: vi
- name: Vi group validation
hosts: vi
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@@ -68,7 +78,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_vi=true
- hosts: la
- name: La group validation
hosts: la
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@@ -76,7 +87,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_la=true
- hosts: VICUGNA
- name: VICUGNA group validation
hosts: VICUGNA
gather_facts: false
tasks:
- name: verify that only the alpaca is in this group
@@ -84,7 +96,8 @@
- name: set a fact to check that we ran this play
set_fact: genus_VICUGNA=true
- hosts: LAMA
- name: LAMA group validation
hosts: LAMA
gather_facts: false
tasks:
- name: verify that only the llama is in this group
@@ -92,19 +105,22 @@
- name: set a fact to check that we ran this play
set_fact: genus_LAMA=true
- hosts: 'genus'
- name: genus group validation (expect skipped)
hosts: 'genus'
gather_facts: false
tasks:
- name: no hosts should match this group
fail: msg="should never get here"
- hosts: alpaca
- name: alpaca validation of groups
hosts: alpaca
gather_facts: false
tasks:
- name: check that alpaca matched all four groups
assert: { that: ["genus_vicugna", "genus_vic", "genus_vi", "genus_VICUGNA"] }
- hosts: llama
- name: llama validation of groups
hosts: llama
gather_facts: false
tasks:
- name: check that llama matched all four groups

View File

@@ -4,7 +4,7 @@
gather_facts: False
connection: local
roles:
- { role: test_handlers_meta }
- { role: test_handlers_meta, tags: ['scenario1'] }
- name: verify final handler was run
hosts: A
@@ -16,6 +16,7 @@
that:
- "not hostvars[inventory_hostname]['handler1_called']"
- "'handler2_called' in hostvars[inventory_hostname]"
tags: ['scenario1']
- name: test handlers
hosts: testgroup

View File

@@ -14,9 +14,9 @@
- { role: test_includes, tags: test_includes }
tasks:
- include: roles/test_includes/tasks/not_a_role_task.yml
- include: roles/test_includes/tasks/empty.yml
- assert:
that:
- "ca == 33000"
- "cb == 33001"
- "cc == 33002"

View File

@@ -36,7 +36,7 @@
- hosts: inven_overridehosts
vars_files:
- "{{ var_dir }}/test_var_precedence.yml"
- "test_var_precedence.yml"
roles:
- role: test_var_precedence_inven_override
foo: bar

View File

@@ -18,6 +18,7 @@
- hosts: windows
gather_facts: false
max_fail_percentage: 1
roles:
- { role: test_win_raw, tags: test_win_raw }
- { role: test_win_script, tags: test_win_script }