Ansible 删除 AWS Route53 TXT 记录
我正在尝试使用 Ansible 删除 AWS Route53 TXT 记录
这是我的剧本的一部分
- name: "Retrieve the details for {{ item }}.{{ build_number }}.{{ internal_domain }} TXT Record"
community.aws.route53:
state: get
private_zone: true
record: "{{ item }}.{{ build_number }}.{{ internal_domain }}"
type: TXT
zone: "{{ internal_domain }}"
register: rec_TXT
- name: display record
debug: var=rec_TXT
- name: "Delete {{ item }}.{{ build_number }}.{{ internal_domain }} TXT Record"
community.aws.route53:
state: absent
private_zone: true
record: "{{ rec_TXT.set.record }}"
ttl: "{{ rec_TXT.set.ttl }}"
type: "{{ rec_TXT.set.type }}"
value: "{{ rec_TXT.set.value | string }}"
zone: "{{ rec_TXT.set.zone }}"
when: rec_TXT.set | length > 0
,这会导致错误
"msg": "[Tried to delete resource record set [name='dashboard.uat1tx.test.xyz.internal.', type='TXT'] but the rdata provided is invalid]"
在详细模式下运行剧本时 (-vvv) get 请求产生
ok: [localhost] => {
"rec_TXT": {
"changed": false,
"failed": false,
"nameservers": [
"ns-1536.awsdns-00.co.uk.",
"ns-0.awsdns-00.com.",
"ns-1024.awsdns-00.org.",
"ns-512.awsdns-00.net."
],
"set": {
"alias": false,
"failover": null,
"health_check": null,
"hosted_zone_id": "HIAAGVXXXXPM9",
"identifier": null,
"record": "dashboard.uat1tx.test.xyz.internal.",
"region": null,
"ttl": "300",
"type": "TXT",
"value": "\"heritage=external-dns,external-dns/owner=SST4985-EKSCluster-uat1tx,external-dns/resource=service/default/k8s-dashboard-kubernetes-dashboard\"",
"values": [
"\"heritage=external-dns,external-dns/owner=SST4985-EKSCluster-uat1tx,external-dns/resource=service/default/k8s-dashboard-kubernetes-dashboard\""
],
"weight": null,
"zone": "test.xyz.internal."
}
}
}
absent 播放产生
The full traceback is:
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 687, in main
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 457, in invoke_with_throttling_retries
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 453, in invoke_with_throttling_retries
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 428, in commit
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 422, in commit
File "/usr/local/lib/python3.8/site-packages/boto/route53/record.py", line 168, in commit
return self.connection.change_rrsets(self.hosted_zone_id, self.to_xml())
File "/usr/local/lib/python3.8/site-packages/boto/route53/connection.py", line 473, in change_rrsets
raise exception.DNSServerError(response.status,
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"alias": null,
"alias_evaluate_target_health": false,
"alias_hosted_zone_id": null,
"aws_access_key": null,
"aws_ca_bundle": null,
"aws_config": null,
"aws_secret_key": null,
"debug_botocore_endpoint_logs": false,
"ec2_url": null,
"failover": null,
"health_check": null,
"hosted_zone_id": null,
"identifier": null,
"overwrite": null,
"private_zone": true,
"profile": null,
"record": "dashboard.uat1tx.test.xyz.internal.",
"region": null,
"retry_interval": 500,
"security_token": null,
"state": "absent",
"ttl": 300,
"type": "TXT",
"validate_certs": true,
"value": [
"\"\"heritage=external-dns",
"external-dns/owner=SST4985-EKSCluster-uat1tx",
"external-dns/resource=service/default/k8s-dashboard-kubernetes-dashboard\"\""
],
"vpc_id": null,
"wait": false,
"wait_timeout": 300,
"weight": null,
"zone": "test.xyz.internal."
}
},
"msg": "[Tried to delete resource record set [name='dashboard.uat1tx.test.xyz.internal.', type='TXT'] but the rdata provided is invalid]"
}
问题在于值中的逗号。
有人提出了问题,但没有提供提示。 https://github.com/ansible/ansible/issues/58084
我该如何将“字面”刺痛传递给值选项?
任何人都可以提供任何提示/解决方案吗?!!!
I'm trying to delete AWS Route53 TXT records using Ansible
This is a section of my playbook
- name: "Retrieve the details for {{ item }}.{{ build_number }}.{{ internal_domain }} TXT Record"
community.aws.route53:
state: get
private_zone: true
record: "{{ item }}.{{ build_number }}.{{ internal_domain }}"
type: TXT
zone: "{{ internal_domain }}"
register: rec_TXT
- name: display record
debug: var=rec_TXT
- name: "Delete {{ item }}.{{ build_number }}.{{ internal_domain }} TXT Record"
community.aws.route53:
state: absent
private_zone: true
record: "{{ rec_TXT.set.record }}"
ttl: "{{ rec_TXT.set.ttl }}"
type: "{{ rec_TXT.set.type }}"
value: "{{ rec_TXT.set.value | string }}"
zone: "{{ rec_TXT.set.zone }}"
when: rec_TXT.set | length > 0
this results in the error
"msg": "[Tried to delete resource record set [name='dashboard.uat1tx.test.xyz.internal.', type='TXT'] but the rdata provided is invalid]"
When running the playbook in verbose mode (-vvv)
the get request produces
ok: [localhost] => {
"rec_TXT": {
"changed": false,
"failed": false,
"nameservers": [
"ns-1536.awsdns-00.co.uk.",
"ns-0.awsdns-00.com.",
"ns-1024.awsdns-00.org.",
"ns-512.awsdns-00.net."
],
"set": {
"alias": false,
"failover": null,
"health_check": null,
"hosted_zone_id": "HIAAGVXXXXPM9",
"identifier": null,
"record": "dashboard.uat1tx.test.xyz.internal.",
"region": null,
"ttl": "300",
"type": "TXT",
"value": "\"heritage=external-dns,external-dns/owner=SST4985-EKSCluster-uat1tx,external-dns/resource=service/default/k8s-dashboard-kubernetes-dashboard\"",
"values": [
"\"heritage=external-dns,external-dns/owner=SST4985-EKSCluster-uat1tx,external-dns/resource=service/default/k8s-dashboard-kubernetes-dashboard\""
],
"weight": null,
"zone": "test.xyz.internal."
}
}
}
The absent play produced
The full traceback is:
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 687, in main
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 457, in invoke_with_throttling_retries
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 453, in invoke_with_throttling_retries
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 428, in commit
File "/tmp/ansible_community.aws.route53_payload_xb_ilskb/ansible_community.aws.route53_payload.zip/ansible_collections/community/aws/plugins/modules/route53.py", line 422, in commit
File "/usr/local/lib/python3.8/site-packages/boto/route53/record.py", line 168, in commit
return self.connection.change_rrsets(self.hosted_zone_id, self.to_xml())
File "/usr/local/lib/python3.8/site-packages/boto/route53/connection.py", line 473, in change_rrsets
raise exception.DNSServerError(response.status,
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"alias": null,
"alias_evaluate_target_health": false,
"alias_hosted_zone_id": null,
"aws_access_key": null,
"aws_ca_bundle": null,
"aws_config": null,
"aws_secret_key": null,
"debug_botocore_endpoint_logs": false,
"ec2_url": null,
"failover": null,
"health_check": null,
"hosted_zone_id": null,
"identifier": null,
"overwrite": null,
"private_zone": true,
"profile": null,
"record": "dashboard.uat1tx.test.xyz.internal.",
"region": null,
"retry_interval": 500,
"security_token": null,
"state": "absent",
"ttl": 300,
"type": "TXT",
"validate_certs": true,
"value": [
"\"\"heritage=external-dns",
"external-dns/owner=SST4985-EKSCluster-uat1tx",
"external-dns/resource=service/default/k8s-dashboard-kubernetes-dashboard\"\""
],
"vpc_id": null,
"wait": false,
"wait_timeout": 300,
"weight": null,
"zone": "test.xyz.internal."
}
},
"msg": "[Tried to delete resource record set [name='dashboard.uat1tx.test.xyz.internal.', type='TXT'] but the rdata provided is invalid]"
}
The issue is with the commas in the values.
Someone has raised an issue, but no tips provided. https://github.com/ansible/ansible/issues/58084
How can I pass the 'literal' sting the the value option?
Can anyone provide any tips/solutions please?!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于我有一个类似的用例,但使用其他 REST API,因此我想在这里分享我的解决方案方法。
在我的用例中,还需要
CSV_STRING
。就像我设置值一样
如果我已经将其作为列表,
我可以使用设置值
但是,查看 ansible-collections/community.aws/blob/main/plugins/modules/route53.py,看起来
value
不需要字符串。以及
route53
的文档 –在 Amazon Route 53 DNS 服务中添加或删除条目 对于参数值
,需要一个字符串元素列表。这意味着,您需要执行相反的操作,将逗号上的字符串拆分为列表。
进一步问答
Since I have a somehow similar use case, but with an other REST API, I wanted to share my solution approach here.
In my use case also a
CSV_STRING
is expected. Something likeI set the value with
If I have it as list already
I can set the value with
However, looking into the current source code of ansible-collections/community.aws/blob/main/plugins/modules/route53.py, it looks like that
value
do not expect a string.As well the documentation of
route53
– add or delete entries in Amazons Route 53 DNS service say that for parametervalue
, a list of string elements is expected.This means, you would need to do the opposite, splitting up your string on comma into a list before.
Further Q&A
我作弊并默认使用命令模块
我仍然想使用route53模块并解决问题。
我有一个模板
戏剧看起来像
I cheated and defaulted to the command module
I would still like to use the route53 module and resolve the issue.
I have a template
The plays looks like