2014-03-12 18:37:15 +00:00
INVENTORY ?= inventory
VARS_FILE ?= integration_config.yml
2014-03-13 13:52:36 +00:00
# Create a semi-random string for use when testing cloud-based resources
i f n d e f C L O U D _ R E S O U R C E _ P R E F I X
CLOUD_RESOURCE_PREFIX := $( shell python -c "import string,random; print 'ansible-testing-' + ''.join(random.choice(string.ascii_letters + string.digits) for _ in xrange(8));" )
e n d i f
2014-03-18 14:15:02 +00:00
CREDENTIALS_FILE = credentials.yml
# If credentials.yml exists, use it
i f n e q ( "$(wildcard $(CREDENTIALS_FILE))" , "" )
CREDENTIALS_ARG = -e @$( CREDENTIALS_FILE)
e l s e
CREDENTIALS_ARG =
e n d i f
2014-08-14 10:20:10 +00:00
# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
2015-02-03 00:17:40 +00:00
MYTMPDIR = $( shell mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir' )
2014-08-14 10:20:10 +00:00
2014-05-21 19:17:53 +00:00
VAULT_PASSWORD_FILE = vault-password
2015-01-24 01:09:03 +00:00
CONSUL_RUNNING := $( shell python consul_running.py)
2015-02-26 22:53:51 +00:00
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
2014-07-24 02:10:58 +00:00
parsing :
2015-06-01 21:41:52 +00:00
#ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario1; [ $$? -eq 4 ]
#ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario2; [ $$? -eq 4 ]
#ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario3; [ $$? -eq 4 ]
#ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario4; [ $$? -eq 4 ]
#ansible-playbook bad_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -vvv $(TEST_FLAGS) --tags prepare,common,scenario5; [ $$? -eq 4 ]
#ansible-playbook good_parsing.yml -i $(INVENTORY) -e @$(VARS_FILE) $(CREDENTIALS_ARG) -v $(TEST_FLAGS)
echo "skipping for now..."
2014-02-20 18:00:05 +00:00
2014-07-26 14:37:55 +00:00
includes :
2015-01-24 01:09:03 +00:00
ansible-playbook test_includes.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) $( TEST_FLAGS)
2014-07-26 14:37:55 +00:00
2014-07-25 13:59:26 +00:00
unicode :
2015-02-02 22:12:16 +00:00
ansible-playbook unicode.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS) -e 'extra_var=café'
2014-11-19 19:50:02 +00:00
# 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)
2014-07-25 13:59:26 +00:00
2015-02-26 22:05:33 +00:00
test_templating_settings :
ansible-playbook test_templating_settings.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-12-16 19:17:29 +00:00
2014-02-20 18:00:05 +00:00
non_destructive :
2014-03-18 14:15:02 +00:00
ansible-playbook non_destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 18:05:03 +00:00
2014-02-20 18:25:19 +00:00
destructive :
2014-03-18 14:15:02 +00:00
ansible-playbook destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 18:25:19 +00:00
2014-02-20 21:10:44 +00:00
check_mode :
2014-03-18 14:15:02 +00:00
ansible-playbook check_mode.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v --check $( TEST_FLAGS)
2014-02-20 21:10:44 +00:00
2014-05-07 02:30:37 +00:00
test_group_by :
ansible-playbook test_group_by.yml -i inventory.group_by -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-03-25 17:32:11 +00:00
test_handlers :
ansible-playbook test_handlers.yml -i inventory.handlers -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2015-04-04 20:37:14 +00:00
# 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
[ " $$ (ansible-playbook test_force_handlers.yml --tags normal -i inventory.handlers --force-handlers -e @ $( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs) " = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing from command line, should only run later tasks on unfailed hosts
[ " $$ (ansible-playbook test_force_handlers.yml --tags normal -i inventory.handlers --force-handlers -e @ $( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | egrep -o CALLED_TASK_. | sort | uniq | xargs) " = "CALLED_TASK_B CALLED_TASK_D CALLED_TASK_E" ]
# Forcing from command line, should call handlers even if all hosts fail
[ " $$ (ansible-playbook test_force_handlers.yml --tags normal -i inventory.handlers --force-handlers -e @ $( VARS_FILE) $( CREDENTIALS_ARG) -v -e fail_all=yes $( TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs) " = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing from ansible.cfg
[ " $$ (ANSIBLE_FORCE_HANDLERS=true ansible-playbook --tags normal test_force_handlers.yml -i inventory.handlers -e @ $( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs) " = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing true in play
[ " $$ (ansible-playbook test_force_handlers.yml --tags force_true_in_play -i inventory.handlers -e @ $( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs) " = "CALLED_HANDLER_A CALLED_HANDLER_B" ]
# Forcing false in play, which overrides command line
[ " $$ (ansible-playbook test_force_handlers.yml --force-handlers --tags force_false_in_play -i inventory.handlers -e @ $( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) | egrep -o CALLED_HANDLER_. | sort | uniq | xargs) " = "CALLED_HANDLER_B" ]
2014-03-25 17:32:11 +00:00
2014-02-20 20:23:51 +00:00
test_hash :
2014-03-18 14:15:02 +00:00
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"}}'
2014-02-24 19:37:23 +00:00
2014-05-09 16:42:45 +00:00
test_var_precedence :
2014-11-26 18:55:37 +00:00
ansible-playbook test_var_precedence.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v -e 'extra_var=extra_var' -e 'extra_var_override=extra_var_override'
2014-05-09 16:42:45 +00:00
2014-06-10 15:07:50 +00:00
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)
2014-05-21 19:17:53 +00:00
2014-12-08 21:39:01 +00:00
# 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
# the test node should create an ssh public-private key pair that allows the
# 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.
2014-12-08 20:44:44 +00:00
test_delegate_to :
ansible-playbook test_delegate_to.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-06-18 04:04:17 +00:00
test_winrm :
ansible-playbook test_winrm.yml -i inventory.winrm -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2015-02-13 01:58:30 +00:00
test_tags :
# Run everything by default
2015-03-11 20:28:37 +00:00
[ " $$ (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: []" ]
2015-02-13 01:58:30 +00:00
# Run the exact tags, and always
2015-03-11 20:28:37 +00:00
[ " $$ (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]" ]
2015-02-13 01:58:30 +00:00
# Skip one tag
2015-03-11 20:28:37 +00:00
[ " $$ (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: []" ]
2015-02-13 01:58:30 +00:00
2015-05-05 12:42:07 +00:00
cloud : amazon rackspace azure
2014-02-24 19:37:23 +00:00
2014-02-27 16:44:13 +00:00
cloud_cleanup : amazon_cleanup rackspace_cleanup
amazon_cleanup :
2014-03-13 13:52:36 +00:00
python cleanup_ec2.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-02-27 16:44:13 +00:00
2015-05-05 12:42:07 +00:00
azure_cleanup :
python cleanup_azure.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-04-11 22:45:56 +00:00
gce_setup :
python setup_gce.py " $( CLOUD_RESOURCE_PREFIX) "
2014-03-30 00:27:48 +00:00
gce_cleanup :
python cleanup_gce.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-02-27 16:44:13 +00:00
rackspace_cleanup :
2015-01-09 20:50:23 +00:00
python cleanup_rax.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-02-27 16:44:13 +00:00
2014-03-18 14:15:02 +00:00
$(CREDENTIALS_FILE) :
@echo " No credentials file found. A file named ' $( CREDENTIALS_FILE) ' is needed to provide credentials needed to run cloud tests. See sample 'credentials.template' file. "
2014-02-24 19:37:23 +00:00
@exit 1
2014-03-18 14:15:02 +00:00
amazon : $( CREDENTIALS_FILE )
2014-05-05 20:07:59 +00:00
ANSIBLE_HOST_KEY_CHECKING = False ANSIBLE_SSH_PIPELINING = no BOTO_CONFIG = /dev/null ansible-playbook amazon.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
2014-02-27 16:44:13 +00:00
RC = $$ ? ; \
2014-03-13 13:52:36 +00:00
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make amazon_cleanup ; \
2014-02-27 16:44:13 +00:00
exit $$ RC;
2014-02-24 19:37:23 +00:00
2015-05-05 12:42:07 +00:00
azure : $( CREDENTIALS_FILE )
ANSIBLE_HOST_KEY_CHECKING = False ansible-playbook azure.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make azure_cleanup ; \
exit $$ RC;
2014-03-30 00:27:48 +00:00
gce : $( CREDENTIALS_FILE )
2014-04-11 22:45:56 +00:00
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make gce_setup ; \
ansible-playbook gce.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
2014-03-30 00:27:48 +00:00
RC = $$ ? ; \
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make gce_cleanup ; \
exit $$ RC;
2014-03-18 14:15:02 +00:00
rackspace : $( CREDENTIALS_FILE )
ansible-playbook rackspace.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
2014-02-27 16:44:13 +00:00
RC = $$ ? ; \
2014-03-13 13:52:36 +00:00
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make rackspace_cleanup ; \
2014-02-27 16:44:13 +00:00
exit $$ RC;
2014-08-14 10:20:10 +00:00
2015-05-03 14:06:30 +00:00
cloudstack :
ansible-playbook cloudstack.yml -i $( INVENTORY) -e @$( VARS_FILE) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
exit $$ RC;
2015-01-24 01:09:03 +00:00
$(CONSUL_RUNNING) :
consul :
i f e q ( $( CONSUL_RUNNING ) , T r u e )
ansible-playbook -i $( INVENTORY) consul.yml ; \
ansible-playbook -i ../../plugins/inventory/consul_io.py consul_inventory.yml
e l s e
@echo "Consul agent is not running locally. To run a cluster locally see http://github.com/sgargan/consul-vagrant"
e n d i f
2014-08-18 11:27:41 +00:00
test_galaxy : test_galaxy_spec test_galaxy_yaml
test_galaxy_spec :
2015-02-03 00:17:40 +00:00
mytmpdir = $( MYTMPDIR) ; \
2014-08-14 10:20:10 +00:00
ansible-galaxy install -r galaxy_rolesfile -p $$ mytmpdir/roles ; \
cp galaxy_playbook.yml $$ mytmpdir ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
2014-08-18 11:27:41 +00:00
exit $$ RC
test_galaxy_yaml :
2015-02-03 00:17:40 +00:00
mytmpdir = $( MYTMPDIR) ; \
2014-08-18 11:27:41 +00:00
ansible-galaxy install -r galaxy_roles.yml -p $$ mytmpdir/roles ; \
cp galaxy_playbook.yml $$ mytmpdir ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
exit $$ RC