2017-06-29 21:34:54 +02:00
# This Makefile is for legacy integration tests.
# Most new tests should be implemented using ansible-test.
# Existing tests are slowly being migrated to ansible-test.
2018-06-29 20:12:01 +02:00
# See: https://docs.ansible.com/ansible/devel/dev_guide/testing_integration.html
2017-06-29 21:34:54 +02:00
2016-03-03 21:22:35 +01:00
TEST_DIR ?= ~/ansible_testing
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
2015-10-16 16:41:01 +02: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 14:52:36 +01:00
e n d i f
2015-10-17 18:45:29 +02:00
CREDENTIALS_FILE ?= credentials.yml
2014-03-18 15:15:02 +01: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 12:20:10 +02:00
# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
2015-02-03 01:17:40 +01:00
MYTMPDIR = $( shell mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir' )
2014-08-14 12:20:10 +02:00
2014-05-21 21:17:53 +02:00
VAULT_PASSWORD_FILE = vault-password
2015-01-24 02:09:03 +01:00
CONSUL_RUNNING := $( shell python consul_running.py)
2016-03-04 20:21:43 +01:00
EUID := $( shell id -u -r)
2015-01-24 02:09:03 +01:00
2016-05-11 22:36:29 +02:00
UNAME := $( shell uname | tr '[:upper:]' '[:lower:]' )
2016-03-10 06:29:32 +01:00
setup :
2016-03-03 21:22:35 +01:00
rm -rf $( TEST_DIR)
mkdir -p $( TEST_DIR)
2014-07-24 04:10:58 +02:00
2015-05-05 14:42:07 +02:00
cloud : amazon rackspace azure
2014-02-24 20:37:23 +01:00
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
2015-05-05 14:42:07 +02:00
azure_cleanup :
python cleanup_azure.py -y --match= " ^ $( CLOUD_RESOURCE_PREFIX) "
2018-11-28 13:07:47 +01:00
digital_ocean : $( CREDENTIALS_FILE )
ansible-playbook digital_ocean.yml -i $( INVENTORY) -e @$( VARS_FILE) $( CREDENTIALS_ARG) -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
exit $$ RC;
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 :
2015-01-09 21:50:23 +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 )
2017-10-02 15:17:08 +02:00
ANSIBLE_HOST_KEY_CHECKING = False ANSIBLE_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
2015-05-05 14:42:07 +02: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 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
2016-08-30 21:48:28 +02:00
exoscale :
ansible-playbook exoscale.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
exit $$ RC;
2016-09-13 16:03:58 +02:00
jenkins :
ansible-playbook jenkins.yml -i $( INVENTORY) -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
RC = $$ ? ; \
exit $$ RC;
2016-03-23 21:41:50 +01: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 23:15:20 +01:00
RC = $$ ? ; \
exit $$ RC;
cloudscale :
2017-06-29 21:34:54 +02:00
ansible-playbook cloudscale.yml -i $( INVENTORY) -e @$( VARS_FILE) -e " resource_prefix= $( CLOUD_RESOURCE_PREFIX) " -v $( TEST_FLAGS) ; \
2016-03-23 21:41:50 +01:00
RC = $$ ? ; \
exit $$ RC;
2015-01-24 02:09:03 +01:00
$(CONSUL_RUNNING) :
consul :
i f e q ( $( CONSUL_RUNNING ) , T r u e )
ansible-playbook -i $( INVENTORY) consul.yml ; \
2015-07-10 18:59:52 +02:00
ansible-playbook -i ../../contrib/inventory/consul_io.py consul_inventory.yml
2015-01-24 02:09:03 +01: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 13:00:29 +01:00
test_galaxy : test_galaxy_spec test_galaxy_yaml test_galaxy_git
2014-08-18 13:27:41 +02:00
2016-03-03 21:22:35 +01:00
test_galaxy_spec : setup
2015-02-03 01:17:40 +01:00
mytmpdir = $( MYTMPDIR) ; \
2015-10-03 16:29:28 +02:00
ansible-galaxy install -r galaxy_rolesfile -p $$ mytmpdir/roles -vvvv ; \
2014-08-14 12:20:10 +02:00
cp galaxy_playbook.yml $$ mytmpdir ; \
2016-11-22 01:23:40 +01:00
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
2014-08-14 12:20:10 +02:00
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
2014-08-18 13:27:41 +02:00
exit $$ RC
2016-03-03 21:22:35 +01:00
test_galaxy_yaml : setup
2015-02-03 01:17:40 +01:00
mytmpdir = $( MYTMPDIR) ; \
2015-10-03 16:29:28 +02:00
ansible-galaxy install -r galaxy_roles.yml -p $$ mytmpdir/roles -vvvv; \
2014-08-18 13:27:41 +02:00
cp galaxy_playbook.yml $$ mytmpdir ; \
2016-11-22 01:23:40 +01:00
ansible-playbook -i $( INVENTORY) $$ mytmpdir/galaxy_playbook.yml -e @$( VARS_FILE) -v $( TEST_FLAGS) ; \
2014-08-18 13:27:41 +02:00
RC = $$ ? ; \
rm -rf $$ mytmpdir ; \
exit $$ RC
2015-08-13 01:00:54 +02:00
2016-03-03 21:22:35 +01:00
test_galaxy_git : setup
2016-01-21 13:00:29 +01: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