forked from hashicorp/packer
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provisioner/ansible: assume scp target is file
Assume the scp target is a file instead of a directory. Assuming the scp target is a file instead of a directory allows uploading files to a node being provisioned with the ssh communciator using sftp and with the winrm communicator. It is fully compatible with ansible; ansible communicators only allow for files to be uploaded (when the copy module is used to upload a directory, ansible walks the directory and uploads files one at a time). Update docuemntation to explain how to provision a Windows image. Extend tests that use ssh to communicate with the node to include single files, recursive copies, and content-only recursive copies. Add test to verify support for the winrm communicator. Remove the err argument from adapter.scpExec, because it was unused. Fixes hashicorp#3911
- Loading branch information
Showing
17 changed files
with
843 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/fixtures/provisioner-ansible/connection_plugins/packer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
from ansible.plugins.connection.ssh import Connection as SSHConnection | ||
|
||
class Connection(SSHConnection): | ||
''' ssh based connections for powershell via packer''' | ||
|
||
transport = 'packer' | ||
has_pipelining = True | ||
become_methods = [] | ||
allow_executable = False | ||
module_implementation_preferences = ('.ps1', '') | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(Connection, self).__init__(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this file's parent directory should not be transferred to the node. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This file and its parent directory should be transferred to the node. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"variables": {}, | ||
"provisioners": [ | ||
{ | ||
"type": "ansible", | ||
"playbook_file": "./playbook.yml", | ||
"extra_arguments": [ | ||
], | ||
"sftp_command": "/usr/bin/false", | ||
"use_sftp": false | ||
} | ||
], | ||
"builders": [ | ||
{ | ||
"type": "googlecompute", | ||
"account_file": "{{user `account_file`}}", | ||
"project_id": "{{user `project_id`}}", | ||
"image_name": "packerbats-scp-to-sftp-{{timestamp}}", | ||
"source_image": "debian-7-wheezy-v20141108", | ||
"zone": "us-central1-a", | ||
"ssh_file_transfer_method": "sftp" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- hosts: default:packer-test | ||
gather_facts: no | ||
tasks: | ||
#- debug: msg="testing regular modules that function with Windows: raw, fetch, slurp, setup" | ||
- name: raw test | ||
raw: date /t | ||
- debug: msg="testing windows modules" | ||
#- win_file: path=tmp/remote-dir state=directory | ||
#- name: win_shell test | ||
#win_shell: date /t | ||
- name: win_copy test | ||
win_copy: src=dir/file.txt dest=file.txt | ||
#- win_copy: src=dir/file.txt dest=/tmp/remote-dir/file.txt | ||
#- fetch: src=/tmp/remote-dir/file.txt dest=fetched-dir validate=yes fail_on_missing=yes | ||
#- win_copy: src=largish-file.txt dest=/tmp/largish-file.txt | ||
- debug: msg="packer does not support downloading from windows" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"variables": {}, | ||
"provisioners": [ | ||
{ | ||
"type": "ansible", | ||
"playbook_file": "./win-playbook.yml", | ||
"extra_arguments": [ | ||
"--connection", "packer", | ||
"--extra-vars", "ansible_shell_type=powershell ansible_shell_executable=None" | ||
] | ||
} | ||
], | ||
"builders": [ | ||
{ | ||
"type": "googlecompute", | ||
"account_file": "{{user `account_file`}}", | ||
"project_id": "{{user `project_id`}}", | ||
"image_name": "packerbats-winrm-{{timestamp}}", | ||
"source_image": "windows-server-2012-r2-dc-v20160916", | ||
"communicator": "winrm", | ||
"zone": "us-central1-a", | ||
"disk_size": 50, | ||
"winrm_username": "packer", | ||
"winrm_use_ssl": true, | ||
"winrm_insecure": true, | ||
"metadata": { | ||
"sysprep-specialize-script-cmd": "winrm set winrm/config/service/auth @{Basic=\"true\"}" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.