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-05-07 02:30:37 +00:00
all : non_destructive destructive check_mode test_hash test_handlers test_group_by
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)
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 :
ansible-playbook test_var_precedence.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v -e 'extra_var=extra_var'
2014-02-24 19:37:23 +00:00
cloud : amazon rackspace
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
rackspace_cleanup :
@echo "FIXME - cleanup_rax.py not yet implemented"
2014-03-13 13:52:36 +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
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;