Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29541

Ansible AWS EC2 Creation Error- "msg": "Instance creation failed => InvalidIPAddress.InUse

$
0
0

I am trying to create EC2 Instance with predefined Private IP Address using Ansible. Also, the provided Private IP Address is not in use. I tried the same using AWS Management Console and able to create but using Ansible getting error.

Getting the error-- "msg": "Instance creation failed => InvalidIPAddress.InUse:

Ansible: 2.9.4

OS: Ubuntu 18.4.4

Could someone please help me here?

Thanks in advance.

Code Sample--

- name: Create AWS resources
  hosts: localhost
  connection: local
  gather_facts: False
  vars:
      keypair: keys_xxxx
      security_group: sg-xxxxxxxxxxxxxxxxxx
      instance_type: t2.small
      image: ami-xxxxxxxxxxxxxxxxxxxx
      region: us-east-1
  tasks:
  - name: create an EC2 instance
    local_action:
      aws_access_key: "xxxxx"
      aws_secret_key: "0xxxxxx"
      key_name: "{{ keypair }}"
      group_id: "{{ security_group }}"
      vpc_subnet_id: "{{ item.subnet }}"
      instance_type: "{{ instance_type }}"
      image: "{{ image }}"
      region: "{{ region }}"
      module: ec2
      private_ip: "{{ item.ip }}"
      wait: yes    
      instance_tags:
        Name: "{{ item.name }}"
        type: consul
      exact_count: 1
      count_tag:
        Name: "{{ item.name }}"      
      volumes:
        - device_name: /dev/sda1
          volume_size: 25
    with_items:
      - { ip: "10.168.0.1", subnet: "subnet-xxxxxx", name: 'Test Server }

Viewing all articles
Browse latest Browse all 29541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>