错误:在Ansible Playbook中,local_action不是此级别的合法参数

时间:2015-03-26 05:56:46

标签: yaml ansible

尝试使用ansible来旋转linode上的实例。我根据http://docs.ansible.com/linode_module.html

安装了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-playbook test.yml
错误:在Ansible Playbook中,local_action不是此级别的合法参数

2 个答案:

答案 0 :(得分:7)

您缺少Playbook的连接/主机部分。请参阅文档中的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

答案 1 :(得分:1)

哈!谢谢Josh!只是玩缩进,这有效:

---
- 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