我最近开始使用 Ansible 自动化 Infoblox,如果这篇文章没有多大意义,请原谅我,但基本上我正在尝试在网格成员中启动 DNS 服务。这是我目前的剧本:
- name: Get object reference of the DNS service
ansible.builtin.uri:
url: "https://{hotsname_ip}/wapi/v2.12.2/request"
body_format: json
user: "admin"
password: "infoblox"
validate_certs: no
return_content: yes
method: GET
force_basic_auth: yes
status_code: 200
register: content
- name: Use object refence to start DNS service
ansible.builtin.uri:
url: "https://{hotsname_ip}/wapi/v2.12.2/{{ content.json[0][\"_ref\"] }}"
user: "admin"
password: "infoblox"
validate_certs: no
return_content: yes
method: PUT
force_basic_auth: yes
status_code: 201, 301, 200
headers:
Content-Type: "application/json"
body:
enable_dns: true
body_format: json
我做错了什么?我的想法对吗? 顺便说一句,这是我运行此剧本时提示的错误:
FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'json'. 'dict object' has no attribute 'json'\n\nThe error appears to be in '/root/ansible_test/playbooks/manage_member.yml': line 48, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Use object refence to start DNS service\n ^ here\n"}
如果我评论第二个任务,剧本运行成功但它没有启动服务所以我猜错误是在第二个任务“使用对象引用启动 DNS 服务”