2014-10-29 54 views
0

我是Ansible的新手,我不確定我的主機文件是什麼樣子,如果我想從本地配置羣集。我的yaml文件如下:使用Ansible Clouldformation模塊配置CoreOS羣集

--- 
- hosts: coreos 
    tasks: 
    - name: Automation CoreOS Cluster 
     action: cloudformation > 
     stack_name="automation_ansible_coreos_cluster" state=present 
     region=us-east-1 disable_rollback=true 
     template=files/coreos-stable-pv.template 
     args: 
     template_parameters: 
      InstanceType: m1.small 
      ClusterSize: 3 
      DiscoveryURL: 'https://discovery.etcd.io/<val>' 
      KeyPair: Automation 
     tags: 
     Stack: ansible-cloudformation-coreos 

任何意見將不勝感激。

回答

0

下工作

劇本:

--- 
- hosts: coreos 
    connection: local 
    tasks: 
    - name: Automation CoreOS Cluster 
    cloudformation: stack_name='automation-ansible-coreos-cluster' state=present region='us-east-1'   disable_rollback=true template='files/coreos-stable-pv.template' 
    args: 
     template_parameters: 
     InstanceType: t1.micro 
     ClusterSize: 3 
     DiscoveryURL: 'https://discovery.etcd.io/<val>' 
     KeyPair: Automation 
    register: stack 
    tags: 
     Stack: ansible-cloudformation-coreos 

主機文件:

[coreos] 
host1 
host2 
host3 
2

轉換劇本看起來像下面這樣:

--- 
- hosts: localhost 
    connection: local 
    gather_facts: false 
    tasks: 
    - name: Automation CoreOS Cluster 
    cloudformation: stack_name='automation_ansible_coreos_cluster' state=present region='us-east-1' disable_rollback=true template='files/coreos-stable-pv.template' 
    args: 
     template_parameters: 
     InstanceType: m1.small 
     ClusterSize: 3 
     DiscoveryURL: 'https://discovery.etcd.io/<val>' 
     KeyPair: Automation 
    register: stack 
    tags: 
     Stack: ansible-cloudformation-coreos 

設置主機localhost和連接到local能夠解決您的問題,增加的gather_facts: false將跳過從清單文件收集信息和繼續配置你的機器,這就解決了需要尋找機器的問題(還沒有被創建!)

另外,你需要AWS用戶cr有足夠的訪問edentials對問題進行操作