模块的Ansible和route53不支持的参数:connection

时间:2016-02-11 17:36:09

标签: dns ansible amazon-route53

我正在尝试使用亚马逊的Route53服务运行Ansible剧本,但我在标题中收到了错误。

$ ansible-playbook play-dns.yml
PLAY [localhost] ************************************************************** 
GATHERING FACTS *************************************************************** 
ok: [localhost]
TASK: [configure dns] ********************************************************* 
failed: [localhost] => {"failed": true}
msg: unsupported parameter for module: connection
FATAL: all hosts have already failed -- aborting
PLAY RECAP ******************************************************************** 
          to retry, use: --limit @/home/myuser/play-dns.retry
localhost                  : ok=1    changed=0    unreachable=0    failed=1

这是我的游戏:

$ cat play-dns.yml
---
- hosts: localhost
  tasks:
  - name: configure dns
    route53:
      command: create
      aws_access_key: 'XXXXXXXXXXXXXXXXXXXX'
      aws_secret_key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
      zone: myzone.info
      record: test.myzone.info
      type: A
      ttl: 7200
      value: 1.1.1.1
      wait: yes
      connection: local

这是我的Ansible主机文件:

$ cat /etc/ansible/hosts|grep localhost
[localhost]
localhost           ansible_connection=local

如果我从hosts文件中删除ansible_connection = local

$ cat /etc/ansible/hosts|grep localhost
[localhost]
localhost

然后我收到了这个错误:

$ ansible-playbook play-dns.yml
PLAY [localhost] ************************************************************** 
GATHERING FACTS *************************************************************** 
fatal: [localhost] => SSH Error: ssh: connect to host localhost port 22: Connection refused
    while connecting to 127.0.0.1:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
TASK: [configure dns] ********************************************************* 
fatal: [localhost] => SSH Error: ssh: connect to host localhost port 22: Connection refused
    while connecting to 127.0.0.1:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
FATAL: all hosts have already failed -- aborting
PLAY RECAP ******************************************************************** 
          to retry, use: --limit @/home/myuser/play-dns.retry
localhost                  : ok=0    changed=0    unreachable=2    failed=0

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您的问题只是缩进。目前Ansible正在解析您的playbook并将连接线视为route53模块的参数,然后抱怨connection不是该模块的有效参数。

相反,你只需要将该行取消与主机相同的级别,以便Ansible将其作为整个剧本的参数进行解析而不是模块:

---
- hosts: localhost
  connection: local
  tasks:
  - name: configure dns
    route53:
      command: create
      aws_access_key: 'XXXXXXXXXXXXXXXXXXXX'
      aws_secret_key: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
      zone: myzone.info
      record: test.myzone.info
      type: A
      ttl: 7200
      value: 1.1.1.1
      wait: yes