2017-04-27 1 views
1

설치와 관련된 일부 컨텍스트를 제공하기 위해 VirtualBox를 공급자로 사용하는 Packer와 Windows 8.1 (x64) VM을 스핀 업하려는 중입니다. 로컬 맥북. 필자는 성공적으로 작동하는 Packer (Animate 공급자가 제공되지 않음)로 Windows 빌드를 테스트했습니다.Packer 문제 Windows 용 가상 프로 시저 8.1 가상 머신의 VM

그러나 나는 (신뢰할 수없는 지역이 아닌) 유능한 공급자를 사용하려고 할 때 그렇게 할 수 없습니다. 필자는 패커 문서에 지정된대로 패커 빌드를 설정했습니다 : https://www.packer.io/docs/provisioners/ansible.html. Windows VM을 처음 부팅 할 때 http://docs.ansible.com/ansible/intro_windows.html#windows-system-prep에 언급 된 ConfigureRemotingForAnsible.ps1도 실행합니다.

내 기술 스택 버전은 다음과 같습니다

  • 패커 1.0.0
  • Ansible 2.3.0.0
  • 파이썬 2.7.11
  • pywinrm 0.2.2
  • 버추얼 5.1.20

packer.json 파일은 다음과 같습니다.

,451,515,
{ 
    "builders": [ 
    { 
     "type": "virtualbox-iso", 
     "iso_url": "{{ user `iso_url` }}", 
     "iso_checksum_type": "sha1", 
     "iso_checksum": "{{ user `iso_checksum` }}", 
     "communicator": "winrm", 
     "headless": "{{ user `headless` }}", 
     "boot_wait": "9m", 
     "winrm_use_ssl": true, 
     "winrm_insecure": true, 
     "winrm_host": "127.0.0.1", 
     "winrm_port": 5986, 
     "winrm_username": "packer", 
     "winrm_password": "packer", 
     "winrm_timeout": "8h", 
     "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"", 
     "guest_os_type": "Windows81_64", 
     "guest_additions_mode": "disable", 
     "floppy_files": [ 
     "./answer_files/81/Autounattend.xml", 
     "./scripts/enable-winrm.ps1", 
     "./scripts/ConfigureRemotingForAnsible.ps1" 
     ], 
     "vboxmanage": [ 
     [ "modifyvm", "{{.Name}}", "--natpf1", "winrm,tcp,,5986,,5986" ], 
     [ "modifyvm", "{{.Name}}", "--memory", "4096" ], 
     [ "modifyvm", "{{.Name}}", "--vram", "32" ], 
     [ "modifyvm", "{{.Name}}", "--cpus", "2" ] 
     ] 
    } 
    ], 
    "provisioners": [ 
    { 
     "type": "ansible", 
     "playbook_file": "./provisioner/run-powershell.yml", 
     "local_port": "5986", 
     "user": "packer", 
     "extra_arguments": [ 
     "-vvvv", 
     "--connection", "packer", 
     "--extra-vars", "ansible_shell_type=powershell ansible_shell_executable=None" 
     ] 
    } 
    ], 
    "post-processors": [ 
    { 
     "type": "vagrant", 
     "keep_input_artifact": true, 
     "output": "output-formats/windows_81_{{.Provider}}.box", 
     "vagrantfile_template": "vagrantfile-windows_81.template" 
    } 
    ], 
    "variables": { 
    "headless": "false", 
    "iso_checksum": "CHECKSUM_VALUE", 
    "iso_url": "/path/to/iso" 
    } 
} 

런 powershell.yml 각본은 다음과 같습니다

# This playbook tests the script module on Windows hosts 

- name: Run Ansible play 
    hosts: all 
    gather_facts: no 
    tasks: 
    - name: Ping windows machine 
     win_command: cmd.exe /c powershell -Command "Write-Host 'Hello World!'" 
# - name: Ping windows machine 
#  win_ping: 
# - name: Create a file 
#  win_file: 
#  path: "C:\\Windows\\Temp\\ansible_test.txt" 
#  state: touch 
# - name: Run powershell script 
#  script: a:\helloworld.ps1 

packer.log에서 볼 수 있듯이 오류의 마지막 조각은 다음과 같습니다 ansible 창 작업

ui: [0;32m virtualbox-iso: <127.0.0.1> (1, '{"exception":"At C:\\\\Users\\\\packer\\\\AppData\\\\Local\\\\Temp\\\\ansible-tmp-1493195766.64-166408222728325\\\\win_command.ps1:25 char:16\\r\\n+ $parsed_args = Parse-Args $args $false\\r\\n+    ~~~~~~~~~~","msg":"The term \\u0027Parse-Args\\u0027 is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.","failed":true}\r\n', 'OpenSSH_6.9p1, LibreSSL 2.1.8\r\ndebug1: Reading configuration data /Users/mk/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 7498\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to 127.0.0.1 closed.\r\n')[0m 
ui: [0;32m virtualbox-iso: The full traceback is:[0m 
ui: [0;32m virtualbox-iso: At C:\Users\packer\AppData\Local\Temp\ansible-tmp-1493195766.64-166408222728325\win_command.ps1:25 char:16[0m 
ui: [0;32m virtualbox-iso: + $parsed_args = Parse-Args $args $false[0m 
ui: [0;32m virtualbox-iso: +    ~~~~~~~~~~[0m 
ui: [0;32m virtualbox-iso: fatal: [default]: FAILED! => {[0m 
ui: [0;32m virtualbox-iso:  "changed": false,[0m 
ui: [0;32m virtualbox-iso:  "failed": true,[0m 
ui: [0;32m virtualbox-iso:  "msg": "The term 'Parse-Args' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."[0m 
ui: [0;32m virtualbox-iso: }[0m 
ui: [0;32m virtualbox-iso: to retry, use: --limit @/Users/mk/Workspace/packer/win81/provisioner/run-powershell.retry[0m 
ui: [0;32m virtualbox-iso:[0m 
ui: [0;32m virtualbox-iso: PLAY RECAP *********************************************************************[0m 
ui: [0;32m virtualbox-iso: default     : ok=0 changed=0 unreachable=0 failed=1[0m 
ui: [0;32m virtualbox-iso:[0m 
packer: 2017/04/26 18:36:31 shutting down the SSH proxy 
packer: 2017/04/26 18:36:31 Executing VBoxManage: []string{"controlvm", "packer-virtualbox-iso-1493195197", "poweroff"} 

없음 (Windows VM에서 .ps1로 실행)가 실행될 수 있으며 위와 동일한 오류가 발생할 수 있습니다 (내 게임 북에서 주석 처리 된 행 참조). Parse-Args cmdlet의 모든 오류는 표준 Powershell 함수이지만 Windows 8.1 VM에서 어떤 이유로 인식되지 않습니다.

FYI : SSL을 사용하지 않고 포트 5985에서 winrm을 실행 해봤는데 동일한 오류가 발생했습니다.

이 문제를 해결하려면 도움이 필요합니다.

+0

wth는'parse-args'입니까? – 4c74356b41

+0

표준 PowerShell cmdlet은 아니지만 Ansible과 함께 제공 될 수 있습니다. Git 여기에 설명되어 있습니다 : https://github.com/technolo-g/ansible_venv/blob/master/lib/python2.7/site-packages/ansible/module_utils/powershell.ps1 –

+0

"가능한 JSON 인수를 구문 분석하는 도우미 함수 단일 인수로 전달 된 파일에서 모듈 " –

답변

1

똑같은 문제가있었습니다. 나는 최근 버전의 Anabilities에서 파손 된 것을 발견했습니다. 나는 2.2.0으로 나의 어새 스틱 설치를 다운 그레이드했고 패커 문서에 따라 예상대로 작동하고있다.

+0

Thanks @ Ricardo Herrera, 문제를 해결했습니다. 어니 셔 버전으로 어떻게 좁혔습니까? – mk7

+0

@ mk7 https://github.com/hashicorp/packer/issues/4904 –