2016-03-03 20:22:35 +00:00
TEST_DIR ?= ~/ansible_testing
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
2015-10-16 14:41:01 +00:00
CLOUD_RESOURCE_PREFIX := $( shell python -c "import string,random; print('ansible-testing-' + ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8)));" )
2014-03-13 13:52:36 +00:00
e n d i f
2015-10-17 16:45:29 +00:00
CREDENTIALS_FILE ?= credentials.yml
2014-03-18 14:15:02 +00:00
# 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)
2016-03-04 19:21:43 +00:00
EUID := $( shell id -u -r)
2015-01-24 01:09:03 +00:00
2016-05-11 20:36:29 +00:00
UNAME := $( shell uname | tr '[:upper:]' '[:lower:]' )
2016-10-12 21:57:53 +00:00
all : other non_destructive destructive
2016-06-02 20:39:27 +00:00
2017-02-24 17:33:24 +00:00
other : ansible test_test_infra parsing test_var_blending test_var_precedence unicode test_templating_settings \
environment test_as includes blocks pull_run pull_no_127 pull_limit_inventory check_mode test_hash test_handlers \
test_group_by test_vault test_tags test_lookup_paths no_log test_gathering_facts test_binary_modules_posix \
test_hosts_field test_lookup_properties args test_jinja2_groupby test_callback_retry_task_name
2016-11-11 05:47:12 +00:00
ansible :
( cd targets/ansible && ./runme.sh $( TEST_FLAGS) )
2016-03-03 20:22:35 +00:00
2016-03-10 01:36:39 +00:00
test_test_infra :
2016-10-12 21:57:53 +00:00
( cd targets/test_infra && ./runme.sh $( TEST_FLAGS) )
2016-03-10 01:36:39 +00:00
2016-03-10 05:29:32 +00:00
setup :
2016-03-03 20:22:35 +00:00
rm -rf $( TEST_DIR)
mkdir -p $( TEST_DIR)
2014-07-24 02:10:58 +00:00
2016-10-12 21:57:53 +00:00
parsing :
( cd targets/parsing && ./runme.sh $( TEST_FLAGS) )
2014-02-20 18:00:05 +00:00
2016-10-12 21:57:53 +00:00
includes :
( cd targets/includes && ./runme.sh $( TEST_FLAGS) )
2016-02-02 11:13:23 +00:00
pull_run :
2016-10-12 21:57:53 +00:00
( cd targets/pull_run && ./runme.sh $( TEST_FLAGS) )
2016-02-02 11:13:23 +00:00
pull_no_127 :
2016-10-12 21:57:53 +00:00
( cd targets/pull_no_127 && ./runme.sh $( TEST_FLAGS) )
2016-02-02 11:13:23 +00:00
pull_limit_inventory :
2016-10-12 21:57:53 +00:00
( cd targets/pull_limit_inventory && ./runme.sh $( TEST_FLAGS) )
2016-02-02 11:13:23 +00:00
2016-10-12 21:57:53 +00:00
unicode :
( cd targets/unicode && ./runme.sh $( TEST_FLAGS) )
2014-07-25 13:59:26 +00:00
2016-10-12 21:57:53 +00:00
test_templating_settings :
( cd targets/templating_settings && ./runme.sh $( TEST_FLAGS) )
2014-12-16 19:17:29 +00:00
2016-10-12 21:57:53 +00:00
test_gathering_facts :
( cd targets/gathering_facts && ./runme.sh $( TEST_FLAGS) )
2016-03-14 21:50:27 +00:00
2016-10-12 21:57:53 +00:00
environment :
( cd targets/environment && ./runme.sh $( TEST_FLAGS) )
2015-08-21 04:37:17 +00:00
2017-01-19 19:39:59 +00:00
test_jinja2_groupby :
( cd targets/filters && ./runme.sh $( TEST_FLAGS) )
2016-03-03 20:22:35 +00:00
non_destructive : setup
2016-11-22 00:23:40 +00:00
ANSIBLE_ROLES_PATH = $( shell pwd ) /targets ansible-playbook non_destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 18:05:03 +00:00
2016-10-12 21:57:53 +00:00
# Tests which can be run when running as root and a local SSH daemon is available.
test_root_ssh : test_connection_local test_connection_chroot test_connection_ssh test_connection_paramiko_ssh test_delegate_to
# For tests running in our Docker containers (identified with "ENV container=docker").
# These tests are run as root and have access to a local SSH daemon.
test_as_docker : test_root_ssh test_async_extra_data
# For tests running in our FreeBSD instances on EC2 (identified with "ENV container=freebsd").
# These tests are run as root and have access to a local SSH daemon.
test_as_freebsd : test_root_ssh
# For tests running in our OS X instances at MacStadium (identified with "ENV container=osx").
# These tests are run as root and have access to a local SSH daemon.
test_as_osx : test_root_ssh
# For tests running as root.
# Login to a local SSH daemon assumed to be unavailable.
test_as_root : test_connection_local test_connection_chroot
2016-07-02 00:59:06 +00:00
2016-10-12 21:57:53 +00:00
# For tests not running as root.
# Login to a local SSH daemon assumed to be unavailable.
test_as_non_root : test_connection_local
# Determine which of the above environments we're running in.
2016-03-20 23:24:01 +00:00
i f e q ( $( container ) , d o c k e r )
2016-10-12 21:57:53 +00:00
TEST_AS_TARGET := test_as_docker
2016-08-01 20:46:37 +00:00
e l s e i f e q ( $( container ) , f r e e b s d )
2016-10-12 21:57:53 +00:00
TEST_AS_TARGET := test_as_freebsd
e l s e i f e q ( $( container ) , o s x )
TEST_AS_TARGET := test_as_osx
e l s e i f e q ( $( EUID ) , 0 )
TEST_AS_TARGET := test_as_root
2016-03-20 23:24:01 +00:00
e l s e
2016-10-12 21:57:53 +00:00
TEST_AS_TARGET := test_as_non_root
2016-03-20 23:24:01 +00:00
e n d i f
2016-10-12 21:57:53 +00:00
test_as : $( TEST_AS_TARGET )
test_connection_local :
( cd targets/connection_local && ./runme.sh $( TEST_FLAGS) )
test_connection_chroot :
( cd targets/connection_chroot && ./runme.sh $( TEST_FLAGS) )
test_connection_docker :
( cd targets/connection_docker && ./runme.sh $( TEST_FLAGS) )
test_connection_libvirt_lxc :
( cd targets/connection_libvirt_lxc && ./runme.sh $( TEST_FLAGS) )
test_connection_jail :
( cd targets/connection_jail && ./runme.sh $( TEST_FLAGS) )
2016-03-04 19:21:43 +00:00
2016-10-12 21:57:53 +00:00
test_connection_ssh :
( cd targets/connection_ssh && ./runme.sh $( TEST_FLAGS) )
2016-03-05 02:14:52 +00:00
2016-10-12 21:57:53 +00:00
test_connection_paramiko_ssh :
( cd targets/connection_paramiko_ssh && ./runme.sh $( TEST_FLAGS) )
2016-03-05 02:14:52 +00:00
2016-10-12 21:57:53 +00:00
test_connection_lxd :
( cd targets/connection_lxd && ./runme.sh $( TEST_FLAGS) )
2016-03-24 17:00:24 +00:00
2016-10-12 21:57:53 +00:00
test_connection_lxc :
( cd targets/connection_lxc && ./runme.sh $( TEST_FLAGS) )
test_connection_winrm :
( cd targets/connection_winrm && ./runme.sh $( TEST_FLAGS) )
2016-03-24 17:00:24 +00:00
2016-03-03 20:22:35 +00:00
destructive : setup
2016-11-22 00:23:40 +00:00
ANSIBLE_ROLES_PATH = $( shell pwd ) /targets ansible-playbook destructive.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-02-20 18:25:19 +00:00
2016-10-12 21:57:53 +00:00
check_mode :
( cd targets/check_mode && ./runme.sh $( TEST_FLAGS) )
2014-02-20 21:10:44 +00:00
2016-10-12 21:57:53 +00:00
test_group_by :
( cd targets/group_by && ./runme.sh $( TEST_FLAGS) )
2014-05-07 02:30:37 +00:00
2014-03-25 17:32:11 +00:00
test_handlers :
2016-10-12 21:57:53 +00:00
( cd targets/handlers && ./runme.sh $( TEST_FLAGS) )
2014-03-25 17:32:11 +00:00
2014-02-20 20:23:51 +00:00
test_hash :
2016-10-12 21:57:53 +00:00
( cd targets/hash && ./runme.sh $( TEST_FLAGS) )
2016-10-13 05:22:46 +00:00
test_var_blending :
( cd targets/var_blending && ./runme.sh $( TEST_FLAGS) )
2016-10-12 21:57:53 +00:00
test_var_precedence :
( cd targets/var_precedence && ./runme.sh $( TEST_FLAGS) )
test_vault :
( cd targets/vault && ./runme.sh $( TEST_FLAGS) )
test_delegate_to :
( cd targets/delegate_to && ./runme.sh $( TEST_FLAGS) )
2014-12-08 20:44:44 +00:00
2016-07-29 04:03:14 +00:00
# Split Windows CI targets to support parallel execution.
# Targets should be balanced to have similar run times.
ci_win : ci_win 1 ci_win 2 ci_win 3
ci_win1 : test_win_group 1
2016-08-02 17:42:07 +00:00
ci_win2 : test_win_group 2 test_binary_modules_winrm
2016-07-29 04:03:14 +00:00
ci_win3 : test_win_group 3 test_connection_winrm
test_winrm : test_win_group 1 test_win_group 2 test_win_group 3
2016-10-12 21:57:53 +00:00
test_win_group1 :
2016-11-22 00:23:40 +00:00
ANSIBLE_ROLES_PATH = $( shell pwd ) /targets ansible-playbook test_win_group1.yml -i inventory.winrm -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2016-07-29 04:03:14 +00:00
2016-10-12 21:57:53 +00:00
test_win_group2 :
2016-11-22 00:23:40 +00:00
ANSIBLE_ROLES_PATH = $( shell pwd ) /targets ansible-playbook test_win_group2.yml -i inventory.winrm -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2016-07-29 04:03:14 +00:00
2016-10-12 21:57:53 +00:00
test_win_group3 :
2016-11-22 00:23:40 +00:00
ANSIBLE_ROLES_PATH = $( shell pwd ) /targets ansible-playbook test_win_group3.yml -i inventory.winrm -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS)
2014-06-18 04:04:17 +00:00
2016-10-12 21:57:53 +00:00
test_tags :
( cd targets/tags && ./runme.sh $( TEST_FLAGS) )
blocks :
( cd targets/blocks && ./runme.sh $( TEST_FLAGS) )
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;
2016-08-30 19:48:28 +00:00
exoscale :
ansible-playbook exoscale.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
exit $$ RC;
2016-09-13 14:03:58 +00:00
jenkins :
ansible-playbook jenkins.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
exit $$ RC;
2016-03-23 20:41:50 +00:00
cloudflare : $( CREDENTIALS_FILE )
ansible-playbook cloudflare.yml -i $( INVENTORY) -e @$( VARS_FILE) -e @$( CREDENTIALS_FILE) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
2017-01-17 22:15:20 +00:00
RC = $$ ? ; \
exit $$ RC;
cloudscale :
ANSIBLE_ROLES_PATH = $( shell pwd ) /targets ansible-playbook cloudscale.yml -i $( INVENTORY) -e @$( VARS_FILE) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
2016-03-23 20:41:50 +00:00
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 ; \
2015-07-10 16:59:52 +00:00
ansible-playbook -i ../../contrib/inventory/consul_io.py consul_inventory.yml
2015-01-24 01:09:03 +00:00
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
2016-01-21 12:00:29 +00:00
test_galaxy : test_galaxy_spec test_galaxy_yaml test_galaxy_git
2014-08-18 11:27:41 +00:00
2016-03-03 20:22:35 +00:00
test_galaxy_spec : setup
2015-02-03 00:17:40 +00:00
mytmpdir = $( MYTMPDIR) ; \
2015-10-03 14:29:28 +00:00
ansible-galaxy install -r galaxy_rolesfile -p $$ mytmpdir/roles -vvvv ; \
2014-08-14 10:20:10 +00:00
cp galaxy_playbook.yml $$ mytmpdir ; \
2016-11-22 00:23:40 +00:00
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
2014-08-14 10:20:10 +00:00
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
2014-08-18 11:27:41 +00:00
exit $$ RC
2016-03-03 20:22:35 +00:00
test_galaxy_yaml : setup
2015-02-03 00:17:40 +00:00
mytmpdir = $( MYTMPDIR) ; \
2015-10-03 14:29:28 +00:00
ansible-galaxy install -r galaxy_roles.yml -p $$ mytmpdir/roles -vvvv; \
2014-08-18 11:27:41 +00:00
cp galaxy_playbook.yml $$ mytmpdir ; \
2016-11-22 00:23:40 +00:00
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
2014-08-18 11:27:41 +00:00
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
exit $$ RC
2015-08-12 23:00:54 +00:00
2016-03-03 20:22:35 +00:00
test_galaxy_git : setup
2016-01-21 12:00:29 +00:00
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 ; \
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook_git.yml -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
exit $$ RC
2016-10-12 21:57:53 +00:00
test_lookup_paths :
( cd targets/lookup_paths && ./runme.sh $( TEST_FLAGS) )
2015-10-02 13:09:12 +00:00
2016-10-12 21:57:53 +00:00
no_log :
( cd targets/no_log && ./runme.sh $( TEST_FLAGS) )
2016-02-12 17:56:46 +00:00
2016-10-12 21:57:53 +00:00
test_binary_modules_winrm :
( cd targets/binary_modules_winrm && ./runme.sh $( TEST_FLAGS) )
2016-08-02 17:42:07 +00:00
2016-10-12 21:57:53 +00:00
test_binary_modules_posix :
( cd targets/binary_modules_posix && ./runme.sh $( TEST_FLAGS) )
2016-07-01 21:52:45 +00:00
2016-10-12 21:57:53 +00:00
test_async_extra_data :
( cd targets/async_extra_data && ./runme.sh $( TEST_FLAGS) )
2016-07-31 15:48:32 +00:00
2016-10-12 21:57:53 +00:00
test_hosts_field :
( cd targets/hosts_field && ./runme.sh $( TEST_FLAGS) )
2016-07-31 15:48:32 +00:00
2016-10-12 21:57:53 +00:00
test_lookup_properties :
( cd targets/lookup_properties && ./runme.sh $( TEST_FLAGS) )
2016-09-22 00:25:54 +00:00
2016-10-12 21:57:53 +00:00
args :
( cd targets/args && ./runme.sh $( TEST_FLAGS) )
2017-02-24 17:33:24 +00:00
test_callback_retry_task_name :
( cd targets/callback_retry_task_name && ./runme.sh $( TEST_FLAGS) )