2014-03-12 19:37:15 +01:00
INVENTORY ?= inventory
VARS_FILE ?= integration_config.yml
2014-03-13 14:52:36 +01: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 15:15:02 +01: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 12:20:10 +02:00
# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
TMPDIR = $( shell mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir' )
2014-05-21 21:17:53 +02:00
VAULT_PASSWORD_FILE = vault-password
2014-11-17 22:30:22 +01:00
all : parsing test_var_precedence unicode non_destructive destructive includes check_mode test_hash test_handlers test_group_by test_vault
2014-07-24 04:10:58 +02:00
parsing :
2014-11-19 16:40:52 +01:00
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 ]
2014-07-24 04:10:58 +02:00
ansible-playbook good_parsing.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 19:00:05 +01:00
2014-07-26 16:37:55 +02:00
includes :
ansible-playbook test_includes.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) $( TEST_FLAGS)
2014-07-25 15:59:26 +02:00
unicode :
ansible-playbook unicode.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS)
2014-11-19 20:50:02 +01: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 15:59:26 +02:00
2014-02-20 19:00:05 +01:00
non_destructive :
2014-03-18 15:15:02 +01:00
ansible-playbook non_destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 19:05:03 +01:00
2014-02-20 19:25:19 +01:00
destructive :
2014-03-18 15:15:02 +01:00
ansible-playbook destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 19:25:19 +01:00
2014-02-20 22:10:44 +01:00
check_mode :
2014-03-18 15:15:02 +01:00
ansible-playbook check_mode.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v --check $( TEST_FLAGS)
2014-02-20 22:10:44 +01:00
2014-05-07 04:30:37 +02: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 18:32:11 +01:00
test_handlers :
ansible-playbook test_handlers.yml -i inventory.handlers -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 21:23:51 +01:00
test_hash :
2014-03-18 15:15:02 +01: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 20:37:23 +01:00
2014-05-09 18:42:45 +02:00
test_var_precedence :
ansible-playbook test_var_precedence.yml -i $( INVENTORY) $( CREDENTIALS_ARG) -v -e 'extra_var=extra_var'
2014-06-10 17:07:50 +02: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 21:17:53 +02:00
2014-06-18 06:04:17 +02:00
test_winrm :
ansible-playbook test_winrm.yml -i inventory.winrm -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-24 20:37:23 +01:00
cloud : amazon rackspace
2014-02-27 17:44:13 +01:00
cloud_cleanup : amazon_cleanup rackspace_cleanup
amazon_cleanup :
2014-03-13 14:52:36 +01:00
python cleanup_ec2.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-02-27 17:44:13 +01:00
2014-04-12 00:45:56 +02:00
gce_setup :
python setup_gce.py " $( CLOUD_RESOURCE_PREFIX) "
2014-03-30 01:27:48 +01:00
gce_cleanup :
python cleanup_gce.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-02-27 17:44:13 +01:00
rackspace_cleanup :
@echo "FIXME - cleanup_rax.py not yet implemented"
2014-03-13 14:52:36 +01:00
@# python cleanup_rax.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2014-02-27 17:44:13 +01:00
2014-03-18 15:15:02 +01: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 20:37:23 +01:00
@exit 1
2014-03-18 15:15:02 +01:00
amazon : $( CREDENTIALS_FILE )
2014-05-05 22:07:59 +02: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 17:44:13 +01:00
RC = $$ ? ; \
2014-03-13 14:52:36 +01:00
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make amazon_cleanup ; \
2014-02-27 17:44:13 +01:00
exit $$ RC;
2014-02-24 20:37:23 +01:00
2014-03-30 01:27:48 +01:00
gce : $( CREDENTIALS_FILE )
2014-04-12 00:45:56 +02: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 01:27:48 +01:00
RC = $$ ? ; \
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make gce_cleanup ; \
exit $$ RC;
2014-03-18 15:15:02 +01: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 17:44:13 +01:00
RC = $$ ? ; \
2014-03-13 14:52:36 +01:00
CLOUD_RESOURCE_PREFIX = " $( CLOUD_RESOURCE_PREFIX) " make rackspace_cleanup ; \
2014-02-27 17:44:13 +01:00
exit $$ RC;
2014-08-14 12:20:10 +02:00
2014-08-18 13:27:41 +02:00
test_galaxy : test_galaxy_spec test_galaxy_yaml
test_galaxy_spec :
2014-08-14 12:20:10 +02:00
mytmpdir = $( TMPDIR) ; \
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 13:27:41 +02:00
exit $$ RC
test_galaxy_yaml :
mytmpdir = $( TMPDIR) ; \
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