ERROR: local_action is not a legal parameter at this level in an Ansible Playbook

ERROR: local_action is not a legal parameter at this level in an Ansible Playbook

尝试使用 ansible 在 linode 上启动实例。我已经根据 http://docs.ansible.com/linode_module.html

pip 安装了 linode-python

我还根据 http://softwareas.com/ansible-and-linode-what-i-learned-about-controlling-linodes-from-ansible/

进行了额外调整

命令行:

ansible localhost -m linode  -a "api_key=xxx name=test plan=1 distribution=124 datacenter=3 password=xxx state=present"

有效。为什么这个剧本不起作用?

---
- local_action:
     module: linode
     api_key: 'xxx'
     name: quickpic
     plan: 1
     datacenter: 3
     distribution: 124
     password: 'xxx'
     wait: yes
     wait_timeout: 600
     state: present

$ansible-剧本test.yml
错误:local_action 不是 Ansible Playbook 中此级别的合法参数

您缺少剧本的 connection/host 部分。请参阅文档中的 Local Playbooks

- hosts: 127.0.0.1
  connection: local
  tasks:
    - name: Create a linode machine
      linode: 
        api_key: 'longStringFromLinodeApi'
        name: linode-test1
        plan: 1
        ...etc

哈!谢谢乔希!刚刚玩了缩进,这个有效:

---
- hosts: 127.0.0.1
  connection: local
  tasks:
    - name: Create linode machine
      linode: 
        api_key: 'xxx'
        name: test
        plan: 1
        datacenter: 3
        distribution: 124
        password: 'xxx'
        wait: yes
        wait_timeout: 600
        state: present