2017-03-07 4 views
-1

나는 어제 Anagers로 시작하여 개인 XenServer에 VM을 프로비저닝하려고했습니다. XenGuide Sharknet.usAnonymous Xen Provisioning

그래서 내가 ansible에서 핑 (ping)와 젠 서버를 reache 수 있습니다

나는이 가이드를 따라 갔다.

내 프로젝트 폴더의 구조는 다음과 같습니다

Project Folder 
|-- site.yml 
|-- hosts (inventory file) 
+-+ host_vars 
| |-- master01.lab.local 
| |-- master02.lab.local 
| |-- slave01.lab.local 
| |-- slave02.lab.local 
+-+ group_vars 
| |-- all 
+-+ roles 
| +-+ master 
| | |-- main.yml 
| +-+ slave 
| | |-- main.yml 
| +-+ vm 
| | |-- create_vm.yml 
| | |-- main.yml 

내 파일 Site.yml :

hostname: master01 
ram: 8GiB 
vcpus: 4 

groups_vars : 예를 들어

[vm] 
master01.lab.local 
master02.lab.local 
slave01.lab.local 
slave02.lab.local 

[hypervisor] 
xen01.lab.local 

HOST_VARS/master01.lab.local을/all 파일 :

centos_template_uid: 11fd3dc9-96cc-49af-b091-a2ca7e94c589 
primary_sr_uid: 6e074a6e-bf19-031d-7c65-c9ab2749a3da 
user_network_uid: 087af565-bd27-cd0a-93e4-724beeb27735 

역할/VM/main.yml

- name: Check if VM exists 
    command: xe vm-list name-label={{ hostname }} 
    register: found 
    delegate_to: xen01.lab.local 

- include: create_vm.yml 
    when: found.stdout == "" 

- name: Wait for the Kickstart install to complete and the VM to reboot 
    local_action: wait_for host={{ hostname }}.lab.local port=22 delay=15 timeout=1200 state=started 

역할/VM/create_vm.yml

- name: Prevent template from creating storage 
    command: xe template-param-remove uuid={{ centos_template_uid }} param-name=other-config param-key=disks 
    ignore_errors: yes 
    delegate_to: xen01.lab.loca 

- name: Create VM 
    command: xe vm-install template={{ centos_template_uid }} new-name-label="{{ hostname }}" sr-uuid={{ primary_sr_uid }} 
    register: vm 
    delegate_to: xen01.lab.local 

- name: Set the repository location 
    command: xe vm-param-set uuid={{ vm.stdout }} other-config:install-repository="http://ansible-repo.lab.local/" 
    delegate_to: xen01.lab.local 

- name: Set the location of the kickstart file 
    command: xe vm-param-set uuid={{ vm.stdout }} PV-args="ks=http://ansible-repo.lab.local/ks.cfg ksdevice=eth0" 
    delegate_to: xen01.lab.local 

- name: Assign a network 
    command: xe vif-create vm-uuid={{ vm.stdout }} network-uuid={{ user_network_uid }} mac={{ mac }} device=0 
    delegate_to: xen01.lab.local 

- name: Allocate VM storage 
    command: xe vdi-create name-label="{{ hostname }} storage" sr-uuid={{ primary_sr_uid }} type=system virtual-size=25GiB 
    register: disk 
    delegate_to: xen01.lab.local 

- name: Assign storage to VM 
command: xe vbd-create vdi-uuid={{ disk.stdout }} vm-uuid={{ vm.stdout }} type=Disk bootable=true device=0 
delegate_to: xen01.lab.local 

- name: Set the VM RAM limits 
    command: xe vm-memory-limits-set vm={{ vm.stdout }} static-min={{ ram }} static-max={{ ram }} dynamic-min={{ ram }} dynamic-max={{ ram }} 
    delegate_to: xen01.lab.local 

- name: Set the number of CPUs 
    command: xe vm-param-set VCPUs-max={{ vcpus }} uuid={{ vm.stdout }} 
    delegate_to: xen01.lab.local 

- name: Launch the VM 
    command: xe vm-start uuid={{ vm.stdout }} 
    delegate_to: xen01.lab.local 

내가 이제 다음 명령을 실행하는 경우 : 내가 얻을

ansible-playbook -i hosts site.yml -K 

을 다음 오류 :

ERROR! Syntax Error while loading YAML. 

The error appears to have been in '/var/ansible/ansible-playbooks/provisioning/xen/roles/vm/tasks/main.yml': line 2, column 1, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 
- name: Check if VM exists 
    command: xe vm-list name-label={{ hostname }} 
^ here 
We could be wrong, but this one looks like it might be an issue with 
missing quotes. Always quote template expression brackets when they 
start a value. For instance: 

with_items: 
    - {{ foo }} 

Should be written as: 

with_items: 
    - "{{ foo }}" 

누군가이 오류를 알고 있습니까?

답변

0

command: xe vm-list name-label={{ hostname }} 

command: xe vm-list name-label="{{ hostname }}" 

동일하게해야합니다 경우 당신에게 그렇게 당신은 변수를 포함하는 문자열을 인용한다 변수

따옴표없이 다른 모든 작업에 적용