---
- 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
On Monday, July 31, 2023 at 7:15:27 AM UTC-7 Faizan UI Haq wrote:
> 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.
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/04a46c39-ab54-43eb-aa8f-df99b3aceda2n%40googlegroups.com.