Stop source/destination check of an Instance

17 views
Skip to first unread message

Faizan UI Haq

unread,
Jul 31, 2023, 10:15:27 AM7/31/23
to Ansible Project

I am calling a global role in the main file to spin up an ec2 instance in the aws then i want to use local role to stop the source/destination check for that instance. I am not finding a way to do it using any of the ansible module. Could you please suggest me the module if there is any module. The error i get is

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.NoCredentialsError: Unable to locate credentials
fatal: [localhost -> 54.149.210.58]: FAILED! => {"boto3_version": "1.28.11", "botocore_version": "1.31.11", "changed": false, "msg": "Failed to get vpc_id for subnet-A1B2c34: Unable to locate credentials"}

I used amazon.aws.ec2_instance, amazon.aws.ec2_eni and command as well  in below mentioned way;
- name: Stop Source/Destination Check for EC2 instance
  become: true
  command: "aws ec2 modify-instance-attribute --instance-id {{ instance_id }} --no-source-dest-check"
One thing to be noted is the ansible-server and the new server which i am deploying are in the same subnet. Also the ansible-server has admin access.

Atul Nasir

unread,
Aug 19, 2023, 2:07:57 PM8/19/23
to Ansible Project
---
- name: Create EC2 instance
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Create EC2 instance
      ec2_instance:
        key_name: your_key_name
        instance_type: t2.micro
        image: ami-12345678
        region: us-east-1
        wait: yes
      register: ec2_instance_result


- name: Stop Source/Destination Check for EC2 instance
  hosts: localhost
  gather_facts: no
  tasks:

    - name: Stop Source/Destination Check
      ec2_mod_instance_attribute:
        instance_ids: "{{ ec2_instance_result.instances[0].id }}"
        source_dest_check: no
      register: stop_source_dest_result
Reply all
Reply to author
Forward
0 new messages