大网数据广告活动
服务器运维问答

AWS VPC Subnet InvalidSubnet.Range only when using Ansible

· 52CE 我爱测

I have an AWS VPC with a v4 CIDR of 10.0.0.0/16 (I double-checked that CIDR). When I try to create a subnet on AWS using the following ansible task ec2_vpc_subnet: vpc_id: "vpc-<the-non-default-vpc-id>" az: eu-central-1c cidr: "1…

问题原文

原帖链接 · okirmis · CC BY-SA 4.0

I have an AWS VPC with a v4 CIDR of 10.0.0.0/16 (I double-checked that CIDR).

When I try to create a subnet on AWS using the following ansible task

ec2_vpc_subnet:
    vpc_id: "vpc-<the-non-default-vpc-id>"
    az: eu-central-1c
    cidr: "10.0.2.0/24"
    state: present

then I get a an error:

botocore.exceptions.ClientError: An error occurred (InvalidSubnet.Range) when calling the CreateSubnet operation: The CIDR '10.0.2.0/24' is invalid.

However, using the CLI aws ec2 create-subnet --vpc-id vpc-<definetly-the-same-as-used-in-ansible> --availability-zone eu-central-1c --cidr-block 10.0.2.0/24 or the AWS web console is working fine.

What could be the reason for that behavior or am I not using the ansible module correctly?

已采纳解答

原帖链接 · okirmis · CC BY-SA 4.0

Finally, I found the problem. The example I've posted actually works, but I removed the IPv6-CIDR because I thought that the message was clear about what the problem is (IPv4).

Turns out I had a typo in the IPv6-CIDR. So when Ansible/AWS complains about an invalid IPv4 subrange, double-check your IPv6 settings (and always post complete examples on StackExchange ...).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。