From 323ff78206d1748e323ffe272b7d83b2c70e2f19 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Sirot <jcsirot@gmail.com>
Date: Sat, 13 Feb 2016 15:16:28 +0100
Subject: [PATCH] Update playbooks for automatic deployment tests

---
 tests/cloud_playbooks/create-aws.yml                   | 2 +-
 tests/cloud_playbooks/delete-aws.yml                   | 2 ++
 tests/local_inventory/hosts.cfg                        | 2 +-
 tests/templates/{inventory.ini.j2 => inventory-aws.j2} | 6 +++---
 4 files changed, 7 insertions(+), 5 deletions(-)
 rename tests/templates/{inventory.ini.j2 => inventory-aws.j2} (84%)

diff --git a/tests/cloud_playbooks/create-aws.yml b/tests/cloud_playbooks/create-aws.yml
index b0749ab5b..88d3326d5 100644
--- a/tests/cloud_playbooks/create-aws.yml
+++ b/tests/cloud_playbooks/create-aws.yml
@@ -20,7 +20,7 @@
 
   - name: Template the inventory
     template:
-      src: templates/inventory.ini.j2
+      src: ../templates/inventory-aws.j2
       dest: "{{ inventory_path }}"
 
   - name: Wait until SSH is available
diff --git a/tests/cloud_playbooks/delete-aws.yml b/tests/cloud_playbooks/delete-aws.yml
index 3b44f3091..29e9a4b95 100644
--- a/tests/cloud_playbooks/delete-aws.yml
+++ b/tests/cloud_playbooks/delete-aws.yml
@@ -9,6 +9,8 @@
   - name: Terminate EC2 instances
     local_action:
       module: ec2
+      aws_access_key: "{{ aws_access_key }}"
+      aws_secret_key: "{{ aws_secret_key }}"
       state: absent
       instance_ids: "{{ ansible_ec2_instance_id }}"
       region: "{{ ansible_ec2_placement_region }}"
diff --git a/tests/local_inventory/hosts.cfg b/tests/local_inventory/hosts.cfg
index a3550c31b..2302edae3 100644
--- a/tests/local_inventory/hosts.cfg
+++ b/tests/local_inventory/hosts.cfg
@@ -1 +1 @@
-localhost ansible_connection=localx
\ No newline at end of file
+localhost ansible_connection=local
diff --git a/tests/templates/inventory.ini.j2 b/tests/templates/inventory-aws.j2
similarity index 84%
rename from tests/templates/inventory.ini.j2
rename to tests/templates/inventory-aws.j2
index d6358efb9..e0771a94e 100644
--- a/tests/templates/inventory.ini.j2
+++ b/tests/templates/inventory-aws.j2
@@ -1,6 +1,6 @@
-node1 ansible_ssh_host={{ec2.instances[0].public_ip}} ansible_ssh_user=admin
-node2 ansible_ssh_host={{ec2.instances[1].public_ip}} ansible_ssh_user=admin
-node3 ansible_ssh_host={{ec2.instances[2].public_ip}} ansible_ssh_user=admin
+node1 ansible_ssh_host={{ec2.instances[0].public_ip}} ansible_ssh_user={{ssh_user}}
+node2 ansible_ssh_host={{ec2.instances[1].public_ip}} ansible_ssh_user={{ssh_user}}
+node3 ansible_ssh_host={{ec2.instances[2].public_ip}} ansible_ssh_user={{ssh_user}}
 
 [kube-master]
 node1
-- 
GitLab