如何在本地运行Ansible?

时间:2016-12-13 04:07:37

标签: ansible ansible-playbook ansible-2.x

我使用的是Ansible 2.2.0.0版。

我对Ansible有以下目录结构:

- (void) playAmbientSound {

    [self runAction:self.pAmbientSound completion:^{
        [self playAmbientSound];
    }];
}



- (void) initSounds {
    // Avatar swim sound
    self.pSwimSound = [SKAction playSoundFileNamed:@"swim-sound.m4a" waitForCompletion:NO];

    // Animation sound
    self.pAmbientSound = [SKAction playSoundFileNamed:@"ambient-final.mp3" waitForCompletion:YES];
    // Do the Sound in a loop
    [self playAmbientSound];

}

1。 kafka.yml in group-vars

├── group-vars
│   └── kafka.yml
├── inventory
│   └── kafka
├── kafka.yml
└── roles
    └── kafka
        └── tasks
            ├── install.yml
            ├── main.yml
            └── verification.yml

2。库存==>卡夫卡

software_dir: /home/sohanvir/softwares
kafka_installation_dir: "{{ software_dir }}/kafka"

kafka_version: kafka_2.11-0.10.1.0.tgz
kafka_download_link: "http://redrockdigimark.com/apachemirror/kafka/0.10.1.0/{{ kafka_version}}"

第3。剧本==> kafka.yml

[kafka]
localhost

4。角色==> kafka ==>任务

1。 main.yml

- name: Install Kafka
  hosts: kafka
  connection: local
  roles:
    - kafka

2。 install.yml

- include: verification.yml
- include: main.yml

第3。 verification.yml

- name: Download kafka from link
  get_url:
    url: '{{ kafka_download_link }}'
    dest: '{{ kafka_installation_dir }}'

- name: Extract tar file
  shell: cd '{{ kafka_installation_dir }}' && tar -xzf '{{ kafka_2.11-0.10.1.0.tgz }}'

我正在使用以下命令运行playbook:

- name: Verify Directory Structure
  shell: mkdir -p '{{ kafka_installation_dir }}'
  ignore_errors: no

但是得到以下错误:

 ansible-playbook -i inventory/kafka kafka.yml 

1 个答案:

答案 0 :(得分:3)

将目录名group-vars更改为group_vars

请参阅Splitting Out Host and Group Specific Data'