diff --git a/test/fixtures/provisioner-ansible/all_options.json b/test/fixtures/provisioner-ansible/all_options.json index 3b18add8f..561d8d275 100644 --- a/test/fixtures/provisioner-ansible/all_options.json +++ b/test/fixtures/provisioner-ansible/all_options.json @@ -4,13 +4,6 @@ { "type": "shell-local", "command": "echo 'TODO(bhcleek): write the public key to $HOME/.ssh/known_hosts and stop using ANSIBLE_HOST_KEY_CHECKING=False'" - }, { - "type": "shell", - "inline": [ - "apt-get update", - "apt-get -y install python openssh-sftp-server", - "ls -l /usr/lib" - ] }, { "type": "ansible", "playbook_file": "./playbook.yml", @@ -34,8 +27,8 @@ "account_file": "{{user `account_file`}}", "project_id": "{{user `project_id`}}", "image_name": "packerbats-alloptions-{{timestamp}}", - "source_image": "debian-7-wheezy-v20141108", + "source_image": "debian-8-jessie-v20161027", "zone": "us-central1-a", - "ssh_username": "root" + "ssh_username": "debian" }] } diff --git a/test/fixtures/provisioner-ansible/docker.json b/test/fixtures/provisioner-ansible/docker.json new file mode 100644 index 000000000..9cc788b51 --- /dev/null +++ b/test/fixtures/provisioner-ansible/docker.json @@ -0,0 +1,26 @@ +{ + "variables": {}, + "provisioners": [ + { + "type": "shell", + "inline": [ + "apt-get update", + "apt-get -y install python" + ] + }, { + "type": "ansible", + "playbook_file": "./playbook.yml", + "extra_arguments": [ + ], + "sftp_command": "/usr/bin/false", + "use_sftp": false + } + ], + "builders": [ + { + "type": "docker", + "image": "debian:jessie", + "discard": true + } + ] +} diff --git a/test/fixtures/provisioner-ansible/minimal.json b/test/fixtures/provisioner-ansible/minimal.json index 9408342e2..b2bec543b 100644 --- a/test/fixtures/provisioner-ansible/minimal.json +++ b/test/fixtures/provisioner-ansible/minimal.json @@ -12,9 +12,9 @@ "account_file": "{{user `account_file`}}", "project_id": "{{user `project_id`}}", "image_name": "packerbats-minimal-{{timestamp}}", - "source_image": "debian-7-wheezy-v20141108", + "source_image": "debian-8-jessie-v20161027", "zone": "us-central1-a", - "ssh_username": "root" + "ssh_username": "debian" } ] } diff --git a/test/fixtures/provisioner-ansible/playbook.yml b/test/fixtures/provisioner-ansible/playbook.yml index d53e56199..484841a77 100644 --- a/test/fixtures/provisioner-ansible/playbook.yml +++ b/test/fixtures/provisioner-ansible/playbook.yml @@ -2,8 +2,8 @@ - hosts: default:packer-test gather_facts: no tasks: - - name: touch /root/ansible-raw-test - raw: touch /root/ansible-raw-test + - name: touch + raw: touch /tmp/ansible-raw-test - name: raw test raw: date - name: command test diff --git a/test/fixtures/provisioner-ansible/scp-to-sftp.json b/test/fixtures/provisioner-ansible/scp-to-sftp.json index c310a5790..4d608ffc2 100644 --- a/test/fixtures/provisioner-ansible/scp-to-sftp.json +++ b/test/fixtures/provisioner-ansible/scp-to-sftp.json @@ -16,9 +16,9 @@ "account_file": "{{user `account_file`}}", "project_id": "{{user `project_id`}}", "image_name": "packerbats-scp-to-sftp-{{timestamp}}", - "source_image": "debian-7-wheezy-v20141108", + "source_image": "debian-8-jessie-v20161027", "zone": "us-central1-a", - "ssh_username": "root", + "ssh_username": "debian", "ssh_file_transfer_method": "sftp" } ] diff --git a/test/fixtures/provisioner-ansible/scp.json b/test/fixtures/provisioner-ansible/scp.json index 321f9bb68..b745d7370 100644 --- a/test/fixtures/provisioner-ansible/scp.json +++ b/test/fixtures/provisioner-ansible/scp.json @@ -16,9 +16,9 @@ "account_file": "{{user `account_file`}}", "project_id": "{{user `project_id`}}", "image_name": "packerbats-scp-{{timestamp}}", - "source_image": "debian-7-wheezy-v20141108", + "source_image": "debian-8-jessie-v20161027", "zone": "us-central1-a", - "ssh_username": "root" + "ssh_username": "debian" } ] } diff --git a/test/fixtures/provisioner-ansible/sftp.json b/test/fixtures/provisioner-ansible/sftp.json index 89bbac4ea..8c0f7034d 100644 --- a/test/fixtures/provisioner-ansible/sftp.json +++ b/test/fixtures/provisioner-ansible/sftp.json @@ -2,14 +2,6 @@ "variables": {}, "provisioners": [ { - "type": "shell", - "inline": [ - "apt-get update", - "apt-get -y install python openssh-sftp-server", - "ls -l /usr/lib", - "#/usr/lib/sftp-server -?" - ] - }, { "type": "ansible", "playbook_file": "./playbook.yml", "sftp_command": "/usr/lib/sftp-server -e -l INFO", @@ -22,9 +14,9 @@ "account_file": "{{user `account_file`}}", "project_id": "{{user `project_id`}}", "image_name": "packerbats-sftp-{{timestamp}}", - "source_image": "debian-7-wheezy-v20141108", + "source_image": "debian-8-jessie-v20161027", "zone": "us-central1-a", - "ssh_username": "root" + "ssh_username": "debian" } ] } diff --git a/test/provisioner_ansible.bats b/test/provisioner_ansible.bats index 19620cb1e..c9dc9abd9 100755 --- a/test/provisioner_ansible.bats +++ b/test/provisioner_ansible.bats @@ -43,6 +43,12 @@ teardown() { rm -rf $FIXTURE_ROOT/fetched-dir } +@test "ansible provisioner: build docker.json" { + cd $FIXTURE_ROOT + run packer build ${USER_VARS} $FIXTURE_ROOT/docker.json + [ "$status" -eq 0 ] + diff -r dir fetched-dir/default/tmp/remote-dir > /dev/null +} @test "ansible provisioner: build minimal.json" { cd $FIXTURE_ROOT run packer build ${USER_VARS} $FIXTURE_ROOT/minimal.json