@ -1,3 +1,4 @@
TEST_DIR ?= ~/ansible_testing
INVENTORY ?= inventory
VARS_FILE ?= integration_config.yml
@ -21,14 +22,18 @@ VAULT_PASSWORD_FILE = vault-password
CONSUL_RUNNING := $( shell python consul_running.py)
all : parsing test_var_precedence unicode test_templating_settings environment non_destructive destructive includes blocks pull check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths no_log
all : setup parsing test_var_precedence unicode test_templating_settings environment non_destructive destructive includes blocks pull check_mode test_hash test_handlers test_group_by test_vault test_tags test_lookup_paths no_log
setup :
rm -rf $( TEST_DIR)
mkdir -p $( TEST_DIR)
parsing :
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)
ansible-playbook bad_parsing.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -vvv $( TEST_FLAGS) --tags prepare,common,scenario5
ansible-playbook good_parsing.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
includes :
ansible-playbook test_includes.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) $( TEST_FLAGS)
includes : setup
ansible-playbook test_includes.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) $( TEST_FLAGS)
pull : pull_run pull_no_ 127 pull_limit_inventory
@ -53,28 +58,28 @@ pull_limit_inventory:
exit $$ RC
unicode :
ansible-playbook unicode.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS) -e 'extra_var=café'
unicode : setup
ansible-playbook unicode.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) -v $( TEST_FLAGS) -e 'extra_var=café'
# Test the start-at-task flag #9571
ansible-playbook unicode.yml -i $( INVENTORY) -e @$( VARS_FILE) -v --start-at-task '*¶' -e 'start_at_task=True' $( TEST_FLAGS)
ansible-playbook unicode.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) -v --start-at-task '*¶' -e 'start_at_task=True' $( TEST_FLAGS)
test_templating_settings :
ansible-playbook test_templating_settings.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_templating_settings : setup
ansible-playbook test_templating_settings.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
environment :
ansible-playbook test_environment.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) $( TEST_FLAGS)
environment : setup
ansible-playbook test_environment.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) $( TEST_FLAGS)
non_destructive :
ansible-playbook non_destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
non_destructive : setup
ansible-playbook non_destructive.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
destructive :
ansible-playbook destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
destructive : setup
ansible-playbook destructive.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
check_mode :
ansible-playbook check_mode.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v --check $( TEST_FLAGS)
check_mode : setup
ansible-playbook check_mode.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v --check $( TEST_FLAGS)
test_group_by :
ansible-playbook test_group_by.yml -i inventory.group_by -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_group_by : setup
ansible-playbook test_group_by.yml -i inventory.group_by -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_handlers :
ansible-playbook test_handlers.yml --tags scenario1 -i inventory.handlers -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
@ -98,14 +103,14 @@ test_hash:
ANSIBLE_HASH_BEHAVIOUR = replace ansible-playbook test_hash.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v -e '{"test_hash":{"extra_args":"this is an extra arg"}}'
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) $( TEST_FLAGS) -v -e 'extra_var=extra_var' -e 'extra_var_override=extra_var_override'
test_var_precedence : setup
ansible-playbook test_var_precedence.yml -i $( INVENTORY) $( CREDENTIALS_ARG) $( TEST_FLAGS) -v -e outputdir = $( TEST_DIR) -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
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE) --list-hosts
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE) --syntax-check
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE)
test_vault : setup
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE) --list-tasks -e outputdir = $( TEST_DIR)
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE) --list-hosts -e outputdir = $( TEST_DIR)
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE) --syntax-check -e outputdir = $( TEST_DIR)
ansible-playbook test_vault.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) --vault-password-file $( VAULT_PASSWORD_FILE) -e outputdir = $( TEST_DIR)
# test_delegate_to does not work unless we have permission to ssh to localhost.
# Would take some more effort on our test systems to implement that -- probably
@ -113,30 +118,30 @@ test_vault:
# root user on a node to ssh to itself. Until then, this is not in make all.
# Have to run it manually. Ordinary users should be able to run this test as
# long as they have permissions to login to their local machine via ssh.
test_delegate_to :
ansible-playbook test_delegate_to.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_delegate_to : setup
ansible-playbook test_delegate_to.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_winrm :
ansible-playbook test_winrm.yml -i inventory.winrm -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_winrm : setup
ansible-playbook test_winrm.yml -i inventory.winrm -e outputdir = $( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
test_tags :
test_tags : setup
# Run everything by default
[ " $$ (ansible-playbook --list-tasks test_tags.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | fgrep Task_with | xargs) " = "Task_with_tag TAGS: [tag] Task_with_always_tag TAGS: [always] Task_without_tag TAGS: []" ]
[ " $$ (ansible-playbook --list-tasks test_tags.yml -i $( INVENTORY) -e outputdir=$( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | fgrep Task_with | xargs) " = "Task_with_tag TAGS: [tag] Task_with_always_tag TAGS: [always] Task_without_tag TAGS: []" ]
# Run the exact tags, and always
[ " $$ (ansible-playbook --list-tasks --tags tag test_tags.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | fgrep Task_with | xargs) " = "Task_with_tag TAGS: [tag] Task_with_always_tag TAGS: [always]" ]
[ " $$ (ansible-playbook --list-tasks --tags tag test_tags.yml -i $( INVENTORY) -e outputdir=$( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | fgrep Task_with | xargs) " = "Task_with_tag TAGS: [tag] Task_with_always_tag TAGS: [always]" ]
# Skip one tag
[ " $$ (ansible-playbook --list-tasks --skip-tags tag test_tags.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | fgrep Task_with | xargs) " = "Task_with_always_tag TAGS: [always] Task_without_tag TAGS: []" ]
[ " $$ (ansible-playbook --list-tasks --skip-tags tag test_tags.yml -i $( INVENTORY) -e outputdir=$( TEST_DIR) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | fgrep Task_with | xargs) " = "Task_with_always_tag TAGS: [always] Task_without_tag TAGS: []" ]
blocks :
blocks : setup
# remove old output log
rm -f block_test.out
# run the test and check to make sure the right number of completions was logged
ansible-playbook -vv test_blocks/main.yml | tee block_test.out
ansible-playbook -vv -e outputdir = $( TEST_DIR) test_blocks/main.yml | tee block_test.out
[ " $$ (grep 'TEST COMPLETE' block_test.out | wc -l) " = " $$ (egrep '^[0-9]+ plays in' block_test.out | cut -f1 -d' ') " ]
# cleanup the output log again, to make sure the test is clean
rm -f block_test.out
# run test with free strategy and again count the completions
ansible-playbook -vv test_blocks/main.yml -e test_strategy = free | tee block_test.out
ansible-playbook -vv -e outputdir = $( TEST_DIR) test_blocks/main.yml -e test_strategy = free | tee block_test.out
[ " $$ (grep 'TEST COMPLETE' block_test.out | wc -l) " = " $$ (egrep '^[0-9]+ plays in' block_test.out | cut -f1 -d' ') " ]
cloud : amazon rackspace azure
@ -204,25 +209,25 @@ endif
test_galaxy : test_galaxy_spec test_galaxy_yaml test_galaxy_git
test_galaxy_spec :
test_galaxy_spec : setup
mytmpdir = $( MYTMPDIR) ; \
ansible-galaxy install -r galaxy_rolesfile -p $$ mytmpdir/roles -vvvv ; \
cp galaxy_playbook.yml $$ mytmpdir ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -v $( TEST_FLAGS) ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -e outputdir = $( TEST_DIR) - v $( TEST_FLAGS) ; \
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
exit $$ RC
test_galaxy_yaml :
test_galaxy_yaml : setup
mytmpdir = $( MYTMPDIR) ; \
ansible-galaxy install -r galaxy_roles.yml -p $$ mytmpdir/roles -vvvv; \
cp galaxy_playbook.yml $$ mytmpdir ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -v $( TEST_FLAGS) ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -e outputdir = $( TEST_DIR) - v $( TEST_FLAGS) ; \
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
exit $$ RC
test_galaxy_git :
test_galaxy_git : setup
mytmpdir = $( MYTMPDIR) ; \
ansible-galaxy install git+https://bitbucket.org/willthames/git-ansible-galaxy,v1.6 -p $$ mytmpdir/roles -vvvv; \
cp galaxy_playbook_git.yml $$ mytmpdir ; \
@ -231,9 +236,9 @@ test_galaxy_git:
rm -rf $$ mytmpdir ; \
exit $$ RC
test_lookup_paths :
ansible-playbook lookup_paths/play.yml -i $( INVENTORY) -v $( TEST_FLAGS)
test_lookup_paths : setup
ansible-playbook lookup_paths/play.yml -i $( INVENTORY) -e outputdir = $( TEST_DIR) - v $( TEST_FLAGS)
no_log :
no_log : setup
# This test expects 7 loggable vars and 0 non loggable ones, if either mismatches it fails, run the ansible-playbook command to debug
[ " $$ (ansible-playbook no_log_local.yml -i $( INVENTORY) - vvvvv | awk --source 'BEGIN { logme = 0; nolog = 0; } /LOG_ME/ { logme += 1;} /DO_NOT_LOG/ { nolog += 1;} END { printf " %d/%d", logme, nolog; }')" = "6/0" ]
[ " $$ (ansible-playbook no_log_local.yml -i $( INVENTORY) - e outputdir=$( TEST_DIR) - vvvvv | awk --source 'BEGIN { logme = 0; nolog = 0; } /LOG_ME/ { logme += 1;} /DO_NOT_LOG/ { nolog += 1;} END { printf " %d/%d", logme, nolog; }')" = "6/0" ]